daemon: Restart watch on ErrWatchClosed
@@ -49,14 +49,23 @@ func waitUntilUpdate(client corev1.NodeInterface, node string) error {
return nil
}
+ // Loop over watches to ensure that if the watch is closed before changes we
+ // start up a new watch.
+ // See: https://github.com/openshift/machine-config-operator/issues/68
+ for {
// for now, we wait forever. that might not be the best long-term strategy.
- _, err = watch.Until(0, watcher, updateWatcher)
- if err != nil {
+ if _, err := watch.Until(0, watcher, updateWatcher); err != nil {
+ // if the watch was closed, watch again
+ if err == watch.ErrWatchClosed {
+ continue
+ }
+ // any other error should return
return fmt.Errorf("Failed to watch for update request: %v", err)
}
-
+ // no error received so none returned
return nil
}
+}
// setConfig sets the given annotation key, value pair.
func setNodeAnnotations(client corev1.NodeInterface, node string, m map[string]string) error {
