mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 11:13:48 +00:00
Merge pull request #79113 from tedyu/stop-w-detach
Close watcher early for volume detachment
This commit is contained in:
commit
9915047d3d
@ -492,8 +492,13 @@ func (c *csiAttacher) waitForVolumeDetachmentInternal(volumeHandle, attachID str
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("watch error:%v for volume %v", err, volumeHandle)
|
return fmt.Errorf("watch error:%v for volume %v", err, volumeHandle)
|
||||||
}
|
}
|
||||||
|
var watcherClosed bool
|
||||||
ch := watcher.ResultChan()
|
ch := watcher.ResultChan()
|
||||||
defer watcher.Stop()
|
defer func() {
|
||||||
|
if !watcherClosed {
|
||||||
|
watcher.Stop()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -518,8 +523,10 @@ func (c *csiAttacher) waitForVolumeDetachmentInternal(volumeHandle, attachID str
|
|||||||
return nil
|
return nil
|
||||||
|
|
||||||
case watch.Error:
|
case watch.Error:
|
||||||
|
watcher.Stop()
|
||||||
|
watcherClosed = true
|
||||||
// start another cycle
|
// start another cycle
|
||||||
c.waitForVolumeDetachmentInternal(volumeHandle, attachID, timer, timeout)
|
return c.waitForVolumeDetachmentInternal(volumeHandle, attachID, timer, timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
|
Loading…
Reference in New Issue
Block a user