From f00efef50a89162894d8fd2956487fb1fe4c76ae Mon Sep 17 00:00:00 2001 From: Bob Chu <79439153+qnos@users.noreply.github.com> Date: Thu, 28 Sep 2023 08:20:18 +0800 Subject: [PATCH] [Telemetry] enable default service config if no config from DB (#16683) #### Why I did it Fix issue #16533 , telemetry service exit in master and 202305 branches due to no telemetry configs in redis DB. #### How I did it Enable default config if no TELEMETRY configs from redis DB. #### How to verify it After the fix, telemetry service would work with the following two scenarios: 1. With TELEMETRY config in redis DB, load service configs from DB. 2. No TELEMETRY config in redis DB, use default service configs. --- dockers/docker-sonic-telemetry/telemetry.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dockers/docker-sonic-telemetry/telemetry.sh b/dockers/docker-sonic-telemetry/telemetry.sh index c7693adc161b..6e5de142baf8 100755 --- a/dockers/docker-sonic-telemetry/telemetry.sh +++ b/dockers/docker-sonic-telemetry/telemetry.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash EXIT_TELEMETRY_VARS_FILE_NOT_FOUND=1 -INCORRECT_TELEMETRY_VALUE = 2 +INCORRECT_TELEMETRY_VALUE=2 TELEMETRY_VARS_FILE=/usr/share/sonic/templates/telemetry_vars.j2 if [ ! -f "$TELEMETRY_VARS_FILE" ]; then @@ -75,7 +75,7 @@ THRESHOLD_CONNECTIONS=$(echo $GNMI | jq -r '.threshold') if [[ $THRESHOLD_CONNECTIONS =~ ^[0-9]+$ ]]; then TELEMETRY_ARGS+=" --threshold $THRESHOLD_CONNECTIONS" else - if [[ $THRESHOLD_CONNECTIONS == "null" ]]; then + if [ -z $GNMI ] || [[ $THRESHOLD_CONNECTIONS == "null" ]]; then TELEMETRY_ARGS+=" --threshold 100" else echo "Incorrect threshold value, expecting positive integers" >&2 @@ -88,7 +88,7 @@ IDLE_CONN_DURATION=$(echo $GNMI | jq -r '.idle_conn_duration') if [[ $IDLE_CONN_DURATION =~ ^[0-9]+$ ]]; then TELEMETRY_ARGS+=" --idle_conn_duration $IDLE_CONN_DURATION" else - if [[ $IDLE_CONN_DURATION == "null" ]]; then + if [ -z $GNMI ] || [[ $IDLE_CONN_DURATION == "null" ]]; then TELEMETRY_ARGS+=" --idle_conn_duration 5" else echo "Incorrect idle_conn_duration value, expecting positive integers" >&2