1
0
mirror of https://github.com/rancher/rke.git synced 2025-07-23 03:22:27 +00:00

Merge pull request #1965 from mrajashree/nodelister_err

Reset error to nil if lister works on retries
This commit is contained in:
Rajashree Mandaogane 2020-03-13 15:58:33 -07:00 committed by GitHub
commit 02a95b7cc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -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)
} }

View File

@ -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

View File

@ -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