Sandro Bonazzola has uploaded a new change for review. Change subject: packaging - starting ovirt-engine only after yum rollback ......................................................................
packaging - starting ovirt-engine only after yum rollback With the previous implementation ovirt-engine service was started before exiting the rhyum transaction context after an execption. So the newly installed version of ovirt-engine was running with the restored PKI and DB. Now the ovirt-engine service start is done only after yum rollback transaction. Change-Id: If8160293d45361534dfda6c6aa3870e72368d10b Bug-Url: https://bugzilla.redhat.com/879969 Signed-off-by: Sandro Bonazzola <sbona...@redhat.com> --- M packaging/fedora/setup/engine-upgrade.py 1 file changed, 114 insertions(+), 114 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/87/14387/1 diff --git a/packaging/fedora/setup/engine-upgrade.py b/packaging/fedora/setup/engine-upgrade.py index cfb6a2d..af3c006 100755 --- a/packaging/fedora/setup/engine-upgrade.py +++ b/packaging/fedora/setup/engine-upgrade.py @@ -1168,137 +1168,137 @@ raise Exception(MSG_ERROR_INCOMPATIBLE_UPGRADE) rhyum.clean() - - with rhyum.transaction(): - # Check for upgrade, else exit - runFunc([rhyum.begin], MSG_INFO_CHECK_UPDATE) - if rhyum.emptyTransaction: - logging.debug(MSG_INFO_NO_UPGRADE_AVAIL) - print MSG_INFO_NO_UPGRADE_AVAIL - sys.exit(0) - - packages = rhyum.getPackages() - name_packages = [p['name'] for p in packages] - - print MSG_INFO_UPGRADE_AVAIL % (len(packages)) - for p in packages: - print " * %s" % p['display_name'] - if options.check_update: - sys.exit(100) - - if RPM_SETUP in name_packages and not options.force_current_setup_rpm: - logging.debug(MSG_ERROR_NEW_SETUP_AVAIL) - print MSG_ERROR_NEW_SETUP_AVAIL - sys.exit(3) - - # Make sure we will be able to rollback - if not rhyum.rollbackAvailable(packages) and options.yum_rollback: - logging.debug(MSG_ERROR_NO_ROLLBACK_AVAIL) - print MSG_ERROR_NO_ROLLBACK_AVAIL - print MSG_ERROR_CHECK_LOG % logFile - sys.exit(2) - - # Update is related to database if: - # 1. database related package is updated - # 2. CA upgrade is going to alter parameters within database - # 3. UUID update will take place - updateRelatedToDB = False - for package in RPM_BACKEND, RPM_DBSCRIPTS: - if package in name_packages: - updateRelatedToDB = True - logging.debug("related to database package %s" % package) - updateRelatedToDB = updateRelatedToDB or ca.mayUpdateDB() - updateRelatedToDB = updateRelatedToDB or hostids - - # No rollback in this case - try: - # We ask the user before stoping ovirt-engine or take command line option - if options.unattended_upgrade or checkEngine(engineService): - # Stopping engine - runFunc(stopEngineService, MSG_INFO_STOP_ENGINE % engineService) - if updateRelatedToDB: - runFunc([[stopDbRelatedServices, etlService, notificationService]], MSG_INFO_STOP_DB) - - if not options.ignore_tasks: - # Check that there are no running tasks/compensations - try: - if zombieTasksFound(): - # Now, clean zombie tasks. We assume that the tool works. - runFunc([clearZombieTasks], output_messages.MSG_CLEAN_ASYNC) - - checkRunningTasks() - # If something went wrong, restart DB services and the engine - except: - runFunc([[startDbRelatedServices, etlService, notificationService]], MSG_INFO_START_DB) - runFunc(startEngineService, MSG_INFO_START_ENGINE % engineService) - raise - else: - # This means that user chose not to stop ovirt-engine - logging.debug("exiting gracefully") - print MSG_INFO_STOP_INSTALL_EXIT + try: + with rhyum.transaction(): + # Check for upgrade, else exit + runFunc([rhyum.begin], MSG_INFO_CHECK_UPDATE) + if rhyum.emptyTransaction: + logging.debug(MSG_INFO_NO_UPGRADE_AVAIL) + print MSG_INFO_NO_UPGRADE_AVAIL sys.exit(0) - # Preupgrade checks - runFunc(preupgradeFunc, MSG_INFO_PREUPGRADE) + packages = rhyum.getPackages() + name_packages = [p['name'] for p in packages] - # Backup DB - if updateRelatedToDB: - runFunc([db.backup], MSG_INFO_BACKUP_DB) - runFunc([[db.rename, DB_NAME_TEMP]], MSG_INFO_RENAME_DB) + print MSG_INFO_UPGRADE_AVAIL % (len(packages)) + for p in packages: + print " * %s" % p['display_name'] + if options.check_update: + sys.exit(100) - except Exception as e: - print e - raise + if RPM_SETUP in name_packages and not options.force_current_setup_rpm: + logging.debug(MSG_ERROR_NEW_SETUP_AVAIL) + print MSG_ERROR_NEW_SETUP_AVAIL + sys.exit(3) - # In case of failure, do rollback - try: - # yum update - runFunc(upgradeFunc, MSG_INFO_YUM_UPDATE) + # Make sure we will be able to rollback + if not rhyum.rollbackAvailable(packages) and options.yum_rollback: + logging.debug(MSG_ERROR_NO_ROLLBACK_AVAIL) + print MSG_ERROR_NO_ROLLBACK_AVAIL + print MSG_ERROR_CHECK_LOG % logFile + sys.exit(2) - # check if update is relevant to db update - if updateRelatedToDB: + # Update is related to database if: + # 1. database related package is updated + # 2. CA upgrade is going to alter parameters within database + # 3. UUID update will take place + updateRelatedToDB = False + for package in RPM_BACKEND, RPM_DBSCRIPTS: + if package in name_packages: + updateRelatedToDB = True + logging.debug("related to database package %s" % package) + updateRelatedToDB = updateRelatedToDB or ca.mayUpdateDB() + updateRelatedToDB = updateRelatedToDB or hostids - # Update the db and restore its name back - runFunc([db.update], MSG_INFO_DB_UPDATE) - runFunc([[db.rename, basedefs.DB_NAME]], MSG_INFO_RESTORE_DB) + # No rollback in this case + try: + # We ask the user before stoping ovirt-engine or take command line option + if options.unattended_upgrade or checkEngine(engineService): + # Stopping engine + runFunc(stopEngineService, MSG_INFO_STOP_ENGINE % engineService) + if updateRelatedToDB: + runFunc([[stopDbRelatedServices, etlService, notificationService]], MSG_INFO_STOP_DB) - # Bring up any services we shut down before db upgrade - startDbRelatedServices(etlService, notificationService) + if not options.ignore_tasks: + # Check that there are no running tasks/compensations + try: + if zombieTasksFound(): + # Now, clean zombie tasks. We assume that the tool works. + runFunc([clearZombieTasks], output_messages.MSG_CLEAN_ASYNC) - # CA restore - runFunc([ca.prepare], MSG_INFO_PKI_PREPARE) + checkRunningTasks() + # If something went wrong, restart DB services and the engine + except: + runFunc([[startDbRelatedServices, etlService, notificationService]], MSG_INFO_START_DB) + runFunc(startEngineService, MSG_INFO_START_ENGINE % engineService) + raise + else: + # This means that user chose not to stop ovirt-engine + logging.debug("exiting gracefully") + print MSG_INFO_STOP_INSTALL_EXIT + sys.exit(0) - # post install conf - runFunc(postFunc, MSG_INFO_RUN_POST) + # Preupgrade checks + runFunc(preupgradeFunc, MSG_INFO_PREUPGRADE) - except: - logging.error(traceback.format_exc()) - logging.error("Rolling back update") + # Backup DB + if updateRelatedToDB: + runFunc([db.backup], MSG_INFO_BACKUP_DB) + runFunc([[db.rename, DB_NAME_TEMP]], MSG_INFO_RENAME_DB) - print MSG_ERROR_UPGRADE - print MSG_INFO_REASON%(sys.exc_info()[1]) + except Exception as e: + print e + raise - # CA restore - runFunc([ca.rollback], MSG_INFO_PKI_ROLLBACK) + # In case of failure, do rollback + try: + # yum update + runFunc(upgradeFunc, MSG_INFO_YUM_UPDATE) - # allow db restore - if updateRelatedToDB: - try: - runFunc([db.restore], MSG_INFO_DB_RESTORE) - except: - # This Exception have already been logged, so just pass along - pass + # check if update is relevant to db update + if updateRelatedToDB: - raise + # Update the db and restore its name back + runFunc([db.update], MSG_INFO_DB_UPDATE) + runFunc([[db.rename, basedefs.DB_NAME]], MSG_INFO_RESTORE_DB) - finally: - # start engine - runFunc([startEngine], MSG_INFO_START_ENGINE % engineService) + # Bring up any services we shut down before db upgrade + startDbRelatedServices(etlService, notificationService) - # Print log location on success - addAdditionalMessages(etlService.isServiceAvailable()) - print "\n%s\n" % MSG_INFO_UPGRADE_OK - printMessages() + # CA restore + runFunc([ca.prepare], MSG_INFO_PKI_PREPARE) + + # post install conf + runFunc(postFunc, MSG_INFO_RUN_POST) + + except: + logging.error(traceback.format_exc()) + logging.error("Rolling back update") + + print MSG_ERROR_UPGRADE + print MSG_INFO_REASON%(sys.exc_info()[1]) + + # CA restore + runFunc([ca.rollback], MSG_INFO_PKI_ROLLBACK) + + # allow db restore + if updateRelatedToDB: + try: + runFunc([db.restore], MSG_INFO_DB_RESTORE) + except: + # This Exception have already been logged, so just pass along + pass + + raise + + finally: + # start engine after the rollback + runFunc([startEngine], MSG_INFO_START_ENGINE % engineService) + + # Print log location on success + addAdditionalMessages(etlService.isServiceAvailable()) + print "\n%s\n" % MSG_INFO_UPGRADE_OK + printMessages() if __name__ == '__main__': -- To view, visit http://gerrit.ovirt.org/14387 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If8160293d45361534dfda6c6aa3870e72368d10b Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Sandro Bonazzola <sbona...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches