From 2f8eb73f588c96b391be57020ecf0b247c646d19 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Fri, 23 Oct 2020 12:46:14 -0400 Subject: [PATCH] Use a state to determine if a 389-ds upgrade is in progress When applying update files to 389 the listeners are disabled. There is a large try/except around this so that if a failure happens then the configuration should be automatically restored. We've seen multiple cases where this doesn't occur. Best guess is that users are killing or ^C breaking out of the script. What happens in that case is that when the next upgrade is run the configuration is backed up again overwriting the original values. This leaves dirsrv with no listener on 389. Add a new state, upgrade-in-progress, so that the backup of the config information can be skipped when the upgrader is executed again after a failure. The idea behind using a new state value is that if additional attributes are ever backed up we don't need to remember to update the list of possible saved values to check to decide if the upgrade is in progress. https://pagure.io/freeipa/issue/7534 Signed-off-by: Rob Crittenden Reviewed-By: Alexander Bokovoy --- ipaserver/install/upgradeinstance.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ipaserver/install/upgradeinstance.py b/ipaserver/install/upgradeinstance.py index f2455ff85..855d7f236 100644 --- a/ipaserver/install/upgradeinstance.py +++ b/ipaserver/install/upgradeinstance.py @@ -134,6 +134,11 @@ class IPAUpgrade(service.Service): def __save_config(self): shutil.copy2(self.filename, self.savefilename) + if self.get_state('upgrade-in-progress') is not None: + logger.debug('Previous upgrade in process, not saving config') + return + else: + self.backup_state('upgrade-in-progress', True) with open(self.filename, "r") as in_file: parser = GetEntryFromLDIF(in_file, entries_dn=["cn=config"]) parser.parse() @@ -198,6 +203,7 @@ class IPAUpgrade(service.Service): security = self.restore_state('nsslapd-security') global_lock = self.restore_state('nsslapd-global-backend-lock') schema_compat_enabled = self.restore_state('schema_compat_enabled') + self.restore_state('upgrade-in-progress') ldif_outfile = "%s.modified.out" % self.filename with open(ldif_outfile, "w") as out_file: