Commit 3b31c9da authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Write the intent-to-upgrade file during upgrades



To recognize that an upgrade attempt of a cluster was interrupted by a
power failure or similar, write a file into the file system documenting
that currently an upgrade is in progress.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent f2b91949
......@@ -27,7 +27,7 @@
# C0103: Invalid name gnt-cluster
from cStringIO import StringIO
import os.path
import os
import time
import OpenSSL
import itertools
......@@ -1746,6 +1746,17 @@ def _ExecuteCommands(fns):
fn()
def _WriteIntentToUpgrade(version):
"""Write file documenting the intent to upgrade the cluster.
@type version: string
@param version: the version we intent to upgrade to
"""
utils.WriteFile(pathutils.INTENT_TO_UPGRADE,
data=utils.EscapeAndJoin([version, "%d" % os.getpid()]))
# pylint: disable=R0911
def UpgradeGanetiCommand(opts, args):
"""Upgrade a cluster to a new ganeti version.
......@@ -1786,7 +1797,9 @@ def UpgradeGanetiCommand(opts, args):
if not _VerifyVersionInstalled(versionstring):
return 1
# TODO: write intent-to-upgrade file
_WriteIntentToUpgrade(versionstring)
rollback.append(
lambda: utils.RunCmd(["rm", "-f", pathutils.INTENT_TO_UPGRADE]))
ToStdout("Draining queue")
client = GetClient()
......@@ -1888,7 +1901,7 @@ def UpgradeGanetiCommand(opts, args):
if not _RunCommandAndReport(["gnt-cluster", "queue", "undrain"]):
returnvalue = 1
# TODO: write intent-to-upgrade file
_RunCommandAndReport(["rm", "-f", pathutils.INTENT_TO_UPGRADE])
ToStdout("Verifying cluster.")
if not _RunCommandAndReport(["gnt-cluster", "verify"]):
......
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