Merge "SDL CLI command to generate sdlcli shell completion file for bash"
[ric-plt/sdlgo.git] / internal / sdlgoredis / sdlgosentinel.go
index f439570..ac56322 100644 (file)
@@ -23,7 +23,9 @@
 package sdlgoredis
 
 import (
+       "fmt"
        "github.com/go-redis/redis/v7"
+       "strconv"
 )
 
 type Sentinel struct {
@@ -61,6 +63,14 @@ func (s *Sentinel) GetDbState() (*DbState, error) {
        state.PrimaryDbState = *pState
        state.ReplicasDbState = rState
        state.SentinelsDbState = sState
+
+       cnt, err := strconv.Atoi(s.Cfg.nodeCnt)
+       if err != nil {
+               state.Err = fmt.Errorf("Sentinel DBAAS_NODE_COUNT configuration value '%s' conversion to integer failed", s.Cfg.nodeCnt)
+               return state, state.Err
+       }
+       state.ConfigNodeCnt = cnt
+
        if pErr != nil {
                return state, pErr
        }
@@ -124,7 +134,11 @@ func (s *Sentinel) getSentinelsState() (*SentinelsDbState, error) {
        if redisErr == nil {
                for _, redisSentinel := range redisVal {
                        sentinelState := readSentinelState(redisSentinel.([]interface{}))
-                       states.States = append(states.States, sentinelState)
+                       // Ignore a sentinel entry with zero port, because missing of fix
+                       // for the Redis Bug #9240.
+                       if sentinelState.Fields.Port != "0" {
+                               states.States = append(states.States, sentinelState)
+                       }
                }
        }
        states.Err = redisErr