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 <rcritten@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Rob Crittenden 2020-10-23 12:46:14 -04:00
parent 8b6d1ab854
commit 2f8eb73f58

View File

@ -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: