Merge pull request #105095 from wojtek-t/migrate_clock_3

Unify towards k8s.io/utils/clock - part 3

Kubernetes-commit: 353f0a5eabe4bd8d31bb67275ee4beeb4655be3f
This commit is contained in:
Kubernetes Publisher 2021-09-20 12:46:45 -07:00
commit 191e5dc23b
10 changed files with 19 additions and 17 deletions

4
go.mod
View File

@ -31,7 +31,7 @@ require (
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac
google.golang.org/protobuf v1.26.0
k8s.io/api v0.0.0-20210917114730-87c4113e35a1
k8s.io/apimachinery v0.0.0-20210917114042-f7f8dd8e6c3d
k8s.io/apimachinery v0.0.0-20210920194645-86c0c0f8c8e2
k8s.io/klog/v2 v2.20.0
k8s.io/kube-openapi v0.0.0-20210817084001-7fbd8d59e5b8
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a
@ -41,5 +41,5 @@ require (
replace (
k8s.io/api => k8s.io/api v0.0.0-20210917114730-87c4113e35a1
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20210917114042-f7f8dd8e6c3d
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20210920194645-86c0c0f8c8e2
)

4
go.sum
View File

@ -601,8 +601,8 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
k8s.io/api v0.0.0-20210917114730-87c4113e35a1 h1:c5smJttDF8/Ols66NZM4olxSwIEa3p0fklSgV9WA9K8=
k8s.io/api v0.0.0-20210917114730-87c4113e35a1/go.mod h1:NPiqbLN26Y6vkL9V/SbA6NtBMKgFkdVKnh5Drj9GgMo=
k8s.io/apimachinery v0.0.0-20210917114042-f7f8dd8e6c3d h1:rzQUQhOqvkyS9IyueD34dF0WoXiIJ0gANDzmxLS1kJ8=
k8s.io/apimachinery v0.0.0-20210917114042-f7f8dd8e6c3d/go.mod h1:CimYO7ypGwnQeTeoJQ8Jht0OVH2glTFHGy7xEhLj3sk=
k8s.io/apimachinery v0.0.0-20210920194645-86c0c0f8c8e2 h1:MdB81XVh3V0ZnRKsg6KRpVSH90nw2XjN9JcK9NIWY7Q=
k8s.io/apimachinery v0.0.0-20210920194645-86c0c0f8c8e2/go.mod h1:CimYO7ypGwnQeTeoJQ8Jht0OVH2glTFHGy7xEhLj3sk=
k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
k8s.io/klog/v2 v2.20.0 h1:tlyxlSvd63k7axjhuchckaRJm+a92z5GSOrTOQY5sHw=

View File

@ -21,9 +21,9 @@ import (
"time"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/clock"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/utils/clock"
)
// This file implements a low-level controller that is used in

View File

@ -20,8 +20,8 @@ import (
"sync"
"time"
"k8s.io/apimachinery/pkg/util/clock"
"k8s.io/klog/v2"
"k8s.io/utils/clock"
)
// ExpirationCache implements the store interface

View File

@ -17,8 +17,8 @@ limitations under the License.
package cache
import (
"k8s.io/apimachinery/pkg/util/clock"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/utils/clock"
)
type fakeThreadSafeMap struct {

View File

@ -21,9 +21,10 @@ import (
"testing"
"time"
"k8s.io/apimachinery/pkg/util/clock"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/utils/clock"
testingclock "k8s.io/utils/clock/testing"
)
func TestTTLExpirationBasic(t *testing.T) {
@ -167,7 +168,7 @@ func TestTTLPolicy(t *testing.T) {
exactlyOnTTL := fakeTime.Add(-ttl)
expiredTime := fakeTime.Add(-(ttl + 1))
policy := TTLPolicy{ttl, clock.NewFakeClock(fakeTime)}
policy := TTLPolicy{ttl, testingclock.NewFakeClock(fakeTime)}
item := testStoreObject{id: "foo", val: "bar"}
itemkey, _ := testStoreKeyFunc(item)
fakeTimestampedEntry := &TimestampedEntry{Obj: item, Timestamp: exactlyOnTTL, key: itemkey}

View File

@ -32,7 +32,6 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/clock"
"k8s.io/apimachinery/pkg/util/naming"
utilnet "k8s.io/apimachinery/pkg/util/net"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@ -40,6 +39,7 @@ import (
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/pager"
"k8s.io/klog/v2"
"k8s.io/utils/clock"
"k8s.io/utils/trace"
)

View File

@ -32,9 +32,10 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/clock"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/utils/clock"
testingclock "k8s.io/utils/clock/testing"
)
var nevererrc chan error
@ -376,7 +377,7 @@ func TestReflectorListAndWatchInitConnBackoff(t *testing.T) {
func(t *testing.T) {
stopCh := make(chan struct{})
connFails := test.numConnFails
fakeClock := clock.NewFakeClock(time.Unix(0, 0))
fakeClock := testingclock.NewFakeClock(time.Unix(0, 0))
bm := wait.NewExponentialBackoffManager(time.Millisecond, maxBackoff, 100*time.Millisecond, 2.0, 1.0, fakeClock)
done := make(chan struct{})
defer close(done)

View File

@ -23,10 +23,10 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/clock"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/utils/buffer"
"k8s.io/utils/clock"
"k8s.io/klog/v2"
)

View File

@ -26,10 +26,10 @@ import (
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/clock"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait"
fcache "k8s.io/client-go/tools/cache/testing"
testingclock "k8s.io/utils/clock/testing"
)
type testListener struct {
@ -105,7 +105,7 @@ func TestListenerResyncPeriods(t *testing.T) {
// create the shared informer and resync every 1s
informer := NewSharedInformer(source, &v1.Pod{}, 1*time.Second).(*sharedIndexInformer)
clock := clock.NewFakeClock(time.Now())
clock := testingclock.NewFakeClock(time.Now())
informer.clock = clock
informer.processor.clock = clock
@ -190,7 +190,7 @@ func TestResyncCheckPeriod(t *testing.T) {
// create the shared informer and resync every 12 hours
informer := NewSharedInformer(source, &v1.Pod{}, 12*time.Hour).(*sharedIndexInformer)
clock := clock.NewFakeClock(time.Now())
clock := testingclock.NewFakeClock(time.Now())
informer.clock = clock
informer.processor.clock = clock
@ -278,7 +278,7 @@ func TestSharedInformerWatchDisruption(t *testing.T) {
// create the shared informer and resync every 1s
informer := NewSharedInformer(source, &v1.Pod{}, 1*time.Second).(*sharedIndexInformer)
clock := clock.NewFakeClock(time.Now())
clock := testingclock.NewFakeClock(time.Now())
informer.clock = clock
informer.processor.clock = clock