diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 033c3524..582eaa38 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -352,7 +352,7 @@ }, { "ImportPath": "k8s.io/apimachinery", - "Rev": "b3b82f771b5e" + "Rev": "85fcb0190bbf" }, { "ImportPath": "k8s.io/gengo", diff --git a/go.mod b/go.mod index be6ded50..15ddc8eb 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( golang.org/x/time v0.0.0-20191024005414-555d28b269f0 google.golang.org/appengine v1.5.0 // indirect k8s.io/api v0.0.0-20200509162017-b6206047d210 - k8s.io/apimachinery v0.0.0-20200510130550-b3b82f771b5e + k8s.io/apimachinery v0.0.0-20200511201828-85fcb0190bbf k8s.io/klog v1.0.0 k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 sigs.k8s.io/yaml v1.2.0 @@ -39,5 +39,5 @@ replace ( golang.org/x/sys => golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a // pinned to release-branch.go1.13 golang.org/x/tools => golang.org/x/tools v0.0.0-20190821162956-65e3620a7ae7 // pinned to release-branch.go1.13 k8s.io/api => k8s.io/api v0.0.0-20200509162017-b6206047d210 - k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20200510130550-b3b82f771b5e + k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20200511201828-85fcb0190bbf ) diff --git a/go.sum b/go.sum index aa61c902..66681484 100644 --- a/go.sum +++ b/go.sum @@ -190,7 +190,7 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/api v0.0.0-20200509162017-b6206047d210/go.mod h1:raky3QQIV2+BF6omFznvh5TLtBeHdXVNLZPfX9Jc9SM= -k8s.io/apimachinery v0.0.0-20200510130550-b3b82f771b5e/go.mod h1:imoz42hIYwpLTRWXU8pdJ9IE8DbxUsnU9lyVN8Y1SNo= +k8s.io/apimachinery v0.0.0-20200511201828-85fcb0190bbf/go.mod h1:imoz42hIYwpLTRWXU8pdJ9IE8DbxUsnU9lyVN8Y1SNo= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= diff --git a/tools/watch/until.go b/tools/watch/until.go index e12d82ac..37a46da4 100644 --- a/tools/watch/until.go +++ b/tools/watch/until.go @@ -22,8 +22,6 @@ import ( "fmt" "time" - "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/watch" @@ -167,70 +165,3 @@ func ContextWithOptionalTimeout(parent context.Context, timeout time.Duration) ( return context.WithTimeout(parent, timeout) } - -// ListWatchUntil first lists objects, converts them into synthetic ADDED events -// and checks conditions for those synthetic events. If the conditions have not been reached so far -// it continues by calling Until which establishes a watch from resourceVersion of the list call -// to evaluate those conditions based on new events. -// ListWatchUntil provides the same guarantees as Until and replaces the old WATCH from RV "" (or "0") -// which was mixing list and watch calls internally and having severe design issues. (see #74022) -// There is no resourceVersion order guarantee for the initial list and those synthetic events. -func ListWatchUntil(ctx context.Context, lw cache.ListerWatcher, conditions ...ConditionFunc) (*watch.Event, error) { - if len(conditions) == 0 { - return nil, nil - } - - list, err := lw.List(metav1.ListOptions{}) - if err != nil { - return nil, err - } - initialItems, err := meta.ExtractList(list) - if err != nil { - return nil, err - } - - // use the initial items as simulated "adds" - var lastEvent *watch.Event - currIndex := 0 - passedConditions := 0 - for _, condition := range conditions { - // check the next condition against the previous event and short circuit waiting for the next watch - if lastEvent != nil { - done, err := condition(*lastEvent) - if err != nil { - return lastEvent, err - } - if done { - passedConditions = passedConditions + 1 - continue - } - } - - ConditionSucceeded: - for currIndex < len(initialItems) { - lastEvent = &watch.Event{Type: watch.Added, Object: initialItems[currIndex]} - currIndex++ - - done, err := condition(*lastEvent) - if err != nil { - return lastEvent, err - } - if done { - passedConditions = passedConditions + 1 - break ConditionSucceeded - } - } - } - if passedConditions == len(conditions) { - return lastEvent, nil - } - remainingConditions := conditions[passedConditions:] - - metaObj, err := meta.ListAccessor(list) - if err != nil { - return nil, err - } - currResourceVersion := metaObj.GetResourceVersion() - - return Until(ctx, currResourceVersion, lw, remainingConditions...) -}