Commit 8d66f58a authored by René Nussbaumer's avatar René Nussbaumer
Browse files

htools: Use OpMigrateInstance with allow_failover option

Before hbal decided on the fly if an instance is migratable or not. As
we implemented failover fallback in commit d5cafd31

 we can start to
use that.
Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent e9c487be
......@@ -1042,9 +1042,7 @@ iMoveToJob nl il idx move =
let inst = Container.find idx il
iname = Instance.name inst
lookNode = Just . Container.nameOf nl
opF = if Instance.running inst
then OpCodes.OpMigrateInstance iname True False
else OpCodes.OpFailoverInstance iname False
opF = OpCodes.OpMigrateInstance iname True False True
opR n = OpCodes.OpReplaceDisks iname (lookNode n)
OpCodes.ReplaceNewSecondary [] Nothing
in case move of
......
......@@ -227,7 +227,8 @@ instance Arbitrary OpCodes.OpCode where
"OP_INSTANCE_FAILOVER" ->
liftM2 OpCodes.OpFailoverInstance arbitrary arbitrary
"OP_INSTANCE_MIGRATE" ->
liftM3 OpCodes.OpMigrateInstance arbitrary arbitrary arbitrary
liftM4 OpCodes.OpMigrateInstance arbitrary arbitrary arbitrary
arbitrary
_ -> fail "Wrong opcode")
instance Arbitrary Jobs.OpStatus where
......
......@@ -59,7 +59,7 @@ data OpCode = OpTestDelay Double Bool [String]
| OpReplaceDisks String (Maybe String) ReplaceDisksMode
[Int] (Maybe String)
| OpFailoverInstance String Bool
| OpMigrateInstance String Bool Bool
| OpMigrateInstance String Bool Bool Bool
deriving (Show, Read, Eq)
......@@ -67,7 +67,7 @@ opID :: OpCode -> String
opID (OpTestDelay _ _ _) = "OP_TEST_DELAY"
opID (OpReplaceDisks _ _ _ _ _) = "OP_INSTANCE_REPLACE_DISKS"
opID (OpFailoverInstance _ _) = "OP_INSTANCE_FAILOVER"
opID (OpMigrateInstance _ _ _) = "OP_INSTANCE_MIGRATE"
opID (OpMigrateInstance _ _ _ _) = "OP_INSTANCE_MIGRATE"
loadOpCode :: JSValue -> J.Result OpCode
loadOpCode v = do
......@@ -95,7 +95,8 @@ loadOpCode v = do
inst <- extract "instance_name"
live <- extract "live"
cleanup <- extract "cleanup"
return $ OpMigrateInstance inst live cleanup
allow_failover <- extract "allow_failover"
return $ OpMigrateInstance inst live cleanup allow_failover
_ -> J.Error $ "Unknown opcode " ++ op_id
saveOpCode :: OpCode -> JSValue
......@@ -125,11 +126,12 @@ saveOpCode op@(OpFailoverInstance inst consist) =
, ("ignore_consistency", showJSON consist) ]
in makeObj ol
saveOpCode op@(OpMigrateInstance inst live cleanup) =
saveOpCode op@(OpMigrateInstance inst live cleanup allow_failover) =
let ol = [ ("OP_ID", showJSON $ opID op)
, ("instance_name", showJSON inst)
, ("live", showJSON live)
, ("cleanup", showJSON cleanup) ]
, ("cleanup", showJSON cleanup)
, ("allow_failover", showJSON allow_failover) ]
in makeObj ol
instance JSON OpCode where
......
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