LGTM, thanks.

On Fri, Jan 10, 2014 at 12:29 PM, Klaus Aehlig <[email protected]> wrote:

> To allow for necessary last-moment adaptions, of the new cluster,
> we run the post-upgrade hook of the target version, providing
> the version we originally started from.
>
> Signed-off-by: Klaus Aehlig <[email protected]>
> ---
>  lib/client/gnt_cluster.py | 26 +++++++++++++++++---------
>  1 file changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py
> index 05f3eeb..0ea78ef 100644
> --- a/lib/client/gnt_cluster.py
> +++ b/lib/client/gnt_cluster.py
> @@ -1776,20 +1776,20 @@ def _GetConfigVersion():
>  def _ReadIntentToUpgrade():
>    """Read the file documenting the intent to upgrade the cluster.
>
> -  @rtype: string or None
> -  @return: the version to upgrade to, if the file exists, and None
> -      otherwise.
> +  @rtype: (string, string) or (None, None)
> +  @return: (old version, version to upgrade to), if the file exists,
> +      and (None, None) otherwise.
>
>    """
>    if not os.path.isfile(pathutils.INTENT_TO_UPGRADE):
> -    return None
> +    return (None, None)
>
>    contentstring = utils.ReadFile(pathutils.INTENT_TO_UPGRADE)
>    contents = utils.UnescapeAndSplit(contentstring)
>    if len(contents) != 3:
>      # file syntactically mal-formed
> -    return None
> -  return contents[1]
> +    return (None, None)
> +  return (contents[0], contents[1])
>
>
>  def _WriteIntentToUpgrade(version):
> @@ -1906,7 +1906,7 @@ def _SwitchVersionAndConfig(versionstring,
> downgrade):
>    return (True, rollback)
>
>
> -def _UpgradeAfterConfigurationChange():
> +def _UpgradeAfterConfigurationChange(oldversion):
>    """
>    Carry out the upgrade actions necessary after switching to the new
>    Ganeti version and updating the configuration.
> @@ -1916,6 +1916,8 @@ def _UpgradeAfterConfigurationChange():
>    interface. Also, as the configuration change is the point of no return,
>    all actions are pushed trough, even if some of them fail.
>
> +  @param oldversion: the version the upgrade started from
> +  @type oldversion: string
>    @rtype: int
>    @return: the intended return value
>
> @@ -1953,6 +1955,10 @@ def _UpgradeAfterConfigurationChange():
>
>    _RunCommandAndReport(["rm", "-f", pathutils.INTENT_TO_UPGRADE])
>
> +  ToStdout("Running post-upgrade hooks")
> +  if not _RunCommandAndReport([pathutils.POST_UPGRADE, oldversion]):
> +    returnvalue = 1
> +
>    ToStdout("Verifying cluster.")
>    if not _RunCommandAndReport(["gnt-cluster", "verify"]):
>      returnvalue = 1
> @@ -1976,9 +1982,11 @@ def UpgradeGanetiCommand(opts, args):
>               " has to be given")
>      return 1
>
> +  oldversion = constants.RELEASE_VERSION
> +
>    if opts.resume:
>      ssconf.CheckMaster(False)
> -    versionstring = _ReadIntentToUpgrade()
> +    oldversion, versionstring = _ReadIntentToUpgrade()
>      if versionstring is None:
>        return 0
>      version = utils.version.ParseVersion(versionstring)
> @@ -2033,7 +2041,7 @@ def UpgradeGanetiCommand(opts, args):
>      _ExecuteCommands(rollback)
>      return 1
>
> -  return _UpgradeAfterConfigurationChange()
> +  return _UpgradeAfterConfigurationChange(oldversion)
>
>
>  commands = {
> --
> 1.8.5.1
>
>

Reply via email to