Commit 7187a877 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

Fix upgrade and downgrade regarding disk.dev_type

The up/downgrade procedure so far did not consider the
changes in the 'dev_type' attribute of disks. This patch
adds relevant checks and updates. A related problem
was that the logical IDs of disks were adjusted depending
on the dev_type, which made the order of updates not
arbitrary anymore. To make this more robust, the upgrade
procedure also considers the old versions of dev_types
(at least for 2.9).
Signed-off-by: default avatarHelga Velroyen <>
Reviewed-by: default avatarThomas Thrainer <>
parent 66a37e7a
......@@ -58,6 +58,12 @@ DOWNGRADE_MAJOR = 2
#: Target minor version for downgrade
# map of legacy device types
# (mapping differing old LD_* constants to new DT_* constants)
DEV_TYPE_OLD_NEW = {"lvm": constants.DT_PLAIN, "drbd8": constants.DT_DRBD8}
# (mapping differing new DT_* constants to old LD_* constants)
DEV_TYPE_NEW_OLD = {v:k for k,v in DEV_TYPE_OLD_NEW.items()}
class Error(Exception):
"""Generic exception"""
......@@ -173,7 +179,26 @@ def GetExclusiveStorageValue(config_data):
return ret
def ChangeDiskDevType(disk, dev_type_map):
"""Replaces disk's dev_type attributes according to the given map.
This can be used for both, up or downgrading the disks.
if disk["dev_type"] in dev_type_map:
disk["dev_type"] = dev_type_map[disk["dev_type"]]
if "children" in disk:
for child in disk["children"]:
ChangeDiskDevType(child, dev_type_map)
def UpgradeDiskDevType(disk):
"""Upgrades the disks' device type."""
ChangeDiskDevType(disk, DEV_TYPE_OLD_NEW)
def UpgradeInstances(config_data):
"""Upgrades the instances' configuration."""
network2uuid = dict((n["name"], n["uuid"])
for n in config_data["networks"].values())
if "instances" not in config_data:
......@@ -201,6 +226,10 @@ def UpgradeInstances(config_data):
" from '%s' to '%s'",
instance, idx, current, expected)
dobj["iv_name"] = expected
if "dev_type" in dobj:
if not "spindles" in dobj:
missing_spindles = True
......@@ -288,7 +317,11 @@ def GetNewNodeIndex(nodes_by_old_key, old_key, new_key_field):
def ChangeNodeIndices(config_data, old_key_field, new_key_field):
def ChangeDiskNodeIndices(disk):
if disk["dev_type"] in constants.LDS_DRBD:
# Note: 'drbd8' is a legacy device type from pre 2.9 and needs to be
# considered when up/downgrading from/to any versions touching 2.9 on the
# way.
drbd_disk_types = set(["drbd8"]) | constants.DTS_DRBD
if disk["dev_type"] in drbd_disk_types:
for i in range(0, 2):
disk["logical_id"][i] = GetNewNodeIndex(nodes_by_old_key,
......@@ -350,6 +383,10 @@ def UpgradeAll(config_data):
def DowngradeDiskDevType(disk):
"""Downgrades the disks' device type."""
ChangeDiskDevType(disk, DEV_TYPE_NEW_OLD)
def DowngradeDisks(disks, owner):
for disk in disks:
# Remove spindles to downgrade to 2.8
......@@ -358,6 +395,8 @@ def DowngradeDisks(disks, owner):
" instance %s",
disk["spindles"], disk["iv_name"], disk["uuid"], owner)
del disk["spindles"]
if "dev_type" in disk:
def DowngradeInstances(config_data):
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