$ go run main.go
2018/05/31 13:37:05 watch.Util returned err=&errors.errorString{s:"timed out waiting for the condition"}
2018/05/31 13:37:05 RetryOnConflict returned err=<nil>
Created
May 31, 2018 10:37
-
-
Save SpComb/44c7663bd78b3d3ba61622d3d0dd399a to your computer and use it in GitHub Desktop.
util/retry RetryOnConflict returns nil err if fn returns wait.ErrWaitTimeout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"time" | |
"k8s.io/apimachinery/pkg/watch" | |
"k8s.io/client-go/util/retry" | |
) | |
func main() { | |
var watcher = watch.NewFake() | |
var timeout = 100 * time.Millisecond | |
err := retry.RetryOnConflict(retry.DefaultBackoff, func() error { | |
if ev, err := watch.Until(timeout, watcher, func(event watch.Event) (bool, error) { return false, nil }); err != nil { | |
log.Printf("watch.Util returned err=%#v", err) | |
return err | |
} else { | |
log.Printf("watch.Until returned ev=%#v", ev) | |
return nil | |
} | |
}) | |
log.Printf("RetryOnConflict returned err=%#v", err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment