Better message on SubcloudBackupOperationFailed

The message when a Subcloud Backup Operation fails was not clear
on how to check for errors, so a better message showing how to check
the errors was added. Also, the error when a 'subcloud-backup delete'
fails is now being displayed when using 'dcmanager subcloud error'

Partial-Bug: 2000320

Signed-off-by: Guilherme Costa <guilherme.costa@windriver.com>
Change-Id: I62e3b5ff2b7328a68567b007351a22f7ccdf6286
This commit is contained in:
Guilherme Costa 2023-02-14 22:03:41 -03:00
parent daf709e24e
commit f141f03859
4 changed files with 29 additions and 16 deletions

View File

@ -154,7 +154,8 @@ class SubcloudGroupDefaultNotDeletable(DCManagerException):
class SubcloudBackupOperationFailed(DCManagerException):
message = _("Failed to run subcloud-backup %(operation)s, check dcmanager logs")
message = _("Failed to run subcloud-backup %(operation)s. Please run "
"'dcmanager subcloud error' command for details")
class ConnectionRefused(DCManagerException):

View File

@ -726,7 +726,8 @@ class SubcloudManager(manager.Manager):
failed_subclouds)
if invalid_subclouds or failed_subclouds:
return self._build_subcloud_operation_notice(failed_subclouds,
return self._build_subcloud_operation_notice(operation,
failed_subclouds,
invalid_subclouds)
return
@ -933,17 +934,19 @@ class SubcloudManager(manager.Manager):
return subcloud, success
@staticmethod
def _build_subcloud_operation_notice(failed_subclouds, invalid_subclouds):
def _build_subcloud_operation_notice(operation, failed_subclouds, invalid_subclouds):
invalid_subcloud_names = [subcloud.name for subcloud in invalid_subclouds]
failed_subcloud_names = [subcloud.name for subcloud in failed_subclouds]
notice = "Subcloud backup operation completed with warnings:\n"
notice = "Subcloud backup %s operation completed with warnings:\n" % operation
if invalid_subclouds:
notice += ("The following subclouds were skipped for local backup "
"operation: %s." % ' ,'.join(invalid_subcloud_names))
"%s operation: %s."
% (operation, ' ,'.join(invalid_subcloud_names)))
if failed_subclouds:
notice += ("The following subclouds failed during backup "
"operation: %s." % ' ,'.join(failed_subcloud_names))
"%s operation: %s."
% (operation, ' ,'.join(failed_subcloud_names)))
return notice
def _create_subcloud_inventory_file(self, subcloud, data_install=None):
@ -1089,6 +1092,15 @@ class SubcloudManager(manager.Manager):
except PlaybookExecutionFailed:
LOG.error("Failed to delete backup for subcloud %s, check individual "
"log at %s for detailed output." % (subcloud.name, log_file))
msg = utils.find_ansible_error_msg(
subcloud.name, log_file, consts.BACKUP_STATE_FAILED)
LOG.error(msg)
db_api.subcloud_update(
context, subcloud.id,
error_description=msg[0:consts.ERROR_DESCRIPTION_LENGTH])
return False
def _run_subcloud_backup_restore_playbook(

View File

@ -47,7 +47,7 @@ setenv =
deps = -r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
whitelist_externals =
allowlist_externals =
rm
find
reno
@ -146,7 +146,7 @@ deps = -r{toxinidir}/doc/requirements.txt
commands =
rm -rf doc/build
sphinx-build -a -E -W -d doc/build/doctrees -b html doc/source doc/build/html
whitelist_externals = rm
allowlist_externals = rm
[testenv:releasenotes]
basepython = python3
@ -155,7 +155,7 @@ deps = -r{toxinidir}/doc/requirements.txt
commands =
rm -rf releasenotes/build
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
whitelist_externals = rm
allowlist_externals = rm
[testenv:newnote]
basepython = python3
@ -171,7 +171,7 @@ deps = -r{toxinidir}/doc/requirements.txt
commands =
rm -rf api-ref/build
sphinx-build -W -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html
whitelist_externals = rm
allowlist_externals = rm
[testenv:debug]
basepython = python3
@ -236,7 +236,7 @@ basepython = python3
# bashate ignore:
# E006 - accept long lines
# E040 - false positive on |& syntax (new in bash 4)
whitelist_externals = bash
allowlist_externals = bash
commands =
bash -c "find {toxinidir} \
\( -name .tox -prune \) \

10
tox.ini
View File

@ -19,7 +19,7 @@ deps = -r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
keyring
whitelist_externals =
allowlist_externals =
rm
find
reno
@ -42,7 +42,7 @@ description = Dummy environment to allow pylint to be run in subdir tox
[testenv:linters]
basepython = python3
whitelist_externals = bash
allowlist_externals = bash
commands =
bash -c "find {toxinidir} \
\( -name .tox -prune \) \
@ -55,7 +55,7 @@ deps = -r{toxinidir}/doc/requirements.txt
commands =
rm -rf doc/build
sphinx-build -a -E -W -d doc/build/doctrees -b html doc/source doc/build/html
whitelist_externals = rm
allowlist_externals = rm
[testenv:releasenotes]
basepython = python3
@ -63,7 +63,7 @@ deps = -r{toxinidir}/doc/requirements.txt
commands =
rm -rf releasenotes/build
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
whitelist_externals =
allowlist_externals =
rm
reno
@ -81,7 +81,7 @@ deps =
commands =
rm -rf api-ref/build
sphinx-build -W -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html
whitelist_externals = rm
allowlist_externals = rm
[testenv:bandit]
basepython = python3