mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 02:11:09 +00:00
Merge pull request #110776 from harry1064/remove-clock-pkg-scheduler
Use clock package from k8s.io/utils/clock
This commit is contained in:
commit
d2c5779dad
@ -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,
|
||||
|
@ -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()
|
||||
}
|
Loading…
Reference in New Issue
Block a user