Most of the code is shared with instance migrate, so we actually only need
to add the parameter and pass its value along the the common code.
Also, tests and harep are updated to support the right set of options to
the "failover" opcode.
Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
CLEANUP_OPT = cli_option("--cleanup", dest="cleanup",
default=False, action="store_true",
CLEANUP_OPT = cli_option("--cleanup", dest="cleanup",
default=False, action="store_true",
- help="Instead of performing the migration, try to"
- " recover from a failed cleanup. This is safe"
+ help="Instead of performing the migration/failover,"
+ " try to recover from a failed cleanup. This is safe"
" to run even if the instance is healthy, but it"
" will create extra replication traffic and "
" disrupt briefly the replication (like during the"
" to run even if the instance is healthy, but it"
" will create extra replication traffic and "
" disrupt briefly the replication (like during the"
STATIC_OPT = cli_option("-s", "--static", dest="static",
action="store_true", default=False,
STATIC_OPT = cli_option("-s", "--static", dest="static",
action="store_true", default=False,
FailoverInstance, ARGS_ONE_INSTANCE,
[FORCE_OPT, IGNORE_CONSIST_OPT, SUBMIT_OPT, SHUTDOWN_TIMEOUT_OPT,
DRY_RUN_OPT, PRIORITY_OPT, DST_NODE_OPT, IALLOCATOR_OPT,
FailoverInstance, ARGS_ONE_INSTANCE,
[FORCE_OPT, IGNORE_CONSIST_OPT, SUBMIT_OPT, SHUTDOWN_TIMEOUT_OPT,
DRY_RUN_OPT, PRIORITY_OPT, DST_NODE_OPT, IALLOCATOR_OPT,
+ IGNORE_IPOLICY_OPT, CLEANUP_OPT],
"[-f] <instance>", "Stops the instance, changes its primary node and"
" (if it was originally running) starts it on the new node"
" (the secondary for mirrored instances or any node"
"[-f] <instance>", "Stops the instance, changes its primary node and"
" (if it was originally running) starts it on the new node"
" (the secondary for mirrored instances or any node"
_ExpandNamesForMigration(self)
self._migrater = \
_ExpandNamesForMigration(self)
self._migrater = \
- TLMigrateInstance(self, self.op.instance_name, False, True, False,
- self.op.ignore_consistency, True,
+ TLMigrateInstance(self, self.op.instance_name, self.op.cleanup, True,
+ False, self.op.ignore_consistency, True,
self.op.shutdown_timeout, self.op.ignore_ipolicy)
self.tasklets = [self._migrater]
self.op.shutdown_timeout, self.op.ignore_ipolicy)
self.tasklets = [self._migrater]
"SHUTDOWN_TIMEOUT": self.op.shutdown_timeout,
"OLD_PRIMARY": source_node,
"NEW_PRIMARY": target_node,
"SHUTDOWN_TIMEOUT": self.op.shutdown_timeout,
"OLD_PRIMARY": source_node,
"NEW_PRIMARY": target_node,
+ "FAILOVER_CLEANUP": self.op.cleanup,
}
if instance.disk_template in constants.DTS_INT_MIRROR:
}
if instance.disk_template in constants.DTS_INT_MIRROR:
_PIgnoreIpolicy,
_PIAllocFromDesc("Iallocator for deciding the target node for"
" shared-storage instances"),
_PIgnoreIpolicy,
_PIAllocFromDesc("Iallocator for deciding the target node for"
" shared-storage instances"),
+ ("cleanup", False, ht.TBool,
+ "Whether a previously failed failover should be cleaned up"),
, opTargetNode = Nothing
, opIgnoreIpolicy = False
, opIallocator = Nothing
, opTargetNode = Nothing
, opIgnoreIpolicy = False
, opIallocator = Nothing
+ , opMigrationCleanup = False
, pMigrationTargetNode
, pIgnoreIpolicy
, pIallocator
, pMigrationTargetNode
, pIgnoreIpolicy
, pIallocator
])
, ("OpInstanceMigrate",
[ pInstanceName
])
, ("OpInstanceMigrate",
[ pInstanceName
genMaybe genNodeNameNE <*> genMaybe genNameNE
"OP_INSTANCE_FAILOVER" ->
OpCodes.OpInstanceFailover <$> genFQDN <*> arbitrary <*> arbitrary <*>
genMaybe genNodeNameNE <*> genMaybe genNameNE
"OP_INSTANCE_FAILOVER" ->
OpCodes.OpInstanceFailover <$> genFQDN <*> arbitrary <*> arbitrary <*>
- genMaybe genNodeNameNE <*> arbitrary <*> genMaybe genNameNE
+ genMaybe genNodeNameNE <*> arbitrary <*> genMaybe genNameNE <*>
+ arbitrary
"OP_INSTANCE_MIGRATE" ->
OpCodes.OpInstanceMigrate <$> genFQDN <*> arbitrary <*> arbitrary <*>
genMaybe genNodeNameNE <*> arbitrary <*>
"OP_INSTANCE_MIGRATE" ->
OpCodes.OpInstanceMigrate <$> genFQDN <*> arbitrary <*> arbitrary <*>
genMaybe genNodeNameNE <*> arbitrary <*>