Skip to content

Commit

Permalink
Error getting node in setEtcdStatusCondition
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Savian <[email protected]>

Added retry and changed nodes for

Signed-off-by: Vitor Savian <[email protected]>
  • Loading branch information
vitorsavian committed Jan 12, 2024
1 parent c87e6e5 commit 9a70021
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions pkg/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -1086,40 +1086,41 @@ func (e *ETCD) manageLearners(ctx context.Context) {
}

for _, member := range members.Members {
var node *v1.Node
for _, node = range nodes {
if strings.HasPrefix(member.Name, node.Name+"-") {
nodeIsMember[node.Name] = true
}
}
status := StatusVoter
message := ""

if member.IsLearner {
status = StatusLearner
if err := e.trackLearnerProgress(ctx, progress, member); err != nil {
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)
var node *v1.Node
for _, n := range nodes {
if strings.HasPrefix(member.Name, n.Name+"-") {
node = n
nodeIsMember[n.Name] = true
break
}
break
}
if node == nil {
continue
}

// verify if the member is healthy and set the etcd status condition
// verify if the member is healthy and set the status
if _, err := e.getETCDStatus(ctx, member.ClientURLs[0]); err != nil {
if err := e.setEtcdStatusCondition(node, client, member.Name, StatusUnhealthy, err.Error()); err != nil {
logrus.Errorf("Unable to set etcd status condition for unhealthy node %s: %v", member.Name, err)
}
continue
message = err.Error()
status = StatusUnhealthy
}

if err := e.setEtcdStatusCondition(node, client, member.Name, StatusVoter, ""); err != nil {
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)
}
}

for nodeName, isMember := range nodeIsMember {
if !isMember {
node := nodesMap[nodeName]
for nodeName, node := range nodesMap {
if !nodeIsMember[nodeName] {
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)
}
Expand Down

0 comments on commit 9a70021

Please sign in to comment.