On Thu, Jan 9, 2014 at 3:36 PM, Klaus Aehlig <[email protected]> wrote:
> Upgrading can have no specific knowledge about additional > tasks besides upgrading the configuration, as upgrades need > to be able to go to any future version (within the same major > version). Downgrading, however, is version specific and always > goes to the previous minor version. Therefore, the downgrade > procedure can do arbitrary specific tasks prior to switching > to the new binaries. Add a hook for this. > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > lib/client/gnt_cluster.py | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py > index 73f098d..e1005b1 100644 > --- a/lib/client/gnt_cluster.py > +++ b/lib/client/gnt_cluster.py > @@ -1867,6 +1867,23 @@ def > _UpgradeBeforeConfigurationChange(versionstring): > return (True, rollback) > > > +def _VersionSpecificDowngrade(): > + """ > + Perform any additional downrade tasks that are version specific > + and need to be done just after the configuration downgrade. This > + function needs to be idempotent, so that it can be redone if the > + downgrade procedure gets interrupted after changing the > + configuration. > + > + Note that this function has to be rest with every version bump. > typo: reset > + > + @return: True upon success > + """ > + ToStdout("Performing version-specific downgrade tasks.") > + > + return True > + > + > def _SwitchVersionAndConfig(versionstring, downgrade): > """ > Switch to the new Ganeti version and change the configuration, > @@ -1886,6 +1903,11 @@ def _SwitchVersionAndConfig(versionstring, > downgrade): > ToStdout("Downgrading configuration") > if not _RunCommandAndReport([pathutils.CFGUPGRADE, "--downgrade", > "-f"]): > return (False, rollback) > + # Note: version specific downgrades need to be done before switching > + # binaries, so that we still have the knowledgeable binary if the > downgrade > + # process gets interrupted at this point. > + if not _VersionSpecificDowngrade(): > + return (False, rollback) > > # Configuration change is the point of no return. From then onwards, it > is > # safer to push through the up/dowgrade than to try to roll it back. > -- > 1.8.5.1 > > Rest LGTM, thanks -- -- Helga Velroyen | Software Engineer | [email protected] | Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores
