Skip to content

Commit 4d4263f

Browse files
committed
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
1 parent 9e55d59 commit 4d4263f

File tree

5 files changed

+62
-4
lines changed

5 files changed

+62
-4
lines changed

container_config_scripts/nova_cell_v2_discover_hosts.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@
2222

2323
random.seed()
2424

25-
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
25+
debug = os.getenv('__OS_DEBUG', 'false')
26+
27+
if debug.lower() == 'true':
28+
loglevel = logging.DEBUG
29+
else:
30+
loglevel = logging.INFO
31+
32+
logging.basicConfig(stream=sys.stdout, level=loglevel)
2633
LOG = logging.getLogger('nova_cell_v2_discover_hosts')
2734

2835
iterations = 10

container_config_scripts/nova_statedir_ownership.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@
2020
import stat
2121
import sys
2222

23-
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
23+
debug = os.getenv('__OS_DEBUG', 'false')
24+
25+
if debug.lower() == 'true':
26+
loglevel = logging.DEBUG
27+
else:
28+
loglevel = logging.INFO
29+
30+
logging.basicConfig(stream=sys.stdout, level=loglevel)
2431
LOG = logging.getLogger('nova_statedir')
2532

2633

container_config_scripts/nova_wait_for_compute_service.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@
2828

2929
from six.moves.configparser import SafeConfigParser
3030

31-
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
31+
debug = os.getenv('__OS_DEBUG', 'false')
32+
33+
if debug.lower() == 'true':
34+
loglevel = logging.DEBUG
35+
else:
36+
loglevel = logging.INFO
37+
38+
logging.basicConfig(stream=sys.stdout, level=loglevel)
3239
LOG = logging.getLogger('nova_wait_for_compute_service')
3340

3441
iterations = 60

container_config_scripts/nova_wait_for_placement_service.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@
3232
from six.moves.configparser import SafeConfigParser
3333

3434

35-
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
35+
debug = os.getenv('__OS_DEBUG', 'false')
36+
37+
if debug.lower() == 'true':
38+
loglevel = logging.DEBUG
39+
else:
40+
loglevel = logging.INFO
41+
42+
logging.basicConfig(stream=sys.stdout, level=loglevel)
3643
LOG = logging.getLogger('nova_wait_for_placement_service')
3744

3845
iterations = 60

deployment/nova/nova-compute-container-puppet.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,13 @@ outputs:
545545
- ''
546546
- - 'TRIPLEO_DEPLOY_IDENTIFIER='
547547
- {get_param: DeployIdentifier}
548+
- list_join:
549+
- ''
550+
- - '__OS_DEBUG='
551+
- yaql:
552+
expression: str($.data.debug)
553+
data:
554+
debug: {get_attr: [NovaBase, role_data, config_settings, 'nova::logging::debug']}
548555
step_4:
549556
map_merge:
550557
- nova_wait_for_placement_service:
@@ -558,6 +565,14 @@ outputs:
558565
- /var/lib/container-config-scripts/:/container-config-scripts/:z
559566
- /var/lib/config-data/puppet-generated/nova_libvirt/etc/nova:/etc/nova:ro
560567
command: "/container-config-scripts/pyshim.sh /container-config-scripts/nova_wait_for_placement_service.py"
568+
environment:
569+
- list_join:
570+
- ''
571+
- - '__OS_DEBUG='
572+
- yaql:
573+
expression: str($.data.debug)
574+
data:
575+
debug: {get_attr: [NovaBase, role_data, config_settings, 'nova::logging::debug']}
561576
- nova_compute:
562577
start_order: 3
563578
image: *nova_compute_image
@@ -616,6 +631,14 @@ outputs:
616631
- /var/lib/container-config-scripts/:/container-config-scripts/
617632
user: nova
618633
command: "/container-config-scripts/pyshim.sh /container-config-scripts/nova_wait_for_compute_service.py"
634+
environment:
635+
- list_join:
636+
- ''
637+
- - '__OS_DEBUG='
638+
- yaql:
639+
expression: str($.data.debug)
640+
data:
641+
debug: {get_attr: [NovaBase, role_data, config_settings, 'nova::logging::debug']}
619642
- {}
620643
step_5:
621644
if:
@@ -642,6 +665,13 @@ outputs:
642665
- ''
643666
- - 'TRIPLEO_DEPLOY_IDENTIFIER='
644667
- {get_param: DeployIdentifier}
668+
- list_join:
669+
- ''
670+
- - '__OS_DEBUG='
671+
- yaql:
672+
expression: str($.data.debug)
673+
data:
674+
debug: {get_attr: [NovaBase, role_data, config_settings, 'nova::logging::debug']}
645675
- {}
646676
host_prep_tasks:
647677
list_concat:

0 commit comments

Comments
 (0)