Commit 8cd19bec authored by Petr Pudlak's avatar Petr Pudlak Committed by Petr Pudlak
Browse files

Update custom SSH ports config when downgrading to 2.10



If SSH ports other than 22 are configured, abort the config downgrade,
as the operation would certainly fail. Otherwise just remove
_ndparams/ssh_port_ from the configuration.
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarHrvoje Ribicic <riba@google.com>
parent 836ce0c8
......@@ -43,7 +43,8 @@ def GetMinimalConfig():
"version": constants.CONFIG_VERSION,
"cluster": {
"master_node": "node1-uuid",
"ipolicy": None
"ipolicy": None,
"ndparams": {}
},
"instances": {},
"networks": {},
......
......@@ -394,11 +394,33 @@ def UpgradeAll(config_data):
UpgradeInstanceIndices(config_data)
# DOWNGRADE ------------------------------------------------------------
def DowngradeCluster(config_data):
DowngradeNdparams(config_data["cluster"])
def DowngradeGroups(config_data):
for group in config_data["nodegroups"].values():
DowngradeNdparams(group)
def DowngradeNdparams(group_or_cluster):
ssh_port = group_or_cluster["ndparams"].pop("ssh_port", None)
if (ssh_port is not None) and (ssh_port != 22):
raise Error(("The cluster or some node group has configured SSH port %d."
" Refusing to downgrade as it will most certainly fail."
) % (ssh_port, ))
def DowngradeAll(config_data):
# Any code specific to a particular version should be labeled that way, so
# it can be removed when updating to the next version.
config_data["version"] = version.BuildVersion(DOWNGRADE_MAJOR,
DOWNGRADE_MINOR, 0)
DowngradeCluster(config_data)
DowngradeGroups(config_data)
def main():
......
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