From 19e1ad3c6ee67cc19e99fd28f57afc029aa63d17 Mon Sep 17 00:00:00 2001 From: Ilya Kheifets Date: Mon, 9 Sep 2024 00:55:46 +0200 Subject: [PATCH] fix: make debug mode more configurable [run-int-tests] Signed-off-by: Ilya Kheifets --- .../templates/worker/_helpers.tpl | 2 +- charts/splunk-connect-for-snmp/values.schema.json | 2 +- docker_compose/docker-compose-worker-poller.yaml | 2 +- docker_compose/docker-compose-worker-sender.yaml | 2 +- docker_compose/docker-compose-worker-trap.yaml | 2 +- .../templates/worker/poller/deployment.yaml | 2 +- .../templates/worker/sender/deployment.yaml | 2 +- .../templates/worker/trap/deployment.yaml | 2 +- .../templates/worker/poller/deployment.yaml | 2 +- .../templates/worker/sender/deployment.yaml | 2 +- .../templates/worker/trap/deployment.yaml | 2 +- .../templates/worker/poller/deployment.yaml | 2 +- .../templates/worker/sender/deployment.yaml | 2 +- .../templates/worker/trap/deployment.yaml | 2 +- .../templates/worker/poller/deployment.yaml | 2 +- .../templates/worker/sender/deployment.yaml | 2 +- .../templates/worker/trap/deployment.yaml | 2 +- .../templates/worker/poller/deployment.yaml | 2 +- .../templates/worker/sender/deployment.yaml | 2 +- .../templates/worker/sender/deployment.yaml | 2 +- .../templates/worker/trap/deployment.yaml | 2 +- .../templates/worker/poller/deployment.yaml | 2 +- .../templates/worker/sender/deployment.yaml | 2 +- .../templates/worker/trap/deployment.yaml | 2 +- splunk_connect_for_snmp/snmp/manager.py | 13 +++++++++++-- 25 files changed, 35 insertions(+), 26 deletions(-) diff --git a/charts/splunk-connect-for-snmp/templates/worker/_helpers.tpl b/charts/splunk-connect-for-snmp/templates/worker/_helpers.tpl index d6913effd..7e3e6647e 100644 --- a/charts/splunk-connect-for-snmp/templates/worker/_helpers.tpl +++ b/charts/splunk-connect-for-snmp/templates/worker/_helpers.tpl @@ -112,7 +112,7 @@ Common labels - name: MAX_OID_TO_PROCESS value: {{ .Values.poller.maxOidToProcess | default "70" | quote }} - name: PYSNMP_DEBUG - value: {{ .Values.pysnmpDebug | default "false" | quote }} + value: {{ .Values.pysnmpDebug | default "" | quote }} - name: PROFILES_RELOAD_DELAY value: {{ .Values.worker.profilesReloadDelay | default "60" | quote }} - name: MIB_SOURCES diff --git a/charts/splunk-connect-for-snmp/values.schema.json b/charts/splunk-connect-for-snmp/values.schema.json index ad107be64..6ac7bedda 100644 --- a/charts/splunk-connect-for-snmp/values.schema.json +++ b/charts/splunk-connect-for-snmp/values.schema.json @@ -38,7 +38,7 @@ "type": "array" }, "pysnmpDebug": { - "type": "boolean" + "type": "string" }, "UI": { "type": "object", diff --git a/docker_compose/docker-compose-worker-poller.yaml b/docker_compose/docker-compose-worker-poller.yaml index 0386b933d..2804006ac 100644 --- a/docker_compose/docker-compose-worker-poller.yaml +++ b/docker_compose/docker-compose-worker-poller.yaml @@ -42,7 +42,7 @@ services: - PROFILES_RELOAD_DELAY=${PROFILES_RELOAD_DELAY:-60} - WORKER_CONCURRENCY=${WORKER_POLLER_CONCURRENCY:-2} - PREFETCH_COUNT=${PREFETCH_POLLER_COUNT:-1} - - PYSNMP_DEBUG=${PYSNMP_DEBUG:-false} + - PYSNMP_DEBUG=${PYSNMP_DEBUG} image: ${SC4SNMP_IMAGE}:${SC4SNMP_TAG:-latest} networks: - my_network diff --git a/docker_compose/docker-compose-worker-sender.yaml b/docker_compose/docker-compose-worker-sender.yaml index 9249d8383..b5817f5cd 100644 --- a/docker_compose/docker-compose-worker-sender.yaml +++ b/docker_compose/docker-compose-worker-sender.yaml @@ -41,7 +41,7 @@ services: - PROFILES_RELOAD_DELAY=${PROFILES_RELOAD_DELAY:-60} - WORKER_CONCURRENCY=${WORKER_SENDER_CONCURRENCY:-2} - PREFETCH_COUNT=${PREFETCH_SENDER_COUNT:-1} - - PYSNMP_DEBUG=${PYSNMP_DEBUG:-false} + - PYSNMP_DEBUG=${PYSNMP_DEBUG} depends_on: - redis - mongo diff --git a/docker_compose/docker-compose-worker-trap.yaml b/docker_compose/docker-compose-worker-trap.yaml index 3fbf6ab5c..c12accabd 100644 --- a/docker_compose/docker-compose-worker-trap.yaml +++ b/docker_compose/docker-compose-worker-trap.yaml @@ -44,7 +44,7 @@ services: - RESOLVE_TRAP_ADDRESS=${RESOLVE_TRAP_ADDRESS:-false} - MAX_DNS_CACHE_SIZE_TRAPS=${MAX_DNS_CACHE_SIZE_TRAPS:-500} - TTL_DNS_CACHE_TRAPS=${TTL_DNS_CACHE_TRAPS:-1800} - - PYSNMP_DEBUG=${PYSNMP_DEBUG:-false} + - PYSNMP_DEBUG=${PYSNMP_DEBUG} depends_on: - redis - mongo diff --git a/rendered/manifests/tests/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml b/rendered/manifests/tests/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml index 89c57a1b3..5a24aa081 100644 --- a/rendered/manifests/tests/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml +++ b/rendered/manifests/tests/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml @@ -67,7 +67,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml b/rendered/manifests/tests/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml index 5e0fe7ee9..17c212667 100644 --- a/rendered/manifests/tests/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml +++ b/rendered/manifests/tests/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml @@ -67,7 +67,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml b/rendered/manifests/tests/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml index 4dbb2a6c0..9b6b4a5f5 100644 --- a/rendered/manifests/tests/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml +++ b/rendered/manifests/tests/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml @@ -67,7 +67,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests_autoscaling_enabled/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml b/rendered/manifests/tests_autoscaling_enabled/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml index f62d98fca..a790af741 100644 --- a/rendered/manifests/tests_autoscaling_enabled/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml +++ b/rendered/manifests/tests_autoscaling_enabled/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml @@ -66,7 +66,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests_autoscaling_enabled/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml b/rendered/manifests/tests_autoscaling_enabled/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml index 8cd7c7263..1dd219cf6 100644 --- a/rendered/manifests/tests_autoscaling_enabled/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml +++ b/rendered/manifests/tests_autoscaling_enabled/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml @@ -66,7 +66,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests_autoscaling_enabled/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml b/rendered/manifests/tests_autoscaling_enabled/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml index a29347008..5660f516c 100644 --- a/rendered/manifests/tests_autoscaling_enabled/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml +++ b/rendered/manifests/tests_autoscaling_enabled/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml @@ -66,7 +66,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests_autoscaling_enabled_deprecated/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml b/rendered/manifests/tests_autoscaling_enabled_deprecated/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml index f62d98fca..a790af741 100644 --- a/rendered/manifests/tests_autoscaling_enabled_deprecated/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml +++ b/rendered/manifests/tests_autoscaling_enabled_deprecated/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml @@ -66,7 +66,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests_autoscaling_enabled_deprecated/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml b/rendered/manifests/tests_autoscaling_enabled_deprecated/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml index 8cd7c7263..1dd219cf6 100644 --- a/rendered/manifests/tests_autoscaling_enabled_deprecated/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml +++ b/rendered/manifests/tests_autoscaling_enabled_deprecated/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml @@ -66,7 +66,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests_autoscaling_enabled_deprecated/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml b/rendered/manifests/tests_autoscaling_enabled_deprecated/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml index a29347008..5660f516c 100644 --- a/rendered/manifests/tests_autoscaling_enabled_deprecated/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml +++ b/rendered/manifests/tests_autoscaling_enabled_deprecated/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml @@ -66,7 +66,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests_enable_ui/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml b/rendered/manifests/tests_enable_ui/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml index 89c57a1b3..5a24aa081 100644 --- a/rendered/manifests/tests_enable_ui/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml +++ b/rendered/manifests/tests_enable_ui/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml @@ -67,7 +67,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests_enable_ui/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml b/rendered/manifests/tests_enable_ui/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml index 5e0fe7ee9..17c212667 100644 --- a/rendered/manifests/tests_enable_ui/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml +++ b/rendered/manifests/tests_enable_ui/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml @@ -67,7 +67,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests_enable_ui/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml b/rendered/manifests/tests_enable_ui/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml index 4dbb2a6c0..9b6b4a5f5 100644 --- a/rendered/manifests/tests_enable_ui/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml +++ b/rendered/manifests/tests_enable_ui/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml @@ -67,7 +67,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests_only_polling/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml b/rendered/manifests/tests_only_polling/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml index 89c57a1b3..5a24aa081 100644 --- a/rendered/manifests/tests_only_polling/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml +++ b/rendered/manifests/tests_only_polling/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml @@ -67,7 +67,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests_only_polling/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml b/rendered/manifests/tests_only_polling/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml index 5e0fe7ee9..17c212667 100644 --- a/rendered/manifests/tests_only_polling/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml +++ b/rendered/manifests/tests_only_polling/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml @@ -67,7 +67,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests_only_traps/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml b/rendered/manifests/tests_only_traps/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml index 5e0fe7ee9..17c212667 100644 --- a/rendered/manifests/tests_only_traps/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml +++ b/rendered/manifests/tests_only_traps/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml @@ -67,7 +67,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests_only_traps/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml b/rendered/manifests/tests_only_traps/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml index 4dbb2a6c0..9b6b4a5f5 100644 --- a/rendered/manifests/tests_only_traps/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml +++ b/rendered/manifests/tests_only_traps/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml @@ -67,7 +67,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests_probes_enabled/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml b/rendered/manifests/tests_probes_enabled/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml index e9f4e5176..af48a9368 100644 --- a/rendered/manifests/tests_probes_enabled/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml +++ b/rendered/manifests/tests_probes_enabled/splunk-connect-for-snmp/templates/worker/poller/deployment.yaml @@ -67,7 +67,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests_probes_enabled/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml b/rendered/manifests/tests_probes_enabled/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml index 451e784aa..5118bb8a9 100644 --- a/rendered/manifests/tests_probes_enabled/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml +++ b/rendered/manifests/tests_probes_enabled/splunk-connect-for-snmp/templates/worker/sender/deployment.yaml @@ -67,7 +67,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/rendered/manifests/tests_probes_enabled/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml b/rendered/manifests/tests_probes_enabled/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml index d9db309be..37c3334f7 100644 --- a/rendered/manifests/tests_probes_enabled/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml +++ b/rendered/manifests/tests_probes_enabled/splunk-connect-for-snmp/templates/worker/trap/deployment.yaml @@ -67,7 +67,7 @@ spec: - name: MAX_OID_TO_PROCESS value: "70" - name: PYSNMP_DEBUG - value: "false" + value: "" - name: PROFILES_RELOAD_DELAY value: "60" - name: MIB_SOURCES diff --git a/splunk_connect_for_snmp/snmp/manager.py b/splunk_connect_for_snmp/snmp/manager.py index 874b9cfe1..c43985afb 100644 --- a/splunk_connect_for_snmp/snmp/manager.py +++ b/splunk_connect_for_snmp/snmp/manager.py @@ -63,7 +63,7 @@ PROFILES_RELOAD_DELAY = int(os.getenv("PROFILES_RELOAD_DELAY", "60")) UDP_CONNECTION_TIMEOUT = int(os.getenv("UDP_CONNECTION_TIMEOUT", 3)) MAX_OID_TO_PROCESS = int(os.getenv("MAX_OID_TO_PROCESS", 70)) -PYSNMP_DEBUG = human_bool(os.getenv("PYSNMP_DEBUG", False)) +PYSNMP_DEBUG = os.getenv("PYSNMP_DEBUG", "") DEFAULT_STANDARD_MIBS = [ "HOST-RESOURCES-MIB", @@ -78,7 +78,16 @@ if PYSNMP_DEBUG: from pysnmp import debug - debug.setLogger(debug.Debug('all', options={'loggerName': logger})) + + debug_flags = list(debug.flagMap.keys()) + enabled_debug_flags = [ + debug_flag.strip() + for debug_flag in PYSNMP_DEBUG.split(",") + if debug_flag.strip() in debug_flags + ] + + if enabled_debug_flags: + debug.setLogger(debug.Debug(*enabled_debug_flags, loggerName=logger)) def return_address_and_port(target):