bitnami / charts

Bitnami Helm Charts
https://bitnami.com
Other
9.03k stars 9.22k forks source link

[bitnami/redis] Configuring the node as master instead as replica when redis on the same k8s node and exposed outside by HostIP #16925

Open AlehYarmalovich opened 1 year ago

AlehYarmalovich commented 1 year ago

Name and Version

bitnami/redis 17.11.3

What architecture are you using?

amd64

What steps will reproduce the bug?

install helm chart with custom parameters

Are you using any custom parameters or values?

architecture: replication
useHostnames: false
sentinel:
  enabled: true
  quorum: 2
  masterSet: master
  downAfterMilliseconds: 2000
  failoverTimeout: 1000
  service:
    type: NodePort
    nodePorts:
      redis: 30310
      sentinel: 30420
useExternalDNS:
  enabled: true
  suffix: example.com
  additionalAnnotations:
    dns-type: external-dns
    endpoints-type: HostIP

What is the expected behavior?

 12:25:05.19 INFO  ==> about to run the command: timeout 220 redis-cli -h 10.10.10.10 -p 30421 sentinel get-master-addr-by-name master
 12:25:05.20 INFO  ==> about to run the command: timeout 220 redis-cli -h 10.10.10.10 -p 30421 sentinel get-master-addr-by-name master
 12:25:05.21 INFO  ==> Current master: REDIS_SENTINEL_INFO=(10.10.10.10,30311)
 12:25:05.22 INFO  ==> Configuring the node as master
1:C 26 May 2023 12:25:05.263 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 26 May 2023 12:25:05.263 # Redis version=7.0.11, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 26 May 2023 12:25:05.263 # Configuration loaded
1:M 26 May 2023 12:25:05.264 * monotonic clock: POSIX clock_gettime
1:M 26 May 2023 12:25:05.266 * Running mode=standalone, port=6379.
1:M 26 May 2023 12:25:05.266 # Server initialized
1:M 26 May 2023 12:25:05.266 * Ready to accept connections
NAME                    READY   STATUS    RESTARTS   AGE   IP              NODE                           
redis-test-node-0       2/2     Running   0          24h   100.100.100.1   ip-10-10-10-10.ec2.internal
redis-test-node-1       2/2     Running   0          24h   100.100.100.2   ip-10-10-10-10.ec2.internal
redis-test-node-2       2/2     Running   0          24h   100.100.100.3   ip-10-10-10-10.ec2.internal

What do you see instead?

instead of:

        # Fetches current master's host and port
        REDIS_SENTINEL_INFO=($(get_sentinel_master_info))
        info "Current master: REDIS_SENTINEL_INFO=(${REDIS_SENTINEL_INFO[0]},${REDIS_SENTINEL_INFO[1]})"
        REDIS_MASTER_HOST=${REDIS_SENTINEL_INFO[0]}
        REDIS_MASTER_PORT_NUMBER=${REDIS_SENTINEL_INFO[1]}

        if [[ "$REDIS_MASTER_HOST" == "$(get_full_hostname "$HOSTNAME")" ]]; then
            # Case 3: Active sentinel and master it is this node --> MASTER
            info "Configuring the node as master"

use:

        # Fetches current master's host and port
        REDIS_SENTINEL_INFO=($(get_sentinel_master_info))
        info "Current master: REDIS_SENTINEL_INFO=(${REDIS_SENTINEL_INFO[0]},${REDIS_SENTINEL_INFO[1]})"
        REDIS_MASTER_HOST=${REDIS_SENTINEL_INFO[0]}
        REDIS_MASTER_PORT_NUMBER=${REDIS_SENTINEL_INFO[1]}

        if [[ "$REDIS_MASTER_HOST" == "$(get_full_hostname "$HOSTNAME")" ]] && [[ "$REDIS_MASTER_PORT_NUMBER" == "$REDISPORT" ]]; then
            # Case 3: Active sentinel and master it is this node --> MASTER
            info "Configuring the node as master"

I'll do a PR

Additional information

When installing chart with custom parameters above and not setting hard affinity rules, redis nodes than launch at the same k8s node as a master will be configuring as master, because equal values [[ "$REDIS_MASTER_HOST" == "$(get_full_hostname "$HOSTNAME")" ]]

carrodher commented 1 year ago

Thanks for creating this issue and the associated PR. The team will review it and provide feedback. Once merged the PR, this issue will be automatically closed.

github-actions[bot] commented 1 year ago

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

github-actions[bot] commented 1 year ago

Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.

AlehYarmalovich commented 1 year ago

Reopen