Block restore-complete while apps are restore-requested

The apps in restore-requested state can only be transitioned out
of during restore in progress.  However, restore completed
can still be sent while apps are in this state.

This adds a check to ensure restore can not be completed while
apps are in this state and also during applying, which can
transition back on error.

TEST PLAN
PASS: AIO-SX legacy restore
PASS: AIO-SX optimized restore

TEST PLAN
PASS: AIO-SX restore
PASS: AIO-SX optimized restore

Closes-Bug: 2017899
Signed-off-by: Joshua Kraitberg <joshua.kraitberg@windriver.com>
Change-Id: I1e49262516cad3e48871c0ba778cbf3c8c8bc91a
This commit is contained in:
Joshua Kraitberg 2023-04-26 19:12:28 -04:00
parent ceb5852fce
commit 6f5766c386
1 changed files with 11 additions and 0 deletions

View File

@ -15523,6 +15523,17 @@ class ConductorManager(service.PeriodicService):
LOG.error(e)
return message
# Do not allow restore to complete if some apps are still in restore-requested state
waiting_apps = [
v.name for v in self.dbapi.kube_app_get_all()
if v.status in [constants.APP_APPLY_IN_PROGRESS, constants.APP_RESTORE_REQUESTED]]
if waiting_apps:
message = "Some apps are still restoring, " \
"try restore-complete later: {}".format(waiting_apps)
LOG.info(message)
return message
try:
restore = self.dbapi.restore_get_one(
filters={'state': constants.RESTORE_STATE_IN_PROGRESS})