Yedidyah Bar David has uploaded a new change for review. Change subject: packaging: setup: partial cleanup - db only ......................................................................
packaging: setup: partial cleanup - db only Before this change, if during cleanup the user only asked to delete only the database, then ran setup again, setup wrongly identified the system as being legacy 3.2 and tried to upgrade, which failed. This change makes the identification of upgrade from 3.2 legacy more strict and in such a situation setup-engine will continue as a new setup. Bug-Url: https://bugzilla.redhat.com/987939 Change-Id: Id9aa1791eb7ccdbc8c679e72ed6eaa4f72ac29c6 Signed-off-by: Yedidyah Bar David <[email protected]> --- M packaging/setup/ovirt_engine_setup/constants.py M packaging/setup/plugins/ovirt-engine-setup/legacy/core.py M packaging/setup/plugins/ovirt-engine-setup/legacy/database.py 3 files changed, 73 insertions(+), 18 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/03/20203/1 diff --git a/packaging/setup/ovirt_engine_setup/constants.py b/packaging/setup/ovirt_engine_setup/constants.py index 8726775..9a04d5f 100644 --- a/packaging/setup/ovirt_engine_setup/constants.py +++ b/packaging/setup/ovirt_engine_setup/constants.py @@ -567,6 +567,7 @@ AIO_CONFIG_VDSM = 'osetup.aio.config.vdsm' UPGRADE_FROM_LEGACY_CONFIG = 'osetup.legacy.upgrade' + LEGACY_CORE_INIT = 'osetup.legacy.core.init' REMOVE_CUSTOMIZATION_COMMON = 'osetup.remove.customization.common' REMOVE_CUSTOMIZATION_GROUPS = 'osetup.remove.customization.groups' @@ -662,6 +663,8 @@ ORIGINAL_GENERATED_BY_VERSION = 'OVESETUP_CORE/originalGeneratedByVersion' + LEGACY_PG_CREDS_FOUND = 'OVESETUP_CORE/legacyPGCredsFound' + @util.export @util.codegen diff --git a/packaging/setup/plugins/ovirt-engine-setup/legacy/core.py b/packaging/setup/plugins/ovirt-engine-setup/legacy/core.py index 03ee3ff..0d6878b 100644 --- a/packaging/setup/plugins/ovirt-engine-setup/legacy/core.py +++ b/packaging/setup/plugins/ovirt-engine-setup/legacy/core.py @@ -39,19 +39,45 @@ super(Plugin, self).__init__(context=context) @plugin.event( + name=osetupcons.Stages.LEGACY_CORE_INIT, stage=plugin.Stages.STAGE_INIT, ) def _init(self): if self.environment[osetupcons.CoreEnv.DEVELOPER_MODE]: self.environment[osetupcons.CoreEnv.UPGRADE_FROM_LEGACY] = False else: + versionLocked = False + if os.path.exists( + osetupcons.FileLocations.OVIRT_ENGINE_YUM_VERSIONLOCK + ): + with open( + osetupcons.FileLocations.OVIRT_ENGINE_YUM_VERSIONLOCK, + 'r' + ) as f: + versionLocked = ( + '%s-backend' % osetupcons.Const.PACKAGE_NAME + ) in f.read() + self.logger.debug('versionLocked=%s', versionLocked) + self.environment[osetupcons.CoreEnv.UPGRADE_FROM_LEGACY] = ( + # This one should exist only after a 3.3+ setup + not os.path.exists( + osetupcons.FileLocations.OVIRT_SETUP_POST_INSTALL_CONFIG + ) and + # This one should exist after any setup. It even exists + # after a partial cleanup. Perhaps it's best to not check + # it at all... os.path.exists( osetupcons.FileLocations.OVIRT_ENGINE_PKI_ENGINE_CA_CERT ) and - not os.path.exists( - osetupcons.FileLocations.OVIRT_SETUP_POST_INSTALL_CONFIG - ) + # The following ones should exist only after a 3.2 legacy setup + os.path.exists( + osetupcons.FileLocations.LEGACY_OVIRT_ENGINE_SYSCONFIG + ) and + self.environment[ + osetupcons.CoreEnv.LEGACY_PG_CREDS_FOUND + ] and + versionLocked ) diff --git a/packaging/setup/plugins/ovirt-engine-setup/legacy/database.py b/packaging/setup/plugins/ovirt-engine-setup/legacy/database.py index 97ddb57..6cc809d 100644 --- a/packaging/setup/plugins/ovirt-engine-setup/legacy/database.py +++ b/packaging/setup/plugins/ovirt-engine-setup/legacy/database.py @@ -25,6 +25,7 @@ from otopi import constants as otopicons +from otopi import filetransaction from otopi import util from otopi import plugin @@ -41,15 +42,15 @@ super(Plugin, self).__init__(context=context) @plugin.event( - stage=plugin.Stages.STAGE_SETUP, + stage=plugin.Stages.STAGE_INIT, before=( - osetupcons.Stages.DB_CONNECTION_SETUP, + osetupcons.Stages.LEGACY_CORE_INIT, ), - condition=lambda self: self.environment[ - osetupcons.CoreEnv.UPGRADE_FROM_LEGACY - ], ) - def _setup(self): + def _init(self): + self.environment[ + osetupcons.CoreEnv.LEGACY_PG_CREDS_FOUND + ] = False if os.path.exists( osetupcons.FileLocations.LEGACY_PSQL_PASS_FILE ): @@ -76,22 +77,47 @@ osetupcons.DBEnv.USER: d[3], osetupcons.DBEnv.PASSWORD: d[4], osetupcons.DBEnv.NEW_DATABASE: False, + osetupcons.CoreEnv.LEGACY_PG_CREDS_FOUND: True, }) self.environment[ otopicons.CoreEnv.LOG_FILTER ].append( self.environment[osetupcons.DBEnv.PASSWORD] ) - dbovirtutils = database.OvirtUtils(plugin=self) - dbovirtutils.tryDatabaseConnect() - if dbovirtutils.isNewDatabase(): - raise RuntimeError( - _( - 'Unexpected empty database ' - 'during upgrade' - ) - ) break + @plugin.event( + stage=plugin.Stages.STAGE_SETUP, + before=( + osetupcons.Stages.DB_CONNECTION_SETUP, + ), + condition=lambda self: self.environment[ + osetupcons.CoreEnv.UPGRADE_FROM_LEGACY + ], + ) + def _setup(self): + dbovirtutils = database.OvirtUtils(plugin=self) + dbovirtutils.tryDatabaseConnect() + if dbovirtutils.isNewDatabase(): + raise RuntimeError( + _('Unexpected empty database during upgrade') + ) + + @plugin.event( + stage=plugin.Stages.STAGE_MISC, + condition=lambda self: self.environment[ + osetupcons.CoreEnv.UPGRADE_FROM_LEGACY + ], + ) + def _misc(self): + self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append( + filetransaction.FileTransaction( + name=( + osetupcons.FileLocations.LEGACY_PSQL_PASS_FILE + ), + content='', + ) + ) + # vim: expandtab tabstop=4 shiftwidth=4 -- To view, visit http://gerrit.ovirt.org/20203 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id9aa1791eb7ccdbc8c679e72ed6eaa4f72ac29c6 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.3 Gerrit-Owner: Yedidyah Bar David <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
