diff --git a/staging/publishing/import-restrictions.yaml b/staging/publishing/import-restrictions.yaml index 4c77396c28a..ee437f47c51 100644 --- a/staging/publishing/import-restrictions.yaml +++ b/staging/publishing/import-restrictions.yaml @@ -35,6 +35,7 @@ allowedImports: - k8s.io/apimachinery - k8s.io/kube-openapi + - k8s.io/utils/clock - k8s.io/utils/net - k8s.io/klog @@ -79,6 +80,7 @@ - k8s.io/apimachinery - k8s.io/client-go - k8s.io/klog + - k8s.io/utils - baseImportPath: "./vendor/k8s.io/client-go/tools/" excludeTests: true ignoredSubTrees: diff --git a/staging/src/k8s.io/apimachinery/pkg/util/cache/expiring.go b/staging/src/k8s.io/apimachinery/pkg/util/cache/expiring.go index faf2c264538..0d2f153bf9e 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/cache/expiring.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/cache/expiring.go @@ -21,17 +21,17 @@ import ( "sync" "time" - utilclock "k8s.io/apimachinery/pkg/util/clock" + "k8s.io/utils/clock" ) // NewExpiring returns an initialized expiring cache. func NewExpiring() *Expiring { - return NewExpiringWithClock(utilclock.RealClock{}) + return NewExpiringWithClock(clock.RealClock{}) } // NewExpiringWithClock is like NewExpiring but allows passing in a custom // clock for testing. -func NewExpiringWithClock(clock utilclock.Clock) *Expiring { +func NewExpiringWithClock(clock clock.Clock) *Expiring { return &Expiring{ clock: clock, cache: make(map[interface{}]entry), @@ -40,7 +40,7 @@ func NewExpiringWithClock(clock utilclock.Clock) *Expiring { // Expiring is a map whose entries expire after a per-entry timeout. type Expiring struct { - clock utilclock.Clock + clock clock.Clock // mu protects the below fields mu sync.RWMutex diff --git a/staging/src/k8s.io/apimachinery/pkg/util/cache/expiring_test.go b/staging/src/k8s.io/apimachinery/pkg/util/cache/expiring_test.go index 53f8707651a..6d45be6365a 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/cache/expiring_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/cache/expiring_test.go @@ -25,7 +25,7 @@ import ( "github.com/google/uuid" - utilclock "k8s.io/apimachinery/pkg/util/clock" + testingclock "k8s.io/utils/clock/testing" ) func TestExpiringCache(t *testing.T) { @@ -58,7 +58,7 @@ func TestExpiringCache(t *testing.T) { } func TestExpiration(t *testing.T) { - fc := &utilclock.FakeClock{} + fc := &testingclock.FakeClock{} c := NewExpiringWithClock(fc) c.Set("a", "a", time.Second) @@ -104,7 +104,7 @@ func TestExpiration(t *testing.T) { } func TestGarbageCollection(t *testing.T) { - fc := &utilclock.FakeClock{} + fc := &testingclock.FakeClock{} type entry struct { key, val string diff --git a/staging/src/k8s.io/apimachinery/pkg/util/cache/lruexpirecache_test.go b/staging/src/k8s.io/apimachinery/pkg/util/cache/lruexpirecache_test.go index bfafe87b13f..f1de853efe1 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/cache/lruexpirecache_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/cache/lruexpirecache_test.go @@ -21,7 +21,7 @@ import ( "time" "github.com/google/go-cmp/cmp" - "k8s.io/apimachinery/pkg/util/clock" + testingclock "k8s.io/utils/clock/testing" ) func expectEntry(t *testing.T, c *LRUExpireCache, key interface{}, value interface{}) { @@ -68,7 +68,7 @@ func TestSimpleRemove(t *testing.T) { } func TestExpiredGet(t *testing.T) { - fakeClock := clock.NewFakeClock(time.Now()) + fakeClock := testingclock.NewFakeClock(time.Now()) c := NewLRUExpireCacheWithClock(10, fakeClock) c.Add("short-lived", "12345", 1*time.Millisecond) // ensure the entry expired diff --git a/staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle/admission.go b/staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle/admission.go index c417e3f98ae..936a95e45cc 100644 --- a/staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle/admission.go +++ b/staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle/admission.go @@ -29,13 +29,13 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" utilcache "k8s.io/apimachinery/pkg/util/cache" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apiserver/pkg/admission" "k8s.io/apiserver/pkg/admission/initializer" "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes" corelisters "k8s.io/client-go/listers/core/v1" + "k8s.io/utils/clock" ) const ( diff --git a/staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle/admission_test.go b/staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle/admission_test.go index 71b1edf6d8b..e0131538db1 100644 --- a/staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle/admission_test.go +++ b/staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle/admission_test.go @@ -28,7 +28,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/diff" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/wait" @@ -38,6 +37,8 @@ import ( clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/fake" core "k8s.io/client-go/testing" + "k8s.io/utils/clock" + testingclock "k8s.io/utils/clock/testing" ) // newHandlerForTest returns a configured handler for testing. @@ -240,7 +241,7 @@ func TestAdmissionNamespaceForceLiveLookup(t *testing.T) { return true, &v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: namespace}, Status: v1.NamespaceStatus{Phase: phases[namespace]}}, nil }) - fakeClock := clock.NewFakeClock(time.Now()) + fakeClock := testingclock.NewFakeClock(time.Now()) handler, informerFactory, err := newHandlerForTestWithClock(mockClient, fakeClock) if err != nil { diff --git a/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cache_simple.go b/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cache_simple.go index 8e0520af169..a2c5ce680b1 100644 --- a/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cache_simple.go +++ b/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cache_simple.go @@ -20,7 +20,7 @@ import ( "time" utilcache "k8s.io/apimachinery/pkg/util/cache" - "k8s.io/apimachinery/pkg/util/clock" + "k8s.io/utils/clock" ) type simpleCache struct { diff --git a/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cache_test.go b/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cache_test.go index bd0457ac6ca..774d659749d 100644 --- a/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cache_test.go +++ b/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cache_test.go @@ -24,9 +24,9 @@ import ( "github.com/google/uuid" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apiserver/pkg/authentication/authenticator" "k8s.io/apiserver/pkg/authentication/user" + "k8s.io/utils/clock" ) func TestSimpleCache(t *testing.T) { diff --git a/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cached_token_authenticator.go b/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cached_token_authenticator.go index b0d06a23183..afd990f7184 100644 --- a/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cached_token_authenticator.go +++ b/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cached_token_authenticator.go @@ -33,12 +33,12 @@ import ( "golang.org/x/sync/singleflight" apierrors "k8s.io/apimachinery/pkg/api/errors" - utilclock "k8s.io/apimachinery/pkg/util/clock" auditinternal "k8s.io/apiserver/pkg/apis/audit" "k8s.io/apiserver/pkg/audit" "k8s.io/apiserver/pkg/authentication/authenticator" "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/klog/v2" + "k8s.io/utils/clock" ) var errAuthnCrash = apierrors.NewInternalError(errors.New("authentication failed unexpectedly")) @@ -89,10 +89,10 @@ type cache interface { // New returns a token authenticator that caches the results of the specified authenticator. A ttl of 0 bypasses the cache. func New(authenticator authenticator.Token, cacheErrs bool, successTTL, failureTTL time.Duration) authenticator.Token { - return newWithClock(authenticator, cacheErrs, successTTL, failureTTL, utilclock.RealClock{}) + return newWithClock(authenticator, cacheErrs, successTTL, failureTTL, clock.RealClock{}) } -func newWithClock(authenticator authenticator.Token, cacheErrs bool, successTTL, failureTTL time.Duration, clock utilclock.Clock) authenticator.Token { +func newWithClock(authenticator authenticator.Token, cacheErrs bool, successTTL, failureTTL time.Duration, clock clock.Clock) authenticator.Token { randomCacheKey := make([]byte, 32) if _, err := rand.Read(randomCacheKey); err != nil { panic(err) // rand should never fail diff --git a/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cached_token_authenticator_test.go b/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cached_token_authenticator_test.go index ed3abfc1d1f..80ef78ec9d1 100644 --- a/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cached_token_authenticator_test.go +++ b/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cached_token_authenticator_test.go @@ -31,13 +31,14 @@ import ( "time" "github.com/google/go-cmp/cmp" - utilclock "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/uuid" auditinternal "k8s.io/apiserver/pkg/apis/audit" "k8s.io/apiserver/pkg/audit" "k8s.io/apiserver/pkg/authentication/authenticator" "k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/endpoints/request" + "k8s.io/utils/clock" + testingclock "k8s.io/utils/clock/testing" ) func TestCachedTokenAuthenticator(t *testing.T) { @@ -52,7 +53,7 @@ func TestCachedTokenAuthenticator(t *testing.T) { calledWithToken = append(calledWithToken, token) return &authenticator.Response{User: resultUsers[token]}, resultOk, resultErr }) - fakeClock := utilclock.NewFakeClock(time.Now()) + fakeClock := testingclock.NewFakeClock(time.Now()) a := newWithClock(fakeAuth, true, time.Minute, 0, fakeClock) @@ -126,7 +127,7 @@ func TestCachedTokenAuthenticatorWithAudiences(t *testing.T) { auds, _ := authenticator.AudiencesFrom(ctx) return &authenticator.Response{User: resultUsers[auds[0]+token]}, true, nil }) - fakeClock := utilclock.NewFakeClock(time.Now()) + fakeClock := testingclock.NewFakeClock(time.Now()) a := newWithClock(fakeAuth, true, time.Minute, 0, fakeClock) @@ -546,7 +547,7 @@ func (s *singleBenchmark) bench(b *testing.B) { true, 4*time.Second, 500*time.Millisecond, - utilclock.RealClock{}, + clock.RealClock{}, ) b.ResetTimer() diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/filterlatency/filterlatency.go b/staging/src/k8s.io/apiserver/pkg/endpoints/filterlatency/filterlatency.go index 672bb7ad398..40e32a1a190 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/filterlatency/filterlatency.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/filterlatency/filterlatency.go @@ -22,11 +22,11 @@ import ( "net/http" "time" - utilclock "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apiserver/pkg/endpoints/metrics" apirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/server/httplog" "k8s.io/klog/v2" + "k8s.io/utils/clock" ) type requestFilterRecordKeyType int @@ -55,13 +55,13 @@ func requestFilterRecordFrom(ctx context.Context) *requestFilterRecord { // TrackStarted measures the timestamp the given handler has started execution // by attaching a handler to the chain. func TrackStarted(handler http.Handler, name string) http.Handler { - return trackStarted(handler, name, utilclock.RealClock{}) + return trackStarted(handler, name, clock.RealClock{}) } // TrackCompleted measures the timestamp the given handler has completed execution and then // it updates the corresponding metric with the filter latency duration. func TrackCompleted(handler http.Handler) http.Handler { - return trackCompleted(handler, utilclock.RealClock{}, func(ctx context.Context, fr *requestFilterRecord, completedAt time.Time) { + return trackCompleted(handler, clock.RealClock{}, func(ctx context.Context, fr *requestFilterRecord, completedAt time.Time) { latency := completedAt.Sub(fr.startedTimestamp) metrics.RecordFilterLatency(ctx, fr.name, latency) if klog.V(3).Enabled() && latency > minFilterLatencyToLog { @@ -70,7 +70,7 @@ func TrackCompleted(handler http.Handler) http.Handler { }) } -func trackStarted(handler http.Handler, name string, clock utilclock.PassiveClock) http.Handler { +func trackStarted(handler http.Handler, name string, clock clock.PassiveClock) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() if fr := requestFilterRecordFrom(ctx); fr != nil { @@ -90,7 +90,7 @@ func trackStarted(handler http.Handler, name string, clock utilclock.PassiveCloc }) } -func trackCompleted(handler http.Handler, clock utilclock.PassiveClock, action func(context.Context, *requestFilterRecord, time.Time)) http.Handler { +func trackCompleted(handler http.Handler, clock clock.PassiveClock, action func(context.Context, *requestFilterRecord, time.Time)) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // The previous filter has just completed. completedAt := clock.Now() diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/filterlatency/filterlatency_test.go b/staging/src/k8s.io/apiserver/pkg/endpoints/filterlatency/filterlatency_test.go index f12e9456489..db900145aa1 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/filterlatency/filterlatency_test.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/filterlatency/filterlatency_test.go @@ -23,7 +23,7 @@ import ( "testing" "time" - utilclock "k8s.io/apimachinery/pkg/util/clock" + testingclock "k8s.io/utils/clock/testing" ) func TestTrackStartedWithContextAlreadyHasFilterRecord(t *testing.T) { @@ -41,7 +41,7 @@ func TestTrackStartedWithContextAlreadyHasFilterRecord(t *testing.T) { }) requestFilterStarted := time.Now() - wrapped := trackStarted(handler, filterName, utilclock.NewFakeClock(requestFilterStarted)) + wrapped := trackStarted(handler, filterName, testingclock.NewFakeClock(requestFilterStarted)) testRequest, err := http.NewRequest(http.MethodGet, "/api/v1/namespaces", nil) if err != nil { @@ -84,7 +84,7 @@ func TestTrackStartedWithContextDoesNotHaveFilterRecord(t *testing.T) { }) requestFilterStarted := time.Now() - wrapped := trackStarted(handler, filterName, utilclock.NewFakeClock(requestFilterStarted)) + wrapped := trackStarted(handler, filterName, testingclock.NewFakeClock(requestFilterStarted)) testRequest, err := http.NewRequest(http.MethodGet, "/api/v1/namespaces", nil) if err != nil { @@ -121,7 +121,7 @@ func TestTrackCompletedContextHasFilterRecord(t *testing.T) { }) requestFilterEndedAt := time.Now() - wrapped := trackCompleted(handler, utilclock.NewFakeClock(requestFilterEndedAt), func(_ context.Context, fr *requestFilterRecord, completedAt time.Time) { + wrapped := trackCompleted(handler, testingclock.NewFakeClock(requestFilterEndedAt), func(_ context.Context, fr *requestFilterRecord, completedAt time.Time) { actionCallCount++ filterRecordGot = fr filterCompletedAtGot = completedAt @@ -157,7 +157,7 @@ func TestTrackCompletedContextDoesNotHaveFilterRecord(t *testing.T) { handlerCallCount++ }) - wrapped := trackCompleted(handler, utilclock.NewFakeClock(time.Now()), func(_ context.Context, _ *requestFilterRecord, _ time.Time) { + wrapped := trackCompleted(handler, testingclock.NewFakeClock(time.Now()), func(_ context.Context, _ *requestFilterRecord, _ time.Time) { actionCallCount++ }) diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/filters/request_deadline.go b/staging/src/k8s.io/apiserver/pkg/endpoints/filters/request_deadline.go index 1df8e5b5514..132ffab1cf6 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/filters/request_deadline.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/filters/request_deadline.go @@ -27,13 +27,13 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - utilclock "k8s.io/apimachinery/pkg/util/clock" utilruntime "k8s.io/apimachinery/pkg/util/runtime" auditinternal "k8s.io/apiserver/pkg/apis/audit" "k8s.io/apiserver/pkg/audit" "k8s.io/apiserver/pkg/endpoints/handlers/responsewriters" "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/klog/v2" + "k8s.io/utils/clock" ) const ( @@ -48,11 +48,11 @@ const ( // requestTimeoutMaximum specifies the default request timeout value. func WithRequestDeadline(handler http.Handler, sink audit.Sink, policy audit.PolicyRuleEvaluator, longRunning request.LongRunningRequestCheck, negotiatedSerializer runtime.NegotiatedSerializer, requestTimeoutMaximum time.Duration) http.Handler { - return withRequestDeadline(handler, sink, policy, longRunning, negotiatedSerializer, requestTimeoutMaximum, utilclock.RealClock{}) + return withRequestDeadline(handler, sink, policy, longRunning, negotiatedSerializer, requestTimeoutMaximum, clock.RealClock{}) } func withRequestDeadline(handler http.Handler, sink audit.Sink, policy audit.PolicyRuleEvaluator, longRunning request.LongRunningRequestCheck, - negotiatedSerializer runtime.NegotiatedSerializer, requestTimeoutMaximum time.Duration, clock utilclock.PassiveClock) http.Handler { + negotiatedSerializer runtime.NegotiatedSerializer, requestTimeoutMaximum time.Duration, clock clock.PassiveClock) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { ctx := req.Context() diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/filters/request_deadline_test.go b/staging/src/k8s.io/apiserver/pkg/endpoints/filters/request_deadline_test.go index 856e443e506..384c78092a5 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/filters/request_deadline_test.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/filters/request_deadline_test.go @@ -32,10 +32,10 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" - utilclock "k8s.io/apimachinery/pkg/util/clock" auditinternal "k8s.io/apiserver/pkg/apis/audit" "k8s.io/apiserver/pkg/audit/policy" "k8s.io/apiserver/pkg/endpoints/request" + testingclock "k8s.io/utils/clock/testing" ) func TestParseTimeout(t *testing.T) { @@ -227,7 +227,7 @@ func TestWithRequestDeadlineWithClock(t *testing.T) { // if the deadline filter uses the clock instead of using the request started timestamp from the context // then we will see a request deadline of about a minute. receivedTimestampExpected := time.Now().Add(time.Minute) - fakeClock := utilclock.NewFakeClock(receivedTimestampExpected) + fakeClock := testingclock.NewFakeClock(receivedTimestampExpected) fakeSink := &fakeAuditSink{} fakeRuleEvaluator := policy.NewFakePolicyRuleEvaluator(auditinternal.LevelRequestResponse, nil) diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/filters/request_received_time.go b/staging/src/k8s.io/apiserver/pkg/endpoints/filters/request_received_time.go index d9e7369f671..576bb3e7a26 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/filters/request_received_time.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/filters/request_received_time.go @@ -19,18 +19,18 @@ package filters import ( "net/http" - utilclock "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apiserver/pkg/endpoints/request" + "k8s.io/utils/clock" ) // WithRequestReceivedTimestamp attaches the ReceivedTimestamp (the time the request reached // the apiserver) to the context. func WithRequestReceivedTimestamp(handler http.Handler) http.Handler { - return withRequestReceivedTimestampWithClock(handler, utilclock.RealClock{}) + return withRequestReceivedTimestampWithClock(handler, clock.RealClock{}) } // The clock is passed as a parameter, handy for unit testing. -func withRequestReceivedTimestampWithClock(handler http.Handler, clock utilclock.PassiveClock) http.Handler { +func withRequestReceivedTimestampWithClock(handler http.Handler, clock clock.PassiveClock) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { ctx := req.Context() req = req.WithContext(request.WithReceivedTimestamp(ctx, clock.Now())) diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/filters/request_received_time_test.go b/staging/src/k8s.io/apiserver/pkg/endpoints/filters/request_received_time_test.go index f09bad40952..ec4ee68e053 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/filters/request_received_time_test.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/filters/request_received_time_test.go @@ -22,8 +22,8 @@ import ( "testing" "time" - utilclock "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apiserver/pkg/endpoints/request" + testingclock "k8s.io/utils/clock/testing" ) func TestWithRequestReceivedTimestamp(t *testing.T) { @@ -41,7 +41,7 @@ func TestWithRequestReceivedTimestamp(t *testing.T) { receivedTimestampGot, ok = request.ReceivedTimestampFrom(req.Context()) }) - wrapped := withRequestReceivedTimestampWithClock(handler, utilclock.NewFakeClock(receivedTimestampExpected)) + wrapped := withRequestReceivedTimestampWithClock(handler, testingclock.NewFakeClock(receivedTimestampExpected)) testRequest, err := http.NewRequest(http.MethodGet, "/api/v1/namespaces", nil) if err != nil { diff --git a/staging/src/k8s.io/apiserver/pkg/server/config.go b/staging/src/k8s.io/apiserver/pkg/server/config.go index f99d0ca1c51..524c8c0f5ae 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/config.go +++ b/staging/src/k8s.io/apiserver/pkg/server/config.go @@ -35,7 +35,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/serializer" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/sets" utilwaitgroup "k8s.io/apimachinery/pkg/util/waitgroup" "k8s.io/apimachinery/pkg/version" @@ -73,6 +72,7 @@ import ( "k8s.io/klog/v2" openapicommon "k8s.io/kube-openapi/pkg/common" "k8s.io/kube-openapi/pkg/validation/spec" + "k8s.io/utils/clock" utilsnet "k8s.io/utils/net" // install apis diff --git a/staging/src/k8s.io/apiserver/pkg/server/egressselector/egress_selector_test.go b/staging/src/k8s.io/apiserver/pkg/server/egressselector/egress_selector_test.go index 1f310413549..bab1f3ee8b9 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/egressselector/egress_selector_test.go +++ b/staging/src/k8s.io/apiserver/pkg/server/egressselector/egress_selector_test.go @@ -25,12 +25,12 @@ import ( "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/clock" utilnet "k8s.io/apimachinery/pkg/util/net" "k8s.io/apiserver/pkg/apis/apiserver" "k8s.io/apiserver/pkg/server/egressselector/metrics" "k8s.io/component-base/metrics/legacyregistry" "k8s.io/component-base/metrics/testutil" + testingclock "k8s.io/utils/clock/testing" ) type fakeEgressSelection struct { @@ -244,7 +244,7 @@ func TestMetrics(t *testing.T) { t.Run(tn, func(t *testing.T) { metrics.Metrics.Reset() - metrics.Metrics.SetClock(clock.NewFakeClock(time.Now())) + metrics.Metrics.SetClock(testingclock.NewFakeClock(time.Now())) d := dialerCreator{ connector: &fakeProxyServerConnector{ connectorErr: tc.connectorErr, diff --git a/staging/src/k8s.io/apiserver/pkg/server/egressselector/metrics/metrics.go b/staging/src/k8s.io/apiserver/pkg/server/egressselector/metrics/metrics.go index 04ad61c4fd0..af384618181 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/egressselector/metrics/metrics.go +++ b/staging/src/k8s.io/apiserver/pkg/server/egressselector/metrics/metrics.go @@ -19,9 +19,9 @@ package metrics import ( "time" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/component-base/metrics" "k8s.io/component-base/metrics/legacyregistry" + "k8s.io/utils/clock" ) const ( diff --git a/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go b/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go index 8104cd2f05e..f3c17b626f3 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go +++ b/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go @@ -31,7 +31,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/serializer" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/sets" utilwaitgroup "k8s.io/apimachinery/pkg/util/waitgroup" "k8s.io/apimachinery/pkg/version" @@ -56,6 +55,7 @@ import ( openapiutil "k8s.io/kube-openapi/pkg/util" openapiproto "k8s.io/kube-openapi/pkg/util/proto" "k8s.io/kube-openapi/pkg/validation/spec" + "k8s.io/utils/clock" ) // Info about an API group. diff --git a/staging/src/k8s.io/apiserver/pkg/server/healthz.go b/staging/src/k8s.io/apiserver/pkg/server/healthz.go index 61da5873ce2..d6d13444d70 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/healthz.go +++ b/staging/src/k8s.io/apiserver/pkg/server/healthz.go @@ -21,8 +21,8 @@ import ( "net/http" "time" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apiserver/pkg/server/healthz" + "k8s.io/utils/clock" ) // AddHealthChecks adds HealthCheck(s) to health endpoints (healthz, livez, readyz) but diff --git a/staging/src/k8s.io/apiserver/pkg/server/healthz_test.go b/staging/src/k8s.io/apiserver/pkg/server/healthz_test.go index eb4ce2abd31..a8f7025e835 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/healthz_test.go +++ b/staging/src/k8s.io/apiserver/pkg/server/healthz_test.go @@ -20,13 +20,13 @@ import ( "testing" "time" - "k8s.io/apimachinery/pkg/util/clock" + testingclock "k8s.io/utils/clock/testing" ) func TestDelayedHealthCheck(t *testing.T) { t.Run("test that liveness check returns true until the delay has elapsed", func(t *testing.T) { t0 := time.Unix(0, 0) - c := clock.NewFakeClock(t0) + c := testingclock.NewFakeClock(t0) doneCh := make(chan struct{}) healthCheck := delayedHealthCheck(postStartHookHealthz{"test", doneCh}, c, time.Duration(10)*time.Second) @@ -52,7 +52,7 @@ func TestDelayedHealthCheck(t *testing.T) { }) t.Run("test that liveness check does not toggle false even if done channel is closed early", func(t *testing.T) { t0 := time.Unix(0, 0) - c := clock.NewFakeClock(t0) + c := testingclock.NewFakeClock(t0) doneCh := make(chan struct{}) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go index c4f9865c284..2053c818066 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go @@ -31,7 +31,6 @@ import ( "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" "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/apimachinery/pkg/watch" @@ -41,6 +40,7 @@ import ( utilflowcontrol "k8s.io/apiserver/pkg/util/flowcontrol" "k8s.io/client-go/tools/cache" "k8s.io/klog/v2" + "k8s.io/utils/clock" utiltrace "k8s.io/utils/trace" ) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go index 74df2010318..7290ad80ab0 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go @@ -35,7 +35,6 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/diff" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/wait" @@ -44,6 +43,8 @@ import ( examplev1 "k8s.io/apiserver/pkg/apis/example/v1" "k8s.io/apiserver/pkg/storage" utilflowcontrol "k8s.io/apiserver/pkg/util/flowcontrol" + "k8s.io/utils/clock" + testingclock "k8s.io/utils/clock/testing" ) var ( @@ -603,7 +604,7 @@ func TestTimeBucketWatchersBasic(t *testing.T) { return newCacheWatcher(0, filter, forget, testVersioner{}, deadline, true, objectType, "") } - clock := clock.NewFakeClock(time.Now()) + clock := testingclock.NewFakeClock(time.Now()) watchers := newTimeBucketWatchers(clock, defaultBookmarkFrequency) now := clock.Now() watchers.addWatcher(newWatcher(now.Add(10 * time.Second))) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/time_budget.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/time_budget.go index 2e14a782359..da77bd42b02 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/time_budget.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/time_budget.go @@ -20,7 +20,7 @@ import ( "sync" "time" - "k8s.io/apimachinery/pkg/util/clock" + "k8s.io/utils/clock" ) const ( diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/time_budget_test.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/time_budget_test.go index 5bd7f44a58b..c35f34efe33 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/time_budget_test.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/time_budget_test.go @@ -20,11 +20,11 @@ import ( "testing" "time" - "k8s.io/apimachinery/pkg/util/clock" + testingclock "k8s.io/utils/clock/testing" ) func TestTimeBudget(t *testing.T) { - fakeClock := clock.NewFakeClock(time.Now()) + fakeClock := testingclock.NewFakeClock(time.Now()) budget := &timeBudgetImpl{ clock: fakeClock, diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/watch_cache.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/watch_cache.go index b3c925e180c..65f002e6fdd 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/watch_cache.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/watch_cache.go @@ -27,11 +27,11 @@ import ( "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/watch" "k8s.io/apiserver/pkg/storage" "k8s.io/client-go/tools/cache" "k8s.io/klog/v2" + "k8s.io/utils/clock" utiltrace "k8s.io/utils/trace" ) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/watch_cache_test.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/watch_cache_test.go index acf34de1f17..4812650b762 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/watch_cache_test.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/watch_cache_test.go @@ -31,13 +31,13 @@ import ( "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/watch" "k8s.io/apiserver/pkg/apis/example" "k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage/etcd3" "k8s.io/client-go/tools/cache" + testingclock "k8s.io/utils/clock/testing" ) func makeTestPod(name string, resourceVersion uint64) *v1.Pod { @@ -81,7 +81,7 @@ func newTestWatchCache(capacity int, indexers *cache.Indexers) *watchCache { } versioner := etcd3.APIObjectVersioner{} mockHandler := func(*watchCacheEvent) {} - wc := newWatchCache(keyFunc, mockHandler, getAttrsFunc, versioner, indexers, clock.NewFakeClock(time.Now()), reflect.TypeOf(&example.Pod{})) + wc := newWatchCache(keyFunc, mockHandler, getAttrsFunc, versioner, indexers, testingclock.NewFakeClock(time.Now()), reflect.TypeOf(&example.Pod{})) // To preserve behavior of tests that assume a given capacity, // resize it to th expected size. wc.capacity = capacity @@ -443,7 +443,7 @@ func TestWaitUntilFreshAndGet(t *testing.T) { func TestWaitUntilFreshAndListTimeout(t *testing.T) { store := newTestWatchCache(3, &cache.Indexers{}) - fc := store.clock.(*clock.FakeClock) + fc := store.clock.(*testingclock.FakeClock) // In background, step clock after the below call starts the timer. go func() { diff --git a/staging/src/k8s.io/apiserver/pkg/storage/tests/cacher_test.go b/staging/src/k8s.io/apiserver/pkg/storage/tests/cacher_test.go index 32f03d7626f..9381b17ea4e 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/tests/cacher_test.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/tests/cacher_test.go @@ -36,7 +36,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/serializer" - "k8s.io/apimachinery/pkg/util/clock" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/wait" @@ -52,6 +51,8 @@ import ( "k8s.io/apiserver/pkg/storage/value" utilfeature "k8s.io/apiserver/pkg/util/feature" featuregatetesting "k8s.io/component-base/featuregate/testing" + "k8s.io/utils/clock" + testingclock "k8s.io/utils/clock/testing" ) var ( @@ -409,7 +410,7 @@ func TestWatch(t *testing.T) { // Inject one list error to make sure we test the relist case. etcdStorage = &injectListError{errors: 1, Interface: etcdStorage} defer server.Terminate(t) - fakeClock := clock.NewFakeClock(time.Now()) + fakeClock := testingclock.NewFakeClock(time.Now()) cacher, _, err := newTestCacherWithClock(etcdStorage, fakeClock) if err != nil { t.Fatalf("Couldn't create cacher: %v", err) diff --git a/staging/src/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go b/staging/src/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go index 7a09846260a..229a4ccac5b 100644 --- a/staging/src/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go +++ b/staging/src/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go @@ -38,7 +38,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/serializer" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/client-go/pkg/apis/clientauthentication" "k8s.io/client-go/pkg/apis/clientauthentication/install" clientauthenticationv1 "k8s.io/client-go/pkg/apis/clientauthentication/v1" @@ -49,6 +48,7 @@ import ( "k8s.io/client-go/transport" "k8s.io/client-go/util/connrotation" "k8s.io/klog/v2" + "k8s.io/utils/clock" ) const execInfoEnv = "KUBERNETES_EXEC_INFO" diff --git a/staging/src/k8s.io/client-go/plugin/pkg/client/auth/exec/exec_test.go b/staging/src/k8s.io/client-go/plugin/pkg/client/auth/exec/exec_test.go index e55e845d88b..6698fb4e836 100644 --- a/staging/src/k8s.io/client-go/plugin/pkg/client/auth/exec/exec_test.go +++ b/staging/src/k8s.io/client-go/plugin/pkg/client/auth/exec/exec_test.go @@ -39,10 +39,10 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/client-go/pkg/apis/clientauthentication" "k8s.io/client-go/tools/clientcmd/api" "k8s.io/client-go/transport" + testingclock "k8s.io/utils/clock/testing" ) var ( @@ -1421,7 +1421,7 @@ func TestInstallHintRateLimit(t *testing.T) { a.sometimes.threshold = test.threshold a.sometimes.interval = test.interval - clock := clock.NewFakeClock(time.Now()) + clock := testingclock.NewFakeClock(time.Now()) a.sometimes.clock = clock count := 0 diff --git a/staging/src/k8s.io/client-go/rest/request.go b/staging/src/k8s.io/client-go/rest/request.go index e5a8100be29..5cc9900b04a 100644 --- a/staging/src/k8s.io/client-go/rest/request.go +++ b/staging/src/k8s.io/client-go/rest/request.go @@ -39,13 +39,13 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/serializer/streaming" - utilclock "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/net" "k8s.io/apimachinery/pkg/watch" restclientwatch "k8s.io/client-go/rest/watch" "k8s.io/client-go/tools/metrics" "k8s.io/client-go/util/flowcontrol" "k8s.io/klog/v2" + "k8s.io/utils/clock" ) var ( @@ -619,12 +619,12 @@ type throttleSettings struct { } type throttledLogger struct { - clock utilclock.PassiveClock + clock clock.PassiveClock settings []*throttleSettings } var globalThrottledLogger = &throttledLogger{ - clock: utilclock.RealClock{}, + clock: clock.RealClock{}, settings: []*throttleSettings{ { logLevel: 2, diff --git a/staging/src/k8s.io/client-go/rest/request_test.go b/staging/src/k8s.io/client-go/rest/request_test.go index dcdc0edba0f..ab2df1b5339 100644 --- a/staging/src/k8s.io/client-go/rest/request_test.go +++ b/staging/src/k8s.io/client-go/rest/request_test.go @@ -45,7 +45,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/serializer/streaming" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/diff" "k8s.io/apimachinery/pkg/util/httpstream" "k8s.io/apimachinery/pkg/util/intstr" @@ -2485,7 +2484,7 @@ func TestThrottledLogger(t *testing.T) { defer func() { globalThrottledLogger.clock = oldClock }() - clock := clock.NewFakeClock(now) + clock := testingclock.NewFakeClock(now) globalThrottledLogger.clock = clock logMessages := 0 diff --git a/staging/src/k8s.io/client-go/tools/events/event_broadcaster.go b/staging/src/k8s.io/client-go/tools/events/event_broadcaster.go index bde888ee984..59adc417230 100644 --- a/staging/src/k8s.io/client-go/tools/events/event_broadcaster.go +++ b/staging/src/k8s.io/client-go/tools/events/event_broadcaster.go @@ -29,7 +29,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/json" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/strategicpatch" @@ -43,6 +42,7 @@ import ( "k8s.io/client-go/tools/record" "k8s.io/client-go/tools/record/util" "k8s.io/klog/v2" + "k8s.io/utils/clock" ) const ( diff --git a/staging/src/k8s.io/client-go/tools/events/event_recorder.go b/staging/src/k8s.io/client-go/tools/events/event_recorder.go index c824404e965..132843742b0 100644 --- a/staging/src/k8s.io/client-go/tools/events/event_recorder.go +++ b/staging/src/k8s.io/client-go/tools/events/event_recorder.go @@ -24,12 +24,12 @@ import ( eventsv1 "k8s.io/api/events/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/clock" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/tools/record/util" "k8s.io/client-go/tools/reference" "k8s.io/klog/v2" + "k8s.io/utils/clock" ) type recorderImpl struct { diff --git a/staging/src/k8s.io/client-go/tools/leaderelection/healthzadaptor_test.go b/staging/src/k8s.io/client-go/tools/leaderelection/healthzadaptor_test.go index d92f1336397..baf6b5ca20e 100644 --- a/staging/src/k8s.io/client-go/tools/leaderelection/healthzadaptor_test.go +++ b/staging/src/k8s.io/client-go/tools/leaderelection/healthzadaptor_test.go @@ -24,8 +24,8 @@ import ( "net/http" - "k8s.io/apimachinery/pkg/util/clock" rl "k8s.io/client-go/tools/leaderelection/resourcelock" + testingclock "k8s.io/utils/clock/testing" ) type fakeLock struct { @@ -91,7 +91,7 @@ func TestLeaderElectionHealthChecker(t *testing.T) { HolderIdentity: "healthTest", }, observedTime: current, - clock: clock.NewFakeClock(current.Add(time.Hour)), + clock: testingclock.NewFakeClock(current.Add(time.Hour)), }, }, { @@ -108,7 +108,7 @@ func TestLeaderElectionHealthChecker(t *testing.T) { HolderIdentity: "otherServer", }, observedTime: current, - clock: clock.NewFakeClock(current.Add(time.Hour)), + clock: testingclock.NewFakeClock(current.Add(time.Hour)), }, }, { @@ -125,7 +125,7 @@ func TestLeaderElectionHealthChecker(t *testing.T) { HolderIdentity: "healthTest", }, observedTime: current, - clock: clock.NewFakeClock(current), + clock: testingclock.NewFakeClock(current), }, }, { @@ -142,7 +142,7 @@ func TestLeaderElectionHealthChecker(t *testing.T) { HolderIdentity: "healthTest", }, observedTime: current, - clock: clock.NewFakeClock(current.Add(time.Minute).Add(time.Second)), + clock: testingclock.NewFakeClock(current.Add(time.Minute).Add(time.Second)), }, }, } diff --git a/staging/src/k8s.io/client-go/tools/leaderelection/leaderelection.go b/staging/src/k8s.io/client-go/tools/leaderelection/leaderelection.go index e7dd3252003..03a13e6b63f 100644 --- a/staging/src/k8s.io/client-go/tools/leaderelection/leaderelection.go +++ b/staging/src/k8s.io/client-go/tools/leaderelection/leaderelection.go @@ -61,10 +61,10 @@ import ( "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/wait" rl "k8s.io/client-go/tools/leaderelection/resourcelock" + "k8s.io/utils/clock" "k8s.io/klog/v2" ) diff --git a/staging/src/k8s.io/client-go/tools/leaderelection/leaderelection_test.go b/staging/src/k8s.io/client-go/tools/leaderelection/leaderelection_test.go index 24095e7d74f..8fba412ceb4 100644 --- a/staging/src/k8s.io/client-go/tools/leaderelection/leaderelection_test.go +++ b/staging/src/k8s.io/client-go/tools/leaderelection/leaderelection_test.go @@ -30,12 +30,12 @@ import ( "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/diff" "k8s.io/client-go/kubernetes/fake" fakeclient "k8s.io/client-go/testing" rl "k8s.io/client-go/tools/leaderelection/resourcelock" "k8s.io/client-go/tools/record" + "k8s.io/utils/clock" ) func createLockObject(t *testing.T, objectType, namespace, name string, record *rl.LeaderElectionRecord) (obj runtime.Object) {