Commit aa7a5c90 authored by Michele Tartara's avatar Michele Tartara
Browse files

Add cleanup parameter to instance failover



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: default avatarMichele Tartara <mtartara@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 3fc743d6
......@@ -1088,12 +1088,12 @@ SHOWCMD_OPT = cli_option("--show-cmd", dest="show_command",
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"
" migration")
" migration/failover")
STATIC_OPT = cli_option("-s", "--static", dest="static",
action="store_true", default=False,
......
......@@ -1467,7 +1467,7 @@ commands = {
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],
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"
......
......@@ -117,8 +117,8 @@ class LUInstanceFailover(LogicalUnit):
_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]
......@@ -140,6 +140,7 @@ class LUInstanceFailover(LogicalUnit):
"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:
......
......@@ -1520,6 +1520,8 @@ class OpInstanceFailover(OpCode):
_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"),
]
OP_RESULT = ht.TNone
......
......@@ -318,6 +318,7 @@ detectBroken nl inst =
, opTargetNode = Nothing
, opIgnoreIpolicy = False
, opIallocator = Nothing
, opMigrationCleanup = False
}
])
| offSec ->
......
......@@ -84,6 +84,7 @@ $(genOpCode "OpCode"
, pMigrationTargetNode
, pIgnoreIpolicy
, pIallocator
, pMigrationCleanup
])
, ("OpInstanceMigrate",
[ pInstanceName
......
......@@ -116,7 +116,8 @@ instance Arbitrary OpCodes.OpCode where
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 <*>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment