From 28a0d3c532d8fee90c2d3f9b5695cec3d57cf08f Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Tue, 30 Apr 2019 13:19:05 +0200 Subject: [PATCH] Set debug level of nova container_config_scripts only when enabled Right now all scripts log in DEBUG level. This change enables only DEBUG level if debug is also enabled for the nova service. Change-Id: Ie58a6630877a58bec8ce763ede166997bd41f882 (cherry picked from commit 4d4263f4f1f1e49851503162fcd8d3cfca163b73) --- .../nova_cell_v2_discover_hosts.py | 9 +++++- .../nova_statedir_ownership.py | 9 +++++- .../nova_wait_for_compute_service.py | 9 +++++- .../nova_wait_for_placement_service.py | 9 +++++- .../nova/nova-compute-container-puppet.yaml | 30 +++++++++++++++++++ 5 files changed, 62 insertions(+), 4 deletions(-) diff --git a/container_config_scripts/nova_cell_v2_discover_hosts.py b/container_config_scripts/nova_cell_v2_discover_hosts.py index 2ba29548cd..9c80b85d46 100644 --- a/container_config_scripts/nova_cell_v2_discover_hosts.py +++ b/container_config_scripts/nova_cell_v2_discover_hosts.py @@ -22,7 +22,14 @@ import time random.seed() -logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) +debug = os.getenv('__OS_DEBUG', 'false') + +if debug.lower() == 'true': + loglevel = logging.DEBUG +else: + loglevel = logging.INFO + +logging.basicConfig(stream=sys.stdout, level=loglevel) LOG = logging.getLogger('nova_cell_v2_discover_hosts') iterations = 10 diff --git a/container_config_scripts/nova_statedir_ownership.py b/container_config_scripts/nova_statedir_ownership.py index e6c496ccdf..a9bcd3443e 100644 --- a/container_config_scripts/nova_statedir_ownership.py +++ b/container_config_scripts/nova_statedir_ownership.py @@ -20,7 +20,14 @@ import pwd import stat import sys -logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) +debug = os.getenv('__OS_DEBUG', 'false') + +if debug.lower() == 'true': + loglevel = logging.DEBUG +else: + loglevel = logging.INFO + +logging.basicConfig(stream=sys.stdout, level=loglevel) LOG = logging.getLogger('nova_statedir') diff --git a/container_config_scripts/nova_wait_for_compute_service.py b/container_config_scripts/nova_wait_for_compute_service.py index 2c2e8416a4..47a08c460e 100644 --- a/container_config_scripts/nova_wait_for_compute_service.py +++ b/container_config_scripts/nova_wait_for_compute_service.py @@ -28,7 +28,14 @@ from novaclient import client from six.moves.configparser import SafeConfigParser -logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) +debug = os.getenv('__OS_DEBUG', 'false') + +if debug.lower() == 'true': + loglevel = logging.DEBUG +else: + loglevel = logging.INFO + +logging.basicConfig(stream=sys.stdout, level=loglevel) LOG = logging.getLogger('nova_wait_for_compute_service') iterations = 60 diff --git a/container_config_scripts/nova_wait_for_placement_service.py b/container_config_scripts/nova_wait_for_placement_service.py index 5469c64bf9..acedc32623 100755 --- a/container_config_scripts/nova_wait_for_placement_service.py +++ b/container_config_scripts/nova_wait_for_placement_service.py @@ -32,7 +32,14 @@ import requests from six.moves.configparser import SafeConfigParser -logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) +debug = os.getenv('__OS_DEBUG', 'false') + +if debug.lower() == 'true': + loglevel = logging.DEBUG +else: + loglevel = logging.INFO + +logging.basicConfig(stream=sys.stdout, level=loglevel) LOG = logging.getLogger('nova_wait_for_placement_service') iterations = 60 diff --git a/deployment/nova/nova-compute-container-puppet.yaml b/deployment/nova/nova-compute-container-puppet.yaml index 5e8f230a7b..898e2e7068 100644 --- a/deployment/nova/nova-compute-container-puppet.yaml +++ b/deployment/nova/nova-compute-container-puppet.yaml @@ -545,6 +545,13 @@ outputs: - '' - - 'TRIPLEO_DEPLOY_IDENTIFIER=' - {get_param: DeployIdentifier} + - list_join: + - '' + - - '__OS_DEBUG=' + - yaql: + expression: str($.data.debug) + data: + debug: {get_attr: [NovaBase, role_data, config_settings, 'nova::logging::debug']} step_4: map_merge: - nova_wait_for_placement_service: @@ -558,6 +565,14 @@ outputs: - /var/lib/container-config-scripts/:/container-config-scripts/:z - /var/lib/config-data/puppet-generated/nova_libvirt/etc/nova:/etc/nova:ro command: "/container-config-scripts/pyshim.sh /container-config-scripts/nova_wait_for_placement_service.py" + environment: + - list_join: + - '' + - - '__OS_DEBUG=' + - yaql: + expression: str($.data.debug) + data: + debug: {get_attr: [NovaBase, role_data, config_settings, 'nova::logging::debug']} - nova_compute: start_order: 3 image: *nova_compute_image @@ -616,6 +631,14 @@ outputs: - /var/lib/container-config-scripts/:/container-config-scripts/ user: nova command: "/container-config-scripts/pyshim.sh /container-config-scripts/nova_wait_for_compute_service.py" + environment: + - list_join: + - '' + - - '__OS_DEBUG=' + - yaql: + expression: str($.data.debug) + data: + debug: {get_attr: [NovaBase, role_data, config_settings, 'nova::logging::debug']} - {} step_5: if: @@ -642,6 +665,13 @@ outputs: - '' - - 'TRIPLEO_DEPLOY_IDENTIFIER=' - {get_param: DeployIdentifier} + - list_join: + - '' + - - '__OS_DEBUG=' + - yaql: + expression: str($.data.debug) + data: + debug: {get_attr: [NovaBase, role_data, config_settings, 'nova::logging::debug']} - {} host_prep_tasks: list_concat: