Merge "Revert "Make configure_logging more robust.""

This commit is contained in:
Zuul
2025-08-20 14:07:48 +00:00
committed by Gerrit Code Review
37 changed files with 42 additions and 42 deletions

View File

@@ -119,7 +119,7 @@ class PostgresDatabase:
if __name__ == "__main__":
upgrade_utils.configure_logging("/var/log/software.log", LOG, log_level=logging.INFO)
upgrade_utils.configure_logging("/var/log/software.log", log_level=logging.INFO)
port = None
error = False

View File

@@ -515,5 +515,5 @@ def main(argv=None):
if __name__ == "__main__":
upgrade_utils.configure_logging("/var/log/software.log", LOG, log_level=logging.INFO)
upgrade_utils.configure_logging("/var/log/software.log", log_level=logging.INFO)
sys.exit(main())

View File

@@ -202,7 +202,7 @@ class DeployStart:
if __name__ == "__main__":
upgrade_utils.configure_logging("/var/log/software.log", LOG, log_level=logging.INFO)
upgrade_utils.configure_logging("/var/log/software.log", log_level=logging.INFO)
from_version = None
to_version = None

View File

@@ -388,5 +388,5 @@ def main():
if __name__ == "__main__":
upgrade_utils.configure_logging('/var/log/software.log', LOG, log_level=logging.INFO)
upgrade_utils.configure_logging('/var/log/software.log', log_level=logging.INFO)
sys.exit(main())

View File

@@ -110,7 +110,7 @@ class ChrootMounts:
if __name__ == "__main__":
upgrade_utils.configure_logging("/var/log/software.log", LOG, log_level=logging.INFO)
upgrade_utils.configure_logging("/var/log/software.log", log_level=logging.INFO)
checkout_dir = None
operation = None

View File

@@ -340,5 +340,5 @@ def main(sys_argv):
if __name__ == "__main__":
upgrade_utils.configure_logging("/var/log/software.log", LOG, log_level=logging.INFO)
upgrade_utils.configure_logging("/var/log/software.log", log_level=logging.INFO)
sys.exit(main(sys.argv))

View File

@@ -111,7 +111,7 @@ class RemoveTemporaryData:
if __name__ == "__main__":
upgrade_utils.configure_logging("/var/log/software.log", LOG, log_level=logging.INFO)
upgrade_utils.configure_logging("/var/log/software.log", log_level=logging.INFO)
checkout_dir = None
for arg in range(1, len(sys.argv)):

View File

@@ -98,5 +98,5 @@ def main(sys_argv):
return 1
if __name__ == "__main__":
upgrade_utils.configure_logging('/var/log/software.log', LOG, log_level=logging.INFO)
upgrade_utils.configure_logging('/var/log/software.log', log_level=logging.INFO)
sys.exit(main(sys.argv))

View File

@@ -178,7 +178,7 @@ def get_system_info(sysinv_client):
return system_info.system_type, system_info.system_mode
def configure_logging(filename, logger, log_level=logging.INFO):
def configure_logging(filename, log_level=logging.INFO):
read_log_config()
my_exec = os.path.basename(sys.argv[0])
@@ -187,10 +187,10 @@ def configure_logging(filename, logger, log_level=logging.INFO):
log_format = log_format.replace('%(exec)s', my_exec)
formatter = logging.Formatter(log_format, datefmt="%FT%T")
logger.setLevel(log_level)
LOG.setLevel(log_level)
main_log_handler = logging.FileHandler(filename)
main_log_handler.setFormatter(formatter)
logger.addHandler(main_log_handler)
LOG.addHandler(main_log_handler)
def get_platform_conf(key):

View File

@@ -503,5 +503,5 @@ def main():
if __name__ == "__main__":
import upgrade_utils # pylint: disable=E0401
upgrade_utils.configure_logging('/var/log/software.log', LOG, log_level=logging.INFO)
upgrade_utils.configure_logging('/var/log/software.log', log_level=logging.INFO)
sys.exit(main())

View File

@@ -5,7 +5,7 @@
#
import argparse
import logging as log
from oslo_log import log
from software.states import DEPLOY_STATES
from software.utilities.update_deploy_state import update_deploy_state
@@ -50,7 +50,7 @@ def do_activate(from_release, to_release, is_major_release):
def activate():
# this is the entry point to start activate
configure_logging(LOG)
configure_logging()
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument("from_release",

View File

@@ -40,7 +40,7 @@ def do_activate_rollback(from_release, to_release):
def activate_rollback():
# this is the entry point to start activate-rollback
configure_logging(LOG)
configure_logging()
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument("from_release",

View File

@@ -44,7 +44,7 @@ def do_deploy_delete(from_release, to_release, plugin_path, is_major_release):
def deploy_delete():
# this is the entry point to deploy delete plugin
utils.configure_logging(LOG)
utils.configure_logging()
parser = argparse.ArgumentParser(add_help=False)
plugin_path = os.environ.get('plugin_path')

View File

@@ -843,7 +843,7 @@ def upgrade_controller(from_release, to_release, target_port):
def migrate():
# this is the entry point to start data migration
configure_logging(LOG)
configure_logging()
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument("from_release",

View File

@@ -42,7 +42,7 @@ ACTION_ACTIVATE_ROLLBACK = "activate-rollback"
ACTION_DELETE = "delete"
def configure_logging(logger):
def configure_logging():
cfg.read_config()
my_exec = os.path.basename(sys.argv[0])
@@ -51,10 +51,10 @@ def configure_logging(logger):
log_format = log_format.replace('%(exec)s', my_exec)
formatter = logging.Formatter(log_format, datefmt="%FT%T")
logger.setLevel(logging.INFO)
LOG.setLevel(logging.INFO)
main_log_handler = logging.FileHandler(SOFTWARE_LOG_FILE)
main_log_handler.setFormatter(formatter)
logger.addHandler(main_log_handler)
LOG.addHandler(main_log_handler)
def get_migration_scripts(migration_script_dir):

View File

@@ -47,7 +47,7 @@ def main():
print("Invalid option %s." % sys.argv[arg])
return 1
arg += 1
configure_logging(LOG)
configure_logging()
LOG.info(
"%s invoked from_release = %s to_release = %s action = %s"
% (sys.argv[0], from_release, to_release, action)

View File

@@ -47,7 +47,7 @@ def main():
print("Invalid option %s." % sys.argv[arg])
return 1
arg += 1
configure_logging(LOG)
configure_logging()
LOG.info(
"%s invoked from_release = %s to_release = %s action = %s"
% (sys.argv[0], from_release, to_release, action)

View File

@@ -40,7 +40,7 @@ def main():
print("Invalid option %s." % sys.argv[arg])
return 1
arg += 1
configure_logging(LOG)
configure_logging()
LOG.info(
"%s invoked from_release = %s to_release = %s action = %s"
% (sys.argv[0], from_release, to_release, action)

View File

@@ -40,7 +40,7 @@ def main():
print("Invalid option %s." % sys.argv[arg])
return 1
arg += 1
configure_logging(LOG)
configure_logging()
LOG.info(
"%s invoked from_release = %s to_release = %s action = %s"
% (sys.argv[0], from_release, to_release, action)

View File

@@ -58,7 +58,7 @@ def main():
return 1
arg += 1
configure_logging(LOG)
configure_logging()
LOG.info("%s invoked from_release = %s to_release = %s action = %s"
% (sys.argv[0], from_release, to_release, action))
res = 0

View File

@@ -47,7 +47,7 @@ def main():
print("Invalid option %s." % sys.argv[arg])
return 1
arg += 1
configure_logging(LOG)
configure_logging()
LOG.info(
"%s invoked from_release = %s to_release = %s action = %s"
% (sys.argv[0], from_release, to_release, action)

View File

@@ -75,7 +75,7 @@ def main():
return ERROR
arg += 1
configure_logging(LOG)
configure_logging()
LOG.info(
"%s invoked from_release = %s invoked to_release = %s action = %s"
% (sys.argv[0], from_release, to_release, action)

View File

@@ -44,7 +44,7 @@ def main():
return 1
arg += 1
configure_logging(LOG)
configure_logging()
LOG.info("%s invoked from_release = %s to_release = %s action = %s"
% (sys.argv[0], from_release, to_release, action))

View File

@@ -88,7 +88,7 @@ def main():
return 1
arg += 1
configure_logging(LOG)
configure_logging()
LOG.info("%s invoked from_release = %s to_release = %s action = %s"
% (sys.argv[0], from_release, to_release, action))

View File

@@ -191,7 +191,7 @@ def main():
return ERROR
arg += 1
configure_logging(LOG)
configure_logging()
LOG.info(
"%s invoked from_release = %s invoked to_release = %s action = %s"
% (sys.argv[0], from_release, to_release, action)

View File

@@ -39,7 +39,7 @@ def main():
return 1
arg += 1
configure_logging(LOG)
configure_logging()
res = 0
LOG.info("%s invoked from_release = %s to_release = %s action = %s"

View File

@@ -159,7 +159,7 @@ def main():
return ERROR
arg += 1
configure_logging(LOG)
configure_logging()
LOG.info(
"%s invoked from_release = %s invoked to_release = %s action = %s"
% (sys.argv[0], from_release, to_release, action)

View File

@@ -40,7 +40,7 @@ def main():
return 1
arg += 1
configure_logging(LOG)
configure_logging()
LOG.debug("%s invoked with from_release = %s to_release = %s action = %s"
% (sys.argv[0], from_release, to_release, action))

View File

@@ -40,7 +40,7 @@ def main():
return 1
arg += 1
configure_logging(LOG)
configure_logging()
if action in ["activate", "activate-rollback"]:
try:

View File

@@ -58,7 +58,7 @@ def main():
return 1
arg += 1
configure_logging(LOG)
configure_logging()
# Activate
if action == 'activate':

View File

@@ -40,7 +40,7 @@ def main():
print("Invalid option %s." % sys.argv[arg])
return 1
arg += 1
configure_logging(LOG)
configure_logging()
if action == 'activate' and from_release >= '21.12':
LOG.info("%s invoked with from_release = %s to_release = %s "

View File

@@ -61,7 +61,7 @@ def main():
return 1
arg += 1
configure_logging(LOG)
configure_logging()
LOG.info("%s invoked from_release = %s to_release = %s action = %s"
% (sys.argv[0], from_release, to_release, action))

View File

@@ -126,7 +126,7 @@ def check_apps_update_progress(client, action='update'):
def main():
action = sys.argv[3]
if action in ('activate', 'activate-rollback'):
configure_logging(LOG)
configure_logging()
try:
client = get_sysinv_client()
update_operation_result = False

View File

@@ -243,7 +243,7 @@ def main():
print(f"Invalid option {sys.argv[arg]}")
return 1
arg += 1
configure_logging(LOG)
configure_logging()
LOG.info("%s invoked with from_release %s to_release %s and action %s",
sys.argv[0], from_release, to_release, action)

View File

@@ -32,7 +32,7 @@ PCI_CLASS = "pci-sriov"
DEFAULT_POSTGRES_PORT = "5432"
LOG = logging.getLogger('main_logger')
configure_logging(LOG)
configure_logging()
def get_db_credentials():

View File

@@ -43,7 +43,7 @@ def main():
print("Invalid option %s." % sys.argv[arg])
return 1
arg += 1
configure_logging(LOG)
configure_logging()
LOG.info(
"%s invoked from_release = %s to_release = %s action = %s"
% (sys.argv[0], from_release, to_release, action)

View File

@@ -45,7 +45,7 @@ def main():
print("Invalid option %s." % sys.argv[arg])
return 1
arg += 1
configure_logging(LOG)
configure_logging()
LOG.info(
"%s invoked from_release = %s to_release = %s action = %s"
% (sys.argv[0], from_release, to_release, action)