diff --git a/pkg/scheduler/internal/queue/scheduling_queue.go b/pkg/scheduler/internal/queue/scheduling_queue.go index 9b4c5139743..a5a4b30ecad 100644 --- a/pkg/scheduler/internal/queue/scheduling_queue.go +++ b/pkg/scheduler/internal/queue/scheduling_queue.go @@ -46,6 +46,7 @@ import ( "k8s.io/kubernetes/pkg/scheduler/internal/heap" "k8s.io/kubernetes/pkg/scheduler/metrics" "k8s.io/kubernetes/pkg/scheduler/util" + "k8s.io/utils/clock" ) const ( @@ -136,7 +137,7 @@ type PriorityQueue struct { framework.PodNominator stop chan struct{} - clock util.Clock + clock clock.Clock // pod initial backoff duration. podInitialBackoffDuration time.Duration @@ -175,7 +176,7 @@ type PriorityQueue struct { } type priorityQueueOptions struct { - clock util.Clock + clock clock.Clock podInitialBackoffDuration time.Duration podMaxBackoffDuration time.Duration podMaxInUnschedulablePodsDuration time.Duration @@ -186,8 +187,8 @@ type priorityQueueOptions struct { // Option configures a PriorityQueue type Option func(*priorityQueueOptions) -// WithClock sets clock for PriorityQueue, the default clock is util.RealClock. -func WithClock(clock util.Clock) Option { +// WithClock sets clock for PriorityQueue, the default clock is clock.RealClock. +func WithClock(clock clock.Clock) Option { return func(o *priorityQueueOptions) { o.clock = clock } @@ -229,7 +230,7 @@ func WithPodMaxInUnschedulablePodsDuration(duration time.Duration) Option { } var defaultPriorityQueueOptions = priorityQueueOptions{ - clock: util.RealClock{}, + clock: clock.RealClock{}, podInitialBackoffDuration: DefaultPodInitialBackoffDuration, podMaxBackoffDuration: DefaultPodMaxBackoffDuration, podMaxInUnschedulablePodsDuration: DefaultPodMaxInUnschedulablePodsDuration, diff --git a/pkg/scheduler/util/clock.go b/pkg/scheduler/util/clock.go deleted file mode 100644 index e17c759dbac..00000000000 --- a/pkg/scheduler/util/clock.go +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package util - -import ( - "time" -) - -// Clock provides an interface for getting the current time -type Clock interface { - Now() time.Time -} - -// RealClock implements a clock using time -type RealClock struct{} - -// Now returns the current time with time.Now -func (RealClock) Now() time.Time { - return time.Now() -}