Error getting node in setEtcdStatusCondition

Signed-off-by: Vitor Savian <vitor.savian@suse.com>

Added retry and changed nodes for

Signed-off-by: Vitor Savian <vitor.savian@suse.com>
pull/9235/head
Vitor Savian 2024-01-10 16:37:56 -03:00
parent c87e6e5f7e
commit 9a70021a9e
1 changed files with 20 additions and 19 deletions

View File

@ -1086,40 +1086,41 @@ func (e *ETCD) manageLearners(ctx context.Context) {
} }
for _, member := range members.Members { for _, member := range members.Members {
var node *v1.Node status := StatusVoter
for _, node = range nodes { message := ""
if strings.HasPrefix(member.Name, node.Name+"-") {
nodeIsMember[node.Name] = true
}
}
if member.IsLearner { if member.IsLearner {
status = StatusLearner
if err := e.trackLearnerProgress(ctx, progress, member); err != nil { if err := e.trackLearnerProgress(ctx, progress, member); err != nil {
logrus.Errorf("Failed to track learner progress towards promotion: %v", err) logrus.Errorf("Failed to track learner progress towards promotion: %v", err)
} }
if err := e.setEtcdStatusCondition(node, client, member.Name, StatusLearner, ""); err != nil {
logrus.Errorf("Unable to set etcd status condition %s: %v", member.Name, err)
}
break
} }
// verify if the member is healthy and set the etcd status condition var node *v1.Node
if _, err := e.getETCDStatus(ctx, member.ClientURLs[0]); err != nil { for _, n := range nodes {
if err := e.setEtcdStatusCondition(node, client, member.Name, StatusUnhealthy, err.Error()); err != nil { if strings.HasPrefix(member.Name, n.Name+"-") {
logrus.Errorf("Unable to set etcd status condition for unhealthy node %s: %v", member.Name, err) node = n
nodeIsMember[n.Name] = true
break
} }
}
if node == nil {
continue continue
} }
if err := e.setEtcdStatusCondition(node, client, member.Name, StatusVoter, ""); err != nil { // verify if the member is healthy and set the status
if _, err := e.getETCDStatus(ctx, member.ClientURLs[0]); err != nil {
message = err.Error()
status = StatusUnhealthy
}
if err := e.setEtcdStatusCondition(node, client, member.Name, status, message); err != nil {
logrus.Errorf("Unable to set etcd status condition %s: %v", member.Name, err) logrus.Errorf("Unable to set etcd status condition %s: %v", member.Name, err)
} }
} }
for nodeName, isMember := range nodeIsMember { for nodeName, node := range nodesMap {
if !isMember { if !nodeIsMember[nodeName] {
node := nodesMap[nodeName]
if err := e.setEtcdStatusCondition(node, client, nodeName, StatusUnjoined, ""); err != nil { if err := e.setEtcdStatusCondition(node, client, nodeName, StatusUnjoined, ""); err != nil {
logrus.Errorf("Unable to set etcd status condition for a node that is not a cluster member %s: %v", nodeName, err) logrus.Errorf("Unable to set etcd status condition for a node that is not a cluster member %s: %v", nodeName, err)
} }