sonic-net / sonic-buildimage

Scripts which perform an installable binary image build for SONiC
Other
728 stars 1.39k forks source link

[master] sonic-db-cli was not able to connect to CHASSIS DB when namespace is provided. #18733

Closed ysmanman closed 1 month ago

ysmanman commented 5 months ago

Description

sonic-db-cli was not able to connect to CHASSIS DB in host namespace when namespace is provided:

admin@cmp217-5:/var/log$ sudo sonic-db-cli -n asic0 CHASSIS_APP_DB keys "*"
Invalid database name input : 'CHASSIS_APP_DB'
Unable to connect to redis (unix-socket): Cannot assign requested address
admin@cmp217-5:/var/log$ 

It worked fine within asic namespace (without providing namespace):

admin@cmp217-5:/var/log$ docker exec -it swss0 bash
root@cmp217-5:/# sonic-db-cli CHASSIS_APP_DB keys "*"
SYSTEM_INTERFACE|cmp217-5|asic1|Ethernet256
SYSTEM_INTERFACE|cmp217-5|asic0|Ethernet80
SYSTEM_INTERFACE|cmp217-5|asic0|Ethernet32
SYSTEM_INTERFACE|cmp217-5|asic0|Ethernet-IB0
SYSTEM_LAG_ID_START
SYSTEM_INTERFACE|cmp217-5|asic0|Ethernet24
SYSTEM_INTERFACE|cmp217-5|asic1|Ethernet216
SYSTEM_INTERFACE|cmp217-5|asic1|Ethernet224
SYSTEM_LAG_ID_END
SYSTEM_NEIGH|cmp217-5|asic1|Ethernet-IB1|10.0.254.3
SYSTEM_NEIGH|cmp217-5|asic0|Ethernet-IB0|10.0.254.1
SYSTEM_INTERFACE|cmp217-5|asic0|Ethernet88
SYSTEM_INTERFACE|cmp217-5|asic0|Ethernet40
SYSTEM_NEIGH|cmp217-5|asic1|Ethernet-IB1|fc00:3000::3
SYSTEM_NEIGH|cmp217-5|asic0|Ethernet-IB0|fc00:3000::1
SYSTEM_INTERFACE|cmp217-5|asic1|Ethernet176
SYSTEM_INTERFACE|cmp217-5|asic1|Ethernet-IB1
SYSTEM_INTERFACE|cmp217-5|asic1|Ethernet184
SYSTEM_INTERFACE|cmp217-5|asic1|Ethernet-Rec1
SYSTEM_INTERFACE|cmp217-5|asic1|Ethernet248
SYSTEM_INTERFACE|cmp217-5|asic1|Ethernet144
SYSTEM_INTERFACE|cmp217-5|asic0|Ethernet-Rec0
root@cmp217-5:/# 

Steps to reproduce the issue:

1. 2. 3.

Describe the results you received:

Describe the results you expected:

Output of show version:

(paste your output here)

Output of show techsupport:

(paste your output here or download and attach the file here )

Additional information you deem important (e.g. issue happens only occasionally):

ysmanman commented 5 months ago

This seems a regression introduced by https://github.com/sonic-net/sonic-swss-common/pull/797. Before this PR, sonic-db-cli use tcp socket to connect to CHASSIS DBs by default. But with this PR, now it always uses unix socket when namespace is provided.

ysmanman commented 5 months ago

Add @kenneth-arista @arista-nwolfe @arlakshm for viz.

mlok-nokia commented 5 months ago

Afte PR797, behaviours has been changed.
1) Question and confusion: If command "sonic-db-cli -n asic0 STATE_DB PING " means from localhost to ping asic0 STATE_DB, what does it mean by "sonic-db-cli -n asic0 CHASSIS_STATE_DB PING"? Are we ping asic0 CHASSIS_STATE_DB from local host? There is NO CHASSIS_STATE_DB in asic0 namespace. Should PING failure be expected?

2) If we want to allow to PING/access CHASSIS_STATE_DB regardless of "sonic-db-cli" with any asic instance ID specified in the specified in command line, then this issue needs to be addressed.

I have fixed one case with PR https://github.com/sonic-net/sonic-swss-common/pull/866 : "sonic-db-cli -n asic0 PING" which is in the database.sh. In our private branch, we temporarily address this issue by modifying the swss.sh to use sonic-db-cli without asic instance when it wants to access CHASSIS DB.

bingwang-ms commented 5 months ago

The issue will be discussed in chassis meeting.

kenneth-arista commented 5 months ago

Some related history: https://github.com/sonic-net/sonic-buildimage/pull/7002

kenneth-arista commented 5 months ago

Additional related history: https://github.com/sonic-net/sonic-buildimage/pull/17962

wenyiz2021 commented 1 month ago

https://github.com/sonic-net/sonic-swss-common/pull/883 also merged