Enzo Candotti 2f39882bad Enhance logging for dcaudit and dcorch
To improve the logged information during dcmanager audit and avoid
unnecessary logging in dcorch and audit, this commit adjusts log
levels between DEBUG and INFO.
Additionally, a specific rule is added for state.log in logrotate to
retain larger files compared to the rest of the dcmanager logs.

It was also seen that at the end of the dcorch audit process, the
sync_request was being updated to 'requested' for the subcloud and
endpoint being audited. This commit enhances this logic by updating
this state just for the cases in which there are sync jobs to be run.

Test Plan:
PASS: Verify that during dcorch audit, if there are no sync jobs to be
      run, the sync_request field is not updated.
PASS: Verify that during dcorch audit, if there are sync jobs, the
      sync_request field is updated to 'requested'. Also verify that
      in the next sync round, that subcloud/enpdoint is synched.
PASS: Verify that state.log rotates when it reaches the configured
      size of 40MB.
PASS: Verif that other dcmanager logs follow the previous rotation
      policy.

Story: 2011106
Task: 51424

Change-Id: Icfa3eb9bd692e1e22f8940c904e7ef373260589d
Signed-off-by: Enzo Candotti <enzo.candotti@windriver.com>
2024-11-29 21:46:09 +00:00

72 lines
2.6 KiB
Python

# Copyright 2017 Ericsson AB.
# Copyright (c) 2017-2024 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# TODO(nicodemos): Remove this file after all support to patching is removed
from oslo_log import log as logging
from tsconfig.tsconfig import SW_VERSION
from dccommon import consts
from dcmanager.common import utils
LOG = logging.getLogger(__name__)
# NOTE(nicodemos): Keep the PatchAuditData to avoid breaking the code.
class PatchAuditData(object):
def __init__(self):
pass
class PatchAudit(object):
"""Manages tasks related to patch audits."""
def __init__(self, context):
LOG.debug("PatchAudit initialization...")
self.context = context
self.audit_count = 0
# NOTE(nicodemos): Keep the get_regionone_audit_data to avoid breaking the code.
def get_regionone_audit_data(self):
return PatchAuditData()
def subcloud_patch_audit(self, keystone_client, subcloud):
# NOTE(nicodemos): Patch audit not supported for 24.09 subcloud
if subcloud.software_version == SW_VERSION:
return consts.SYNC_STATUS_NOT_AVAILABLE
# Log this just for N-1 subclouds, before the has_usm_service external call
LOG.info("Triggered patch audit for: %s." % subcloud.name)
# NOTE(nicodemos): If the subcloud is on the 22.12 release with USM enabled,
# skip the patch audit.
if utils.has_usm_service(subcloud.region_name, keystone_client):
return consts.SYNC_STATUS_NOT_AVAILABLE
# NOTE(nicodemos): As of version 24.09, the patching orchestration only
# supports applying specific patches (e.g., USM) using the --patch option.
# We should return an out-of-sync status to prompt the user to apply the USM
# patch.
LOG.info(
"Need to apply the USM patch to enable the Software audit in "
f"subcloud: {subcloud.name}."
)
return consts.SYNC_STATUS_OUT_OF_SYNC
# NOTE(nicodemos): Load Audit is not supported anymore;
def subcloud_load_audit(self):
return consts.SYNC_STATUS_NOT_AVAILABLE