mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Merge pull request #101475 from ash2k/ash2k/stop-timer
Stop timer and correctly drain it
This commit is contained in:
commit
a7af9f6e0e
@ -491,14 +491,14 @@ func (c *csiAttacher) waitForVolumeAttachDetachStatusWithLister(volumeHandle, at
|
|||||||
clock = &clock.RealClock{}
|
clock = &clock.RealClock{}
|
||||||
)
|
)
|
||||||
backoffMgr := wait.NewExponentialBackoffManager(initBackoff, maxBackoff, resetDuration, backoffFactor, jitter, clock)
|
backoffMgr := wait.NewExponentialBackoffManager(initBackoff, maxBackoff, resetDuration, backoffFactor, jitter, clock)
|
||||||
defer backoffMgr.Backoff().Stop()
|
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
t := backoffMgr.Backoff()
|
||||||
select {
|
select {
|
||||||
case <-backoffMgr.Backoff().C():
|
case <-t.C():
|
||||||
successful, err := verifyStatus()
|
successful, err := verifyStatus()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -507,6 +507,7 @@ func (c *csiAttacher) waitForVolumeAttachDetachStatusWithLister(volumeHandle, at
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
t.Stop()
|
||||||
klog.Error(log("%s timeout after %v [volume=%v; attachment.ID=%v]", operation, timeout, volumeHandle, attachID))
|
klog.Error(log("%s timeout after %v [volume=%v; attachment.ID=%v]", operation, timeout, volumeHandle, attachID))
|
||||||
return fmt.Errorf("%s timeout for volume %v", operation, volumeHandle)
|
return fmt.Errorf("%s timeout for volume %v", operation, volumeHandle)
|
||||||
}
|
}
|
||||||
|
@ -166,6 +166,9 @@ func BackoffUntil(f func(), backoff BackoffManager, sliding bool, stopCh <-chan
|
|||||||
// of every loop to prevent extra executions of f().
|
// of every loop to prevent extra executions of f().
|
||||||
select {
|
select {
|
||||||
case <-stopCh:
|
case <-stopCh:
|
||||||
|
if !t.Stop() {
|
||||||
|
<-t.C()
|
||||||
|
}
|
||||||
return
|
return
|
||||||
case <-t.C():
|
case <-t.C():
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user