Revision 8e2524c3 lib/bootstrap.py

b/lib/bootstrap.py
373 373
                             (node, result.fail_reason, result.output))
374 374

  
375 375

  
376
def MasterFailover():
376
def MasterFailover(no_voting=False):
377 377
  """Failover the master node.
378 378

  
379 379
  This checks that we are not already the master, and will cause the
380 380
  current master to cease being master, and the non-master to become
381 381
  new master.
382 382

  
383
  @type no_voting: boolean
384
  @param no_voting: force the operation without remote nodes agreement
385
                      (dangerous)
386

  
383 387
  """
384 388
  sstore = ssconf.SimpleStore()
385 389

  
......
401 405
                               " master candidates is:\n"
402 406
                               "%s" % ('\n'.join(mc_no_master)))
403 407

  
404
  vote_list = GatherMasterVotes(node_list)
405

  
406
  if vote_list:
407
    voted_master = vote_list[0][0]
408
    if voted_master is None:
409
      raise errors.OpPrereqError("Cluster is inconsistent, most nodes did not"
410
                                 " respond.")
411
    elif voted_master != old_master:
412
      raise errors.OpPrereqError("I have wrong configuration, I believe the"
413
                                 " master is %s but the other nodes voted for"
414
                                 " %s. Please resync the configuration of"
415
                                 " this node." % (old_master, voted_master))
408
  if not no_voting:
409
    vote_list = GatherMasterVotes(node_list)
410

  
411
    if vote_list:
412
      voted_master = vote_list[0][0]
413
      if voted_master is None:
414
        raise errors.OpPrereqError("Cluster is inconsistent, most nodes did"
415
                                   " not respond.")
416
      elif voted_master != old_master:
417
        raise errors.OpPrereqError("I have a wrong configuration, I believe"
418
                                   " the master is %s but the other nodes"
419
                                   " voted %s. Please resync the configuration"
420
                                   " of this node." %
421
                                   (old_master, voted_master))
416 422
  # end checks
417 423

  
418 424
  rcode = 0
......
436 442
  # cluster info
437 443
  cfg.Update(cluster_info)
438 444

  
439
  result = rpc.RpcRunner.call_node_start_master(new_master, True)
445
  # 2.0.X: Don't start the master if no_voting is true
446
  result = rpc.RpcRunner.call_node_start_master(new_master, not no_voting)
440 447
  if result.failed or not result.data:
441 448
    logging.error("Could not start the master role on the new master"
442 449
                  " %s, please check", new_master)

Also available in: Unified diff