@@ -89,8 +89,8 @@ func CheckNodesDown(client *opensearch.Client, logger *logging.Logger, checkEnab
8989 }
9090
9191 nodeCount := len (allocation )
92- var nodePrefixes []string
93- prefixSet := make (map [string ]bool )
92+ var stsBaseNames []string
93+ baseNameSet := make (map [string ]bool )
9494 var invalidNodeNames []string
9595
9696 re := regexp .MustCompile (`-\d+$` )
@@ -101,10 +101,10 @@ func CheckNodesDown(client *opensearch.Client, logger *logging.Logger, checkEnab
101101 invalidNodeNames = append (invalidNodeNames , nodeName )
102102 }
103103
104- prefix := re .ReplaceAllString (nodeName , "" )
105- if ! prefixSet [ prefix ] {
106- prefixSet [ prefix ] = true
107- nodePrefixes = append (nodePrefixes , prefix )
104+ baseName := re .ReplaceAllString (nodeName , "" )
105+ if ! baseNameSet [ baseName ] {
106+ baseNameSet [ baseName ] = true
107+ stsBaseNames = append (stsBaseNames , baseName )
108108 }
109109 }
110110
@@ -114,7 +114,7 @@ func CheckNodesDown(client *opensearch.Client, logger *logging.Logger, checkEnab
114114
115115 if showDetails {
116116 logger .Info (fmt .Sprintf ("Nodes in cluster: %d" , nodeCount ))
117- logger .Info (fmt .Sprintf ("Node prefixes found: %s" , strings .Join (nodePrefixes , ", " )))
117+ logger .Info (fmt .Sprintf ("StatefulSet base names found: %s" , strings .Join (stsBaseNames , ", " )))
118118 }
119119
120120 rc , err := rest .InClusterConfig ()
@@ -137,8 +137,8 @@ func CheckNodesDown(client *opensearch.Client, logger *logging.Logger, checkEnab
137137 var matchingSts []string
138138
139139 for _ , sts := range stsList .Items {
140- for _ , prefix := range nodePrefixes {
141- if strings . HasPrefix ( sts .Name , prefix ) || strings . Contains ( sts . Name , prefix ) {
140+ for _ , baseName := range stsBaseNames {
141+ if sts .Name == baseName {
142142 replicas := int (* sts .Spec .Replicas )
143143 totalReplicas += replicas
144144 matchingSts = append (matchingSts , fmt .Sprintf ("%s (replicas=%d)" , sts .Name , replicas ))
@@ -152,7 +152,7 @@ func CheckNodesDown(client *opensearch.Client, logger *logging.Logger, checkEnab
152152 logger .Info (fmt .Sprintf ("StatefulSets found: %s" , strings .Join (matchingSts , ", " )))
153153 logger .Info (fmt .Sprintf ("Total replicas in StatefulSets: %d" , totalReplicas ))
154154 } else {
155- logger .Warn ("No matching StatefulSets found for node prefixes " )
155+ logger .Warn ("No matching StatefulSets found for node base names " )
156156 }
157157 logger .Info (fmt .Sprintf ("Nodes in cluster: %d, Expected replicas: %d, Difference: %d" , nodeCount , totalReplicas , totalReplicas - nodeCount ))
158158 }
0 commit comments