Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[redis-cli][multiasic]redis-cli supports namespace #8243

Closed
wants to merge 1 commit into from

Conversation

mlok-nokia
Copy link
Contributor

The current redis-cli has been hardcoded only to access to the host database. MThis change modifies the redis-cli to identify the namespace and access to its database

The current redis-cli has been hardcoded only to access to the host database. MThis change modifies the redis-cli to identify the namespace and access to its database
@mlok-nokia mlok-nokia requested a review from lguohan as a code owner July 21, 2021 21:28
@mlok-nokia
Copy link
Contributor Author

@lguohan Could you please help to review this change or assign the the right person to review it?

@anshuv-mfst
Copy link

@arlakshm - FYI

@arlakshm
Copy link
Contributor

arlakshm commented Aug 4, 2021

sonic-db-cli can to be used instead of redis-cli for multi-asic platforms.
sonic-db-cli has the -n namspace option implemented.
Link to earlier discussion on this for context #3888 (comment)

@judyjoseph
Copy link
Contributor

This PR could be closed in favor of using sonic-db-cli

@mlok-nokia mlok-nokia closed this Aug 31, 2021
@mlok-nokia mlok-nokia deleted the rediscli_fix branch August 31, 2021 21:23
@sanmalho-git
Copy link

@arlakshm - redis-cli is still in use in a lot of tests in sonic-mgmt. Is there a plan to modify all tests in sonic-mgmt to use sonic-db-cli?

@arlakshm
Copy link
Contributor

arlakshm commented Sep 7, 2021

Hi @sanmalho-git , sonic-mgmt has function run_redis_cli_cmd to run the redis-cli on Asic or device. I think that should help.

@sanmalho-git
Copy link

/usr/bin/redis-cli in the host and in the netns is hard-coded to use the global 'database'.

docker exec -$DOCKER_EXEC_FLAGS database redis-cli "$@"

So, regardless of whether I add 'sudo ip netns exec' to the redis-cli command or not, it still goes to the global 'database'. As an example on a multi-asic box, keys PORT* in CONFIG_DB at the host level are:

admin@sonic:~$ redis-cli -n 4 keys "PORT*"
 1) "PORT|Ethernet7"
 2) "PORT|Ethernet4"
 3) "PORTCHANNEL_INTERFACE|PortChannel0001|FC00::19/126"
 4) "PORTCHANNEL_MEMBER|PortChannel0005|Ethernet27"
 5) "PORT|Ethernet28"
 6) "PORTCHANNEL|PortChannel0001"
 7) "PORTCHANNEL_MEMBER|PortChannel0001|Ethernet7"
 8) "PORTCHANNEL_INTERFACE|PortChannel0005"
 9) "PORT|Ethernet26"
10) "PORTCHANNEL_INTERFACE|PortChannel0005|FC00::25/126"
11) "PORTCHANNEL|PortChannel0005"
12) "PORTCHANNEL_MEMBER|PortChannel0005|Ethernet26"
13) "PORTCHANNEL_INTERFACE|PortChannel0001"
14) "PORT|Ethernet27"
15) "PORTCHANNEL_INTERFACE|PortChannel0005|10.0.0.18/31"
16) "PORTCHANNEL_INTERFACE|PortChannel0001|10.0.0.12/31"
17) "PORTCHANNEL_MEMBER|PortChannel0001|Ethernet4"
18) "PORT|Ethernet10"

Doing the above command in asic0 namespace gives the same result:

admin@sonic:~$ sudo ip netns exec asic0 redis-cli -n 4 keys "PORT*"
 1) "PORT|Ethernet7"
 2) "PORT|Ethernet4"
 3) "PORTCHANNEL_INTERFACE|PortChannel0001|FC00::19/126"
 4) "PORTCHANNEL_MEMBER|PortChannel0005|Ethernet27"
 5) "PORT|Ethernet28"
 6) "PORTCHANNEL|PortChannel0001"
 7) "PORTCHANNEL_MEMBER|PortChannel0001|Ethernet7"
 8) "PORTCHANNEL_INTERFACE|PortChannel0005"
 9) "PORT|Ethernet26"
10) "PORTCHANNEL_INTERFACE|PortChannel0005|FC00::25/126"
11) "PORTCHANNEL|PortChannel0005"
12) "PORTCHANNEL_MEMBER|PortChannel0005|Ethernet26"
13) "PORTCHANNEL_INTERFACE|PortChannel0001"
14) "PORT|Ethernet27"
15) "PORTCHANNEL_INTERFACE|PortChannel0005|10.0.0.18/31"
16) "PORTCHANNEL_INTERFACE|PortChannel0001|10.0.0.12/31"
17) "PORTCHANNEL_MEMBER|PortChannel0001|Ethernet4"
18) "PORT|Ethernet10"

But if we use 'docker exec database0' we get the correct keys:

admin@sonic:~$ docker exec database0  redis-cli -n 4 keys "PORT*"
PORT|Ethernet2
PORT|Ethernet14
PORTCHANNEL|PortChannel0001
PORT|Ethernet1
PORTCHANNEL_INTERFACE|PortChannel0001
PORT|Ethernet6
PORT|Ethernet11
PORT|Ethernet4
PORT|Ethernet12
PORTCHANNEL_MEMBER|PortChannel0001|Ethernet7
PORT|Ethernet16
PORTCHANNEL_INTERFACE|PortChannel0001|10.0.0.12/31
PORT|Ethernet10
PORT|Ethernet17
PORT|Ethernet0
PORT|Ethernet7
PORTCHANNEL_MEMBER|PortChannel0001|Ethernet4
PORT|Ethernet-IB0
PORTCHANNEL_INTERFACE|PortChannel0001|FC00::19/126
PORT|Ethernet3
PORT|Ethernet13
PORT|Ethernet9
PORT|Ethernet15
PORT|Ethernet8
PORT|Ethernet5

So, in sonic-mgmt, should run_redis_cli_cmd should do 'docker exec' instead of 'sudo ip netns exec'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants