mirror of https://github.com/k3s-io/k3s
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
parent
c87e6e5f7e
commit
9a70021a9e
|
@ -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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var node *v1.Node
|
||||||
|
for _, n := range nodes {
|
||||||
|
if strings.HasPrefix(member.Name, n.Name+"-") {
|
||||||
|
node = n
|
||||||
|
nodeIsMember[n.Name] = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify if the member is healthy and set the etcd status condition
|
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue