Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions pkg/daemon/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,28 @@ func (dn *Daemon) updateOSAndReboot(newConfig *mcfgv1.MachineConfig) error {

dn.recorder.Eventf(node, corev1.EventTypeNormal, "Drain", "Draining node to update config.")

err = wait.ExponentialBackoff(wait.Backoff{
backoff := wait.Backoff{
Steps: 5,
Duration: 10 * time.Second,
Factor: 2,
}, func() (bool, error) {
}
var lastErr error
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keep the logging here to show some progress if we're retrying?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up for this in #412!

lastErr = err
return false, nil
}
lastErr = nil
return true, nil
})
if err != nil {
return err
if lastErr != nil {
return errors.Wrapf(lastErr, "Failed to drain node (%s tries)", backoff.Steps)
}
Copy link
Member

@runcom runcom Feb 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're gonna miss the wait.* error this way cause other err may happen other than just timeout if someone, someday adds another err case which return a real err:

// If the condition never returns true, ErrWaitTimeout is returned. All other
// errors terminate immediately.
func ExponentialBackoff(backoff Backoff, condition ConditionFunc) error {

I was thinking something like https://github.com/openshift/machine-config-operator/blob/master/pkg/operator/sync.go#L357-L362

Copy link
Member

@runcom runcom Feb 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not blocking of course, we control the ConditionFunc here today but if someone jumps and add a return false, err, we're gonna miss it, just to have the same pattern

glog.V(2).Info("Node successfully drained")
}
Expand Down