From 69de1ace3e9f9e9b8564b786684a60bd6972f6b7 Mon Sep 17 00:00:00 2001 From: bruzzechesse Date: Tue, 7 Mar 2023 12:13:16 +0100 Subject: [PATCH 1/3] small fix on discovery compute quota file decresed severity of log in discover cai from INFO to DEBUG --- .../network-dashboard/src/plugins/discover-cai.py | 2 +- .../network-dashboard/src/plugins/discover-compute-quota.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/blueprints/cloud-operations/network-dashboard/src/plugins/discover-cai.py b/blueprints/cloud-operations/network-dashboard/src/plugins/discover-cai.py index 1ac62d0664..16d2c5b854 100644 --- a/blueprints/cloud-operations/network-dashboard/src/plugins/discover-cai.py +++ b/blueprints/cloud-operations/network-dashboard/src/plugins/discover-cai.py @@ -98,7 +98,7 @@ def _handle_resource(resources, asset_type, data): # derive parent type and id and skip if parent is not within scope parent_data = _get_parent(data['parent'], resources) if not parent_data: - LOGGER.info(f'{resource["self_link"]} outside perimeter') + LOGGER.debug(f'{resource["self_link"]} outside perimeter') LOGGER.debug([ resources['organization'], resources['folders'], resources['projects:number'] diff --git a/blueprints/cloud-operations/network-dashboard/src/plugins/discover-compute-quota.py b/blueprints/cloud-operations/network-dashboard/src/plugins/discover-compute-quota.py index 9c9e8f9486..7a6794ff43 100644 --- a/blueprints/cloud-operations/network-dashboard/src/plugins/discover-compute-quota.py +++ b/blueprints/cloud-operations/network-dashboard/src/plugins/discover-compute-quota.py @@ -45,6 +45,8 @@ def _handle_discovery(resources, response): self_link = part.get('selfLink') if not self_link: logging.warn('invalid quota response') + else: + continue self_link = self_link.split('/') if kind == 'compute#project': project_id = self_link[-1] From 3e26a65cb29f2f86c837b3ff53a5c5ff34695d85 Mon Sep 17 00:00:00 2001 From: bruzzechesse Date: Tue, 7 Mar 2023 14:41:33 +0100 Subject: [PATCH 2/3] remove else statement in condition --- .../network-dashboard/src/plugins/discover-compute-quota.py | 1 - 1 file changed, 1 deletion(-) diff --git a/blueprints/cloud-operations/network-dashboard/src/plugins/discover-compute-quota.py b/blueprints/cloud-operations/network-dashboard/src/plugins/discover-compute-quota.py index 7a6794ff43..9801803ae4 100644 --- a/blueprints/cloud-operations/network-dashboard/src/plugins/discover-compute-quota.py +++ b/blueprints/cloud-operations/network-dashboard/src/plugins/discover-compute-quota.py @@ -45,7 +45,6 @@ def _handle_discovery(resources, response): self_link = part.get('selfLink') if not self_link: logging.warn('invalid quota response') - else: continue self_link = self_link.split('/') if kind == 'compute#project': From c06014141913eb9099bdb30479eac26ca4557cba Mon Sep 17 00:00:00 2001 From: Ludo Date: Wed, 8 Mar 2023 18:06:38 +0100 Subject: [PATCH 3/3] add flag for debug logging --- blueprints/cloud-operations/network-dashboard/src/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/blueprints/cloud-operations/network-dashboard/src/main.py b/blueprints/cloud-operations/network-dashboard/src/main.py index bd57f18e4b..ec5e5c6ea7 100755 --- a/blueprints/cloud-operations/network-dashboard/src/main.py +++ b/blueprints/cloud-operations/network-dashboard/src/main.py @@ -266,11 +266,13 @@ def main_cf_pubsub(event, context): help='Load JSON resources from file, skips init and discovery.') @click.option('--debug-plugin', help='Run only core and specified timeseries plugin.') +@click.option('--debug', is_flag=True, default=False, + help='Turn on debug logging.') def main(discovery_root, monitoring_project, project=None, folder=None, custom_quota_file=None, dump_file=None, load_file=None, - debug_plugin=None): + debug_plugin=None, debug=False): 'CLI entry point.' - logging.basicConfig(level=logging.INFO) + logging.basicConfig(level=logging.INFO if not debug else logging.DEBUG) if discovery_root.partition('/')[0] not in ('folders', 'organizations'): raise SystemExit('Invalid discovery root.') descriptors = []