Skip to content

Commit

Permalink
Merge pull request #416 from runcom/check-err-wait
Browse files Browse the repository at this point in the history
pkg/daemon/update.go: check wait err and wrap it
  • Loading branch information
openshift-merge-robot authored Feb 15, 2019
2 parents e4d3b48 + 87b6c2d commit fe2d179
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions pkg/daemon/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,25 @@ func (dn *Daemon) updateOSAndReboot(newConfig *mcfgv1.MachineConfig) error {
Factor: 2,
}
var lastErr error
wait.ExponentialBackoff(backoff, func() (bool, error) {
if err := wait.ExponentialBackoff(backoff, func() (bool, error) {
err := drain.Drain(dn.kubeClient, []*corev1.Node{node}, &drain.DrainOptions{
DeleteLocalData: true,
Force: true,
GracePeriodSeconds: 600,
IgnoreDaemonsets: true,
})
if err != nil {
glog.Infof("Draining failed with: %v; retrying...", err)
lastErr = err
return false, nil
if err == nil {
return true, nil
}
lastErr = err
glog.Infof("Draining failed with: %v, retrying", err)
return false, nil

}); err != nil {
if err == wait.ErrWaitTimeout {
return errors.Wrapf(lastErr, "failed to drain node (%d tries): %v", backoff.Steps, err)
}
lastErr = nil
return true, nil
})
if lastErr != nil {
return errors.Wrapf(lastErr, "Failed to drain node (%d tries)", backoff.Steps)
return errors.Wrap(err, "failed to drain node")
}
glog.V(2).Info("Node successfully drained")
}
Expand Down

0 comments on commit fe2d179

Please sign in to comment.