From f2c692c200e6b072749d096909918f6be24e6366 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Thu, 18 Apr 2024 09:35:53 +0800 Subject: [PATCH] Fix smart switch check command in gnmi and orchagent start script. (#18663) Fix smart switch check command in gnmi and orchagent start script. #### Why I did it Smart switch check command in gnmi and orchagent start script check wrong Redis table. #### How I did it Change smart switch check command check "DEVICE_METADATA|localhost" table. #### How to verify it Pass all UT & E2E test --- dockers/docker-orchagent/orchagent.sh | 14 ++++++++++++-- dockers/docker-sonic-gnmi/gnmi-native.sh | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/dockers/docker-orchagent/orchagent.sh b/dockers/docker-orchagent/orchagent.sh index 883864dbd919..79434668dcc7 100755 --- a/dockers/docker-orchagent/orchagent.sh +++ b/dockers/docker-orchagent/orchagent.sh @@ -73,9 +73,19 @@ else fi # Enable ZMQ for SmartSwitch -LOCALHOST_SUBTYPE=`sonic-db-cli CONFIG_DB hget localhost "subtype"` +LOCALHOST_SUBTYPE=`sonic-db-cli CONFIG_DB hget "DEVICE_METADATA|localhost" "subtype"` if [[ x"${LOCALHOST_SUBTYPE}" == x"SmartSwitch" ]]; then - ORCHAGENT_ARGS+=" -q tcp://127.0.0.1:8100" + midplane_mgmt_ip=$( ip -json -4 addr show eth0-midplane | jq -r ".[0].addr_info[0].local" ) + mgmt_ip=$( ip -json -4 addr show eth0 | jq -r ".[0].addr_info[0].local" ) + if [[ $midplane_ip != "" ]]; then + # Enable ZMQ with eth0-midplane address + ORCHAGENT_ARGS+=" -q tcp://${midplane_mgmt_ip}:8100" + elif [[ $mgmt_ip != "" ]]; then + # If eth0-midplane interface does not exist, enable ZMQ with eth0 address + ORCHAGENT_ARGS+=" -q tcp://${mgmt_ip}:8100" + else + ORCHAGENT_ARGS+=" -q tcp://127.0.0.1:8100" + fi fi exec /usr/bin/orchagent ${ORCHAGENT_ARGS} diff --git a/dockers/docker-sonic-gnmi/gnmi-native.sh b/dockers/docker-sonic-gnmi/gnmi-native.sh index ea5b88f44e3f..d9bab2700e4b 100755 --- a/dockers/docker-sonic-gnmi/gnmi-native.sh +++ b/dockers/docker-sonic-gnmi/gnmi-native.sh @@ -71,9 +71,9 @@ else fi # Enable ZMQ for SmartSwitch -LOCALHOST_SUBTYPE=`sonic-db-cli CONFIG_DB hget localhost "subtype"` +LOCALHOST_SUBTYPE=`sonic-db-cli CONFIG_DB hget "DEVICE_METADATA|localhost" "subtype"` if [[ x"${LOCALHOST_SUBTYPE}" == x"SmartSwitch" ]]; then - TELEMETRY_ARGS+=" -zmq_address=tcp://127.0.0.1:8100" + TELEMETRY_ARGS+=" -zmq_port=8100" fi # Server will handle threshold connections consecutively