AppFwk: Load metadata before clearing stuck application

Restarting sysinv while an application is applying will result in a
wrong reset status. For example cert-manager status is reset to
'apply-failed' instead of 'uploaded'.

When sysinv is restarted, app operations that are in progress are
reset. When apps were decoupled from sysinv [1], a requirement to
have the app metadata loaded was introduced.

Tests on AIO-SX:
PASS: deploy, unlocked enabled available
PASS: forced 'cert-manager' to be 'applying', forced sysinv conductor
restart, observed status was reset to 'uploaded'.

[1]: https://review.opendev.org/c/starlingx/config/+/774292/10/sysinv/sysinv/sysinv/sysinv/conductor/kube_app.py#333
Partial-Bug: 2003198
Signed-off-by: Dan Voiculeasa <dan.voiculeasa@windriver.com>
Change-Id: Ibefc6362c7a7f03571be3cf35b6592cf0c68bca3
This commit is contained in:
Dan Voiculeasa 2023-01-11 17:29:12 +02:00
parent e7366adc41
commit 500fbaa133
2 changed files with 6 additions and 4 deletions

View File

@ -171,6 +171,11 @@ class AppOperator(object):
self._armada = ArmadaHelper(self._kube)
self._fluxcd = FluxCDHelper(self._dbapi, self._kube)
# Load apps metadata
# Clearing stuck application behavior depends on the metadata
for app in self._dbapi.kube_app_get_all():
self.load_application_metadata_from_database(app)
if not os.path.isfile(constants.ANSIBLE_BOOTSTRAP_FLAG):
self._clear_stuck_applications()

View File

@ -362,6 +362,7 @@ class ConductorManager(service.PeriodicService):
# brought up during bootstrap manifest apply and is not restarted
# until host unlock and we need ceph-mon up in order to configure
# ceph for the initial unlock.
# kube_app operator will load app metadata from database
self._helm = helm.HelmOperator(self.dbapi)
self._app = kube_app.AppOperator(self.dbapi, self._helm, self.apps_metadata)
self._docker = kube_app.DockerHelper(self.dbapi)
@ -384,10 +385,6 @@ class ConductorManager(service.PeriodicService):
# Save our start time for time limited init actions
self._start_time = timeutils.utcnow()
# Load apps metadata
for app in self.dbapi.kube_app_get_all():
self._app.load_application_metadata_from_database(app)
def _get_active_controller_uuid(self):
ahost = utils.HostHelper.get_active_controller(self.dbapi)
if ahost: