Currently, if a call to update dcagent cache fails, the previous
successful response will still be cached, so when dcmanager/dcorch
attempts to audit, an out-of-date response will be used. This commit
fixes this problem by clearing the cache for the function if the
call returns an error.
Test plan:
- PASS: Manually force an error in software api. Verify the cache
from dcagent is cleared and the next audit fails.
- PASS: Manage a healthy subcloud and verify the audit is working
as expected.
Closes-bug: 2085832
Change-Id: Ib97f58e8d20e6805b08e930b6e4200aae5451719
Signed-off-by: Victor Romano <victor.gluzromano@windriver.com>
51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
#
|
|
# Copyright (c) 2024 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
"""
|
|
Dcagent base exception handling.
|
|
"""
|
|
|
|
from oslo_utils import excutils
|
|
|
|
from dcdbsync.common.i18n import _
|
|
|
|
|
|
class DcagentException(Exception):
|
|
"""Base dcagent Exception.
|
|
|
|
To correctly use this class, inherit from it and define
|
|
a 'message' property. That message will get printf'd
|
|
with the keyword arguments provided to the constructor.
|
|
"""
|
|
|
|
message = _("An unknown exception occurred.")
|
|
|
|
def __init__(self, **kwargs):
|
|
try:
|
|
super(DcagentException, self).__init__(self.message % kwargs)
|
|
self.msg = self.message % kwargs
|
|
except Exception:
|
|
with excutils.save_and_reraise_exception() as ctxt:
|
|
if not self.use_fatal_exceptions():
|
|
ctxt.reraise = False
|
|
# at least get the core message out if something happened
|
|
super(DcagentException, self).__init__(self.message)
|
|
|
|
def use_fatal_exceptions(self):
|
|
return False
|
|
|
|
|
|
class UnsupportedAudit(DcagentException):
|
|
message = _("Requested audit %(audit)s is not supported.")
|
|
|
|
|
|
class MissingRegionOneData(DcagentException):
|
|
message = _("Audit request does not have RegionOne data for %(audit)s.")
|
|
|
|
|
|
class AuditStatusFailure(DcagentException):
|
|
message = _("Failure getting %(audit)s sync status.")
|