Commit f198cf91 authored by Thomas Thrainer's avatar Thomas Thrainer
Browse files

Add possibility to compress to OpInstanceMove



OpInstanceMove now supports the 'compress' option. It allows to enable
compression for intra-cluster instance moves.
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent f048c574
......@@ -1408,6 +1408,7 @@ class LUInstanceCreate(LogicalUnit):
self.op.src_node_uuid,
self.pnode.uuid,
self.pnode.secondary_ip,
constants.IEC_NONE,
iobj, transfers)
if not compat.all(import_result):
self.LogWarning("Some disks for instance %s on node %s were not"
......@@ -1838,6 +1839,7 @@ class LUInstanceMove(LogicalUnit):
source_node.uuid,
target_node.uuid,
target_node.secondary_ip,
self.op.compress,
self.instance, transfers)
if not compat.all(import_result):
errs.append("Failed to transfer instance data")
......
......@@ -540,6 +540,7 @@ TDiskTemplate = TElemOf(constants.DISK_TEMPLATES)
TEvacMode = TElemOf(constants.NODE_EVAC_MODES)
TIAllocatorTestDir = TElemOf(constants.VALID_IALLOCATOR_DIRECTIONS)
TIAllocatorMode = TElemOf(constants.VALID_IALLOCATOR_MODES)
TImportExportCompression = TElemOf(constants.IEC_ALL)
def TSetParamsMods(fn):
......
......@@ -1007,7 +1007,7 @@ def _GetInstDiskMagic(base, instance_name, index):
def TransferInstanceData(lu, feedback_fn, src_node_uuid, dest_node_uuid,
dest_ip, instance, all_transfers):
dest_ip, compress, instance, all_transfers):
"""Transfers an instance's data from one node to another.
@param lu: Logical unit instance
......@@ -1018,6 +1018,8 @@ def TransferInstanceData(lu, feedback_fn, src_node_uuid, dest_node_uuid,
@param dest_node_uuid: Destination node UUID
@type dest_ip: string
@param dest_ip: IP address of destination node
@type compress: string
@param compress: one of L{constants.IEC_ALL}
@type instance: L{objects.Instance}
@param instance: Instance object
@type all_transfers: list of L{DiskTransfer} instances
......@@ -1027,9 +1029,6 @@ def TransferInstanceData(lu, feedback_fn, src_node_uuid, dest_node_uuid,
each transfer
"""
# Disable compression for all moves as these are all within the same cluster
compress = constants.IEC_NONE
src_node_name = lu.cfg.GetNodeName(src_node_uuid)
dest_node_name = lu.cfg.GetNodeName(dest_node_uuid)
......@@ -1254,6 +1253,7 @@ class ExportInstanceHelper:
dresults = TransferInstanceData(self._lu, self._feedback_fn,
src_node_uuid, dest_node.uuid,
dest_node.secondary_ip,
constants.IEC_NONE,
instance, transfers)
assert len(dresults) == len(instance.disks)
......
......@@ -544,13 +544,14 @@ iemImport = "import"
-- * Import/export transport compression
iecGzip :: String
iecGzip = "gzip"
iecGzip = Types.importExportCompressionToRaw GZip
iecNone :: String
iecNone = "none"
iecNone = Types.importExportCompressionToRaw None
iecAll :: [String]
iecAll = [iecGzip, iecNone]
iecAll :: FrozenSet String
iecAll =
ConstantUtils.mkSet $ map Types.importExportCompressionToRaw [minBound..]
ieCustomSize :: String
ieCustomSize = "fd"
......
......@@ -576,6 +576,7 @@ $(genOpCode "OpCode"
, pIgnoreIpolicy
, pMoveTargetNode
, pMoveTargetNodeUuid
, pMoveCompress
, pIgnoreConsistency
],
"instance_name")
......
......@@ -83,6 +83,7 @@ module Ganeti.OpParams
, pMigrationTargetNodeUuid
, pMoveTargetNode
, pMoveTargetNodeUuid
, pMoveCompress
, pStartupPaused
, pVerbose
, pDebugSimulateErrors
......@@ -1241,6 +1242,12 @@ pMoveTargetNodeUuid =
renameField "MoveTargetNodeUuid" . optionalField $
simpleField "target_node_uuid" [t| NonEmptyString |]
pMoveCompress :: Field
pMoveCompress =
withDoc "Compression mode to use during instance moves" .
defaultField [| None |] $
simpleField "compress" [t| ImportExportCompression |]
pIgnoreDiskSize :: Field
pIgnoreDiskSize =
withDoc "Whether to ignore recorded disk size" $
......
......@@ -152,6 +152,8 @@ module Ganeti.Types
, RpcTimeout(..)
, rpcTimeoutFromRaw -- FIXME: no used anywhere
, rpcTimeoutToRaw
, ImportExportCompression(..)
, importExportCompressionToRaw
) where
import Control.Monad (liftM)
......@@ -834,3 +836,14 @@ $(THH.declareILADT "RpcTimeout"
, ("FourHours", 4 * 3600) -- 4 hours
, ("OneDay", 86400) -- 1 day
])
$(THH.declareLADT ''String "ImportExportCompression"
[ -- No compression
("None", "none")
-- gzip compression
, ("GZip", "gzip")
])
$(THH.makeJSONInstance ''ImportExportCompression)
instance THH.PyValue ImportExportCompression where
showValue = THH.showValue . importExportCompressionToRaw
......@@ -80,6 +80,8 @@ $(genArbitrary ''OpCodes.ReplaceDisksMode)
$(genArbitrary ''DiskAccess)
$(genArbitrary ''ImportExportCompression)
instance Arbitrary OpCodes.DiskIndex where
arbitrary = choose (0, C.maxDisks - 1) >>= OpCodes.mkDiskIndex
......@@ -265,7 +267,7 @@ instance Arbitrary OpCodes.OpCode where
"OP_INSTANCE_MOVE" ->
OpCodes.OpInstanceMove <$> genFQDN <*> return Nothing <*>
arbitrary <*> arbitrary <*> genNodeNameNE <*> return Nothing <*>
arbitrary
arbitrary <*> arbitrary
"OP_INSTANCE_CONSOLE" -> OpCodes.OpInstanceConsole <$> genFQDN <*>
return Nothing
"OP_INSTANCE_ACTIVATE_DISKS" ->
......
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