Skip to content

Commit

Permalink
Merge pull request #105026 from wojtek-t/migrate_clock_2
Browse files Browse the repository at this point in the history
Unify towards k8s.io/utils/clock - part 2

Kubernetes-commit: 9918aa1e035a00bc7c0f16a05e1b222650b3eabc
  • Loading branch information
k8s-publishing-bot committed Sep 17, 2021
2 parents 0866d96 + 608b521 commit efdf058
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 21 deletions.
4 changes: 2 additions & 2 deletions go.mod
Expand Up @@ -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-20210917114041-87fb71e8a0dc
k8s.io/apimachinery v0.0.0-20210917114042-f7f8dd8e6c3d
k8s.io/klog/v2 v2.20.0
k8s.io/kube-openapi v0.0.0-20210817084001-7fbd8d59e5b8
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a
Expand All @@ -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-20210917114041-87fb71e8a0dc
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20210917114042-f7f8dd8e6c3d
)
4 changes: 2 additions & 2 deletions go.sum
Expand Up @@ -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-20210917114041-87fb71e8a0dc h1:3YtYaYOdmmzFpv6HYFzod3i7+3NNlPY7zEyjt9TY1Gk=
k8s.io/apimachinery v0.0.0-20210917114041-87fb71e8a0dc/go.mod h1:CimYO7ypGwnQeTeoJQ8Jht0OVH2glTFHGy7xEhLj3sk=
k8s.io/apimachinery v0.0.0-20210917114042-f7f8dd8e6c3d h1:rzQUQhOqvkyS9IyueD34dF0WoXiIJ0gANDzmxLS1kJ8=
k8s.io/apimachinery v0.0.0-20210917114042-f7f8dd8e6c3d/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=
Expand Down
2 changes: 1 addition & 1 deletion plugin/pkg/client/auth/exec/exec.go
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions plugin/pkg/client/auth/exec/exec_test.go
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions rest/request.go
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions rest/request_test.go
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/events/event_broadcaster.go
Expand Up @@ -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"
Expand All @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion tools/events/event_recorder.go
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions tools/leaderelection/healthzadaptor_test.go
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)),
},
},
{
Expand All @@ -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)),
},
},
{
Expand All @@ -125,7 +125,7 @@ func TestLeaderElectionHealthChecker(t *testing.T) {
HolderIdentity: "healthTest",
},
observedTime: current,
clock: clock.NewFakeClock(current),
clock: testingclock.NewFakeClock(current),
},
},
{
Expand All @@ -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)),
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion tools/leaderelection/leaderelection.go
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion tools/leaderelection/leaderelection_test.go
Expand Up @@ -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) {
Expand Down

0 comments on commit efdf058

Please sign in to comment.