Use error for logging when tasks don't work

VIM was logging all tasks as debug.  This made it impossible to see
errors without enabling debug logging when a node fails to become
enabled-available.

TEST PLAN
PASS: Standard + storage
* No errors
* Error used instead of debug when tasks fail

Partial-Bug: 2088312
Change-Id: I32b58022c67305b138e0546409d579e2ad0b5b1d
Signed-off-by: Joshua Kraitberg <joshua.kraitberg@windriver.com>
This commit is contained in:
Joshua Kraitberg 2024-11-15 15:45:17 -05:00
parent e66a1f712e
commit cbbf25d6aa

View File

@ -14,6 +14,20 @@ from nfv_common.state_machine._state_task_work_result import STATE_TASK_WORK_RES
DLOG = debug.debug_get_logger('nfv_common.state_machine.state_task')
RESULT_LOG_LEVELS = {
STATE_TASK_RESULT.SUCCESS: DLOG.debug,
STATE_TASK_RESULT.FAILED: DLOG.error,
STATE_TASK_RESULT.TIMED_OUT: DLOG.error,
STATE_TASK_RESULT.ABORTED: DLOG.notice,
STATE_TASK_RESULT.DEGRADED: DLOG.warn,
}
def result_log(result, message):
logger = RESULT_LOG_LEVELS.get(result, DLOG.debug)
logger(message)
class StateTask(object):
"""
State Task
@ -226,7 +240,8 @@ class StateTask(object):
State Task Work Complete
"""
task_work = self._task_work_list[self._current_task_work]
DLOG.debug("Task (%s) work (%s) complete, result=%s, reason=%s."
result_log(task_work_result,
"Task (%s) work (%s) complete, result=%s, reason=%s."
% (self._name, task_work.name, task_work_result,
task_work_result_reason))
@ -234,7 +249,8 @@ class StateTask(object):
task_work.complete(task_work_result, task_work_result_reason)
if task_work_result != updated_task_work_result:
DLOG.debug("Task (%s) work (%s) complete, result updated, "
result_log(updated_task_work_result,
"Task (%s) work (%s) complete, result updated, "
"was_result=%s, now_result=%s."
% (self._name, task_work.name, task_work_result,
updated_task_work_result))