Revision a8ae3eb5

b/lib/cmdlib.py
2202 2202
                                   " based ping to noded port")
2203 2203

  
2204 2204
    cp_size = self.cfg.GetClusterInfo().candidate_pool_size
2205
    mc_now, _ = self.cfg.GetMasterCandidateStats()
2206
    master_candidate = mc_now < cp_size
2205
    if self.op.readd:
2206
      exceptions = [node]
2207
    else:
2208
      exceptions = []
2209
    mc_now, mc_max = self.cfg.GetMasterCandidateStats(exceptions)
2210
    # the new node will increase mc_max with one, so:
2211
    mc_max = min(mc_max + 1, cp_size)
2212
    self.master_candidate = mc_now < mc_max
2207 2213

  
2208
    self.new_node = objects.Node(name=node,
2209
                                 primary_ip=primary_ip,
2210
                                 secondary_ip=secondary_ip,
2211
                                 master_candidate=master_candidate,
2212
                                 offline=False, drained=False)
2214
    if self.op.readd:
2215
      self.new_node = self.cfg.GetNodeInfo(node)
2216
      assert self.new_node is not None, "Can't retrieve locked node %s" % node
2217
    else:
2218
      self.new_node = objects.Node(name=node,
2219
                                   primary_ip=primary_ip,
2220
                                   secondary_ip=secondary_ip,
2221
                                   master_candidate=self.master_candidate,
2222
                                   offline=False, drained=False)
2213 2223

  
2214 2224
  def Exec(self, feedback_fn):
2215 2225
    """Adds the new node to the cluster.
......
2218 2228
    new_node = self.new_node
2219 2229
    node = new_node.name
2220 2230

  
2231
    # for re-adds, reset the offline/drained/master-candidate flags;
2232
    # we need to reset here, otherwise offline would prevent RPC calls
2233
    # later in the procedure; this also means that if the re-add
2234
    # fails, we are left with a non-offlined, broken node
2235
    if self.op.readd:
2236
      new_node.drained = new_node.offline = False
2237
      self.LogInfo("Readding a node, the offline/drained flags were reset")
2238
      # if we demote the node, we do cleanup later in the procedure
2239
      new_node.master_candidate = self.master_candidate
2240

  
2241
    # notify the user about any possible mc promotion
2242
    if new_node.master_candidate:
2243
      self.LogInfo("Node will be a master candidate")
2244

  
2221 2245
    # check connectivity
2222 2246
    result = self.rpc.call_version([node])[node]
2223 2247
    result.Raise()
......
2313 2337

  
2314 2338
    if self.op.readd:
2315 2339
      self.context.ReaddNode(new_node)
2340
      # make sure we redistribute the config
2341
      self.cfg.Update(new_node)
2342
      # and make sure the new node will not have old files around
2343
      if not new_node.master_candidate:
2344
        result = self.rpc.call_node_demote_from_mc(new_node.name)
2345
        msg = result.RemoteFailMsg()
2346
        if msg:
2347
          self.LogWarning("Node failed to demote itself from master"
2348
                          " candidate status: %s" % msg)
2316 2349
    else:
2317 2350
      self.context.AddNode(new_node)
2318 2351

  
b/scripts/gnt-node
100 100
  output = cl.QueryConfigValues(['cluster_name'])
101 101
  cluster_name = output[0]
102 102

  
103
  if readd:
104
    # clear the offline and drain flags on the node
105
    ToStdout("Resetting the 'offline' and 'drained' flags due to re-add")
106
    op = opcodes.OpSetNodeParams(node_name=node, force=True,
107
                                 offline=False, drained=False)
108

  
109
    result = SubmitOpCode(op, cl=cl)
110
    if result:
111
      ToStdout("Modified:")
112
      for param, data in result:
113
        ToStdout(" - %-5s -> %s", param, data)
114
  else:
103
  if not readd:
115 104
    ToStderr("-- WARNING -- \n"
116 105
             "Performing this operation is going to replace the ssh daemon"
117 106
             " keypair\n"

Also available in: Unified diff