Before hbal decided on the fly if an instance is migratable or not. As
we implemented failover fallback in commit d5cafd31456 we can start to
use that.
---
htools/Ganeti/HTools/Cluster.hs | 4 +---
htools/Ganeti/HTools/QC.hs | 6 ++----
htools/Ganeti/OpCodes.hs | 24 +++++++-----------------
3 files changed, 10 insertions(+), 24 deletions(-)
diff --git a/htools/Ganeti/HTools/Cluster.hs b/htools/Ganeti/HTools/Cluster.hs
index 4588e77..17f9085 100644
--- a/htools/Ganeti/HTools/Cluster.hs
+++ b/htools/Ganeti/HTools/Cluster.hs
@@ -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
diff --git a/htools/Ganeti/HTools/QC.hs b/htools/Ganeti/HTools/QC.hs
index 534a7b1..98d48fd 100644
--- a/htools/Ganeti/HTools/QC.hs
+++ b/htools/Ganeti/HTools/QC.hs
@@ -215,7 +215,6 @@ instance Arbitrary OpCodes.OpCode where
arbitrary = do
op_id <- elements [ "OP_TEST_DELAY"
, "OP_INSTANCE_REPLACE_DISKS"
- , "OP_INSTANCE_FAILOVER"
, "OP_INSTANCE_MIGRATE"
]
(case op_id of
@@ -224,10 +223,9 @@ instance Arbitrary OpCodes.OpCode where
"OP_INSTANCE_REPLACE_DISKS" ->
liftM5 OpCodes.OpReplaceDisks arbitrary arbitrary
arbitrary arbitrary arbitrary
- "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
diff --git a/htools/Ganeti/OpCodes.hs b/htools/Ganeti/OpCodes.hs
index 972a2dc..375ecfb 100644
--- a/htools/Ganeti/OpCodes.hs
+++ b/htools/Ganeti/OpCodes.hs
@@ -58,16 +58,14 @@ instance JSON ReplaceDisksMode where
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)
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
@@ -87,15 +85,12 @@ loadOpCode v = do
disks <- extract "disks"
ialloc <- maybeFromObj o "iallocator"
return $ OpReplaceDisks inst node mode disks ialloc
- "OP_INSTANCE_FAILOVER" -> do
- inst <- extract "instance_name"
- consist <- extract "ignore_consistency"
- return $ OpFailoverInstance inst consist
"OP_INSTANCE_MIGRATE" -> do
inst <- extract "instance_name"
live <- extract "live"
cleanup <- extract "cleanup"
- return $ OpMigrateInstance inst live cleanup
+ allow_fallback <- extract "allow_fallback"
+ return $ OpMigrateInstance inst live cleanup allow_fallback
_ -> J.Error $ "Unknown opcode " ++ op_id
saveOpCode :: OpCode -> JSValue
@@ -119,17 +114,12 @@ saveOpCode op@(OpReplaceDisks inst node mode disks
iallocator) =
Nothing -> ol2
in makeObj ol3
-saveOpCode op@(OpFailoverInstance inst consist) =
- let ol = [ ("OP_ID", showJSON $ opID op)
- , ("instance_name", showJSON inst)
- , ("ignore_consistency", showJSON consist) ]
- in makeObj ol
-
-saveOpCode op@(OpMigrateInstance inst live cleanup) =
+saveOpCode op@(OpMigrateInstance inst live cleanup allow_fallback) =
let ol = [ ("OP_ID", showJSON $ opID op)
, ("instance_name", showJSON inst)
, ("live", showJSON live)
- , ("cleanup", showJSON cleanup) ]
+ , ("cleanup", showJSON cleanup)
+ , ("allow_fallback", showJSON allow_fallback) ]
in makeObj ol
instance JSON OpCode where
--
1.7.3.1