mirror of
https://github.com/rancher/rke.git
synced 2025-07-22 19:11:42 +00:00
Merge pull request #1965 from mrajashree/nodelister_err
Reset error to nil if lister works on retries
This commit is contained in:
commit
02a95b7cc1
@ -184,6 +184,7 @@ func (c *Cluster) UpgradeControlPlane(ctx context.Context, kubeClient *kubernete
|
|||||||
}
|
}
|
||||||
// find existing nodes that are in NotReady state
|
// find existing nodes that are in NotReady state
|
||||||
if err := services.CheckNodeReady(kubeClient, host, services.ControlRole); err != nil {
|
if err := services.CheckNodeReady(kubeClient, host, services.ControlRole); err != nil {
|
||||||
|
logrus.Debugf("Found node %v in NotReady state", host.HostnameOverride)
|
||||||
notReadyHosts = append(notReadyHosts, host)
|
notReadyHosts = append(notReadyHosts, host)
|
||||||
notReadyHostNames = append(notReadyHostNames, host.HostnameOverride)
|
notReadyHostNames = append(notReadyHostNames, host.HostnameOverride)
|
||||||
}
|
}
|
||||||
@ -285,6 +286,7 @@ func (c *Cluster) UpgradeWorkerPlane(ctx context.Context, kubeClient *kubernetes
|
|||||||
}
|
}
|
||||||
// find existing nodes that are in NotReady state
|
// find existing nodes that are in NotReady state
|
||||||
if err := services.CheckNodeReady(kubeClient, host, services.WorkerRole); err != nil {
|
if err := services.CheckNodeReady(kubeClient, host, services.WorkerRole); err != nil {
|
||||||
|
logrus.Debugf("Found node %v in NotReady state", host.HostnameOverride)
|
||||||
notReadyHosts = append(notReadyHosts, host)
|
notReadyHosts = append(notReadyHosts, host)
|
||||||
notReadyHostNames = append(notReadyHostNames, host.HostnameOverride)
|
notReadyHostNames = append(notReadyHostNames, host.HostnameOverride)
|
||||||
}
|
}
|
||||||
|
@ -41,12 +41,15 @@ func GetNodeList(k8sClient *kubernetes.Clientset) (*v1.NodeList, error) {
|
|||||||
func GetNode(k8sClient *kubernetes.Clientset, nodeName string) (*v1.Node, error) {
|
func GetNode(k8sClient *kubernetes.Clientset, nodeName string) (*v1.Node, error) {
|
||||||
var listErr error
|
var listErr error
|
||||||
for retries := 0; retries < MaxRetries; retries++ {
|
for retries := 0; retries < MaxRetries; retries++ {
|
||||||
|
logrus.Debugf("Checking node list for node %v, retry #%v", nodeName, retries)
|
||||||
nodes, err := GetNodeList(k8sClient)
|
nodes, err := GetNodeList(k8sClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
listErr = err
|
listErr = err
|
||||||
time.Sleep(time.Second * RetryInterval)
|
time.Sleep(time.Second * RetryInterval)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// reset listErr back to nil
|
||||||
|
listErr = nil
|
||||||
for _, node := range nodes.Items {
|
for _, node := range nodes.Items {
|
||||||
if strings.ToLower(node.Labels[HostnameLabel]) == strings.ToLower(nodeName) {
|
if strings.ToLower(node.Labels[HostnameLabel]) == strings.ToLower(nodeName) {
|
||||||
return &node, nil
|
return &node, nil
|
||||||
|
@ -87,7 +87,13 @@ func UpgradeControlPlaneNodes(ctx context.Context, kubeClient *kubernetes.Client
|
|||||||
logrus.Errorf("Failed to upgrade hosts: %v with error %v", strings.Join(hostsFailedToUpgrade, ","), err)
|
logrus.Errorf("Failed to upgrade hosts: %v with error %v", strings.Join(hostsFailedToUpgrade, ","), err)
|
||||||
errMsgMaxUnavailableNotFailed = fmt.Sprintf("Failed to upgrade hosts: %v with error %v", strings.Join(hostsFailedToUpgrade, ","), err)
|
errMsgMaxUnavailableNotFailed = fmt.Sprintf("Failed to upgrade hosts: %v with error %v", strings.Join(hostsFailedToUpgrade, ","), err)
|
||||||
}
|
}
|
||||||
return errMsgMaxUnavailableNotFailed, util.ErrList([]error{err, inactiveHostErr})
|
var errors []error
|
||||||
|
for _, e := range []error{err, inactiveHostErr} {
|
||||||
|
if e != nil {
|
||||||
|
errors = append(errors, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return errMsgMaxUnavailableNotFailed, util.ErrList(errors)
|
||||||
}
|
}
|
||||||
log.Infof(ctx, "[%s] Successfully upgraded Controller Plane..", ControlRole)
|
log.Infof(ctx, "[%s] Successfully upgraded Controller Plane..", ControlRole)
|
||||||
return errMsgMaxUnavailableNotFailed, nil
|
return errMsgMaxUnavailableNotFailed, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user