mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rebase: update kubernetes to v1.21.2
Updated kubernetes packages to latest release. resizefs package has been included into k8s.io/mount-utils package. updated code to use the same. Updates: #1968 Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
42
vendor/k8s.io/apimachinery/pkg/util/clock/clock.go
generated
vendored
42
vendor/k8s.io/apimachinery/pkg/util/clock/clock.go
generated
vendored
@ -34,6 +34,7 @@ type PassiveClock interface {
|
||||
type Clock interface {
|
||||
PassiveClock
|
||||
After(time.Duration) <-chan time.Time
|
||||
AfterFunc(time.Duration, func()) Timer
|
||||
NewTimer(time.Duration) Timer
|
||||
Sleep(time.Duration)
|
||||
NewTicker(time.Duration) Ticker
|
||||
@ -57,6 +58,13 @@ func (RealClock) After(d time.Duration) <-chan time.Time {
|
||||
return time.After(d)
|
||||
}
|
||||
|
||||
// AfterFunc is the same as time.AfterFunc(d, f).
|
||||
func (RealClock) AfterFunc(d time.Duration, f func()) Timer {
|
||||
return &realTimer{
|
||||
timer: time.AfterFunc(d, f),
|
||||
}
|
||||
}
|
||||
|
||||
// NewTimer returns a new Timer.
|
||||
func (RealClock) NewTimer(d time.Duration) Timer {
|
||||
return &realTimer{
|
||||
@ -95,6 +103,7 @@ type fakeClockWaiter struct {
|
||||
stepInterval time.Duration
|
||||
skipIfBlocked bool
|
||||
destChan chan time.Time
|
||||
afterFunc func()
|
||||
}
|
||||
|
||||
// NewFakePassiveClock returns a new FakePassiveClock.
|
||||
@ -145,6 +154,25 @@ func (f *FakeClock) After(d time.Duration) <-chan time.Time {
|
||||
return ch
|
||||
}
|
||||
|
||||
// AfterFunc is the Fake version of time.AfterFunc(d, callback).
|
||||
func (f *FakeClock) AfterFunc(d time.Duration, cb func()) Timer {
|
||||
f.lock.Lock()
|
||||
defer f.lock.Unlock()
|
||||
stopTime := f.time.Add(d)
|
||||
ch := make(chan time.Time, 1) // Don't block!
|
||||
|
||||
timer := &fakeTimer{
|
||||
fakeClock: f,
|
||||
waiter: fakeClockWaiter{
|
||||
targetTime: stopTime,
|
||||
destChan: ch,
|
||||
afterFunc: cb,
|
||||
},
|
||||
}
|
||||
f.waiters = append(f.waiters, timer.waiter)
|
||||
return timer
|
||||
}
|
||||
|
||||
// NewTimer is the Fake version of time.NewTimer(d).
|
||||
func (f *FakeClock) NewTimer(d time.Duration) Timer {
|
||||
f.lock.Lock()
|
||||
@ -211,6 +239,10 @@ func (f *FakeClock) setTimeLocked(t time.Time) {
|
||||
w.destChan <- t
|
||||
}
|
||||
|
||||
if w.afterFunc != nil {
|
||||
w.afterFunc()
|
||||
}
|
||||
|
||||
if w.stepInterval > 0 {
|
||||
for !w.targetTime.After(t) {
|
||||
w.targetTime = w.targetTime.Add(w.stepInterval)
|
||||
@ -225,8 +257,8 @@ func (f *FakeClock) setTimeLocked(t time.Time) {
|
||||
f.waiters = newWaiters
|
||||
}
|
||||
|
||||
// HasWaiters returns true if After has been called on f but not yet satisfied (so you can
|
||||
// write race-free tests).
|
||||
// HasWaiters returns true if After or AfterFunc has been called on f but not yet satisfied
|
||||
// (so you can write race-free tests).
|
||||
func (f *FakeClock) HasWaiters() bool {
|
||||
f.lock.RLock()
|
||||
defer f.lock.RUnlock()
|
||||
@ -261,6 +293,12 @@ func (*IntervalClock) After(d time.Duration) <-chan time.Time {
|
||||
panic("IntervalClock doesn't implement After")
|
||||
}
|
||||
|
||||
// AfterFunc is currently unimplemented, will panic.
|
||||
// TODO: make interval clock use FakeClock so this can be implemented.
|
||||
func (*IntervalClock) AfterFunc(d time.Duration, cb func()) Timer {
|
||||
panic("IntervalClock doesn't implement AfterFunc")
|
||||
}
|
||||
|
||||
// NewTimer is currently unimplemented, will panic.
|
||||
// TODO: make interval clock use FakeClock so this can be implemented.
|
||||
func (*IntervalClock) NewTimer(d time.Duration) Timer {
|
||||
|
Reference in New Issue
Block a user