Skip to content

Commit 150854c

Browse files
authored
fix: create redis cluster account failed (#2395)
1 parent 8ae9d4e commit 150854c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

addons/redis/scripts/redis-account.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ function do_acl_command() {
1414
# in case, the host is like this: apple-7bff57f594-shard-b8p-1.apple-7bff57f594-shard-b8p-headless.kubeblocks-cloud-ns.svc.cluster.local,apple-7bff57f594-shard-9x9-0.apple-7bff57f594-shard-9x9-headless.kubeblocks-cloud-ns.svc.cluster.local,apple-7bff57f594-shard-8bf-1.apple-7bff57f594-shard-8bf-headless.kubeblocks-cloud-ns.svc.cluster.local
1515
# in case of fixed ip mode, the host is like this: 10.96.180.100:6379@1 10.96.180.100:6379@2
1616
# we need to remove the @1 or @2 and remove the port
17+
port=$(echo "$host" | sed -E 's/.*:([0-9]+)@.*/\1/')
1718
host=$(echo "$host" | sed 's/@[0-9]*//g' | sed 's/:[0-9]*/ /g')
19+
# if the host is a fqdn, port == host; if the host is 10.13.25.19:31666@3013, port != host
20+
if [ "$port" != "$host" ]; then
21+
service_port="$port"
22+
fi
1823
cmd="redis-cli $REDIS_CLI_TLS_CMD -h $host -p $service_port --user $user -a $password"
1924
if [ -z "$password" ]; then
2025
cmd="redis-cli $REDIS_CLI_TLS_CMD -h $host -p $service_port --user $user"

0 commit comments

Comments
 (0)