mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Merge pull request #79144 from tedyu/csi-x-recur
Remove recursion in csiAttacher#waitForVolumeAttachmentInternal
This commit is contained in:
commit
9f6ebf0feb
@ -169,13 +169,9 @@ func (c *csiAttacher) waitForVolumeAttachmentInternal(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 func() {
|
defer watcher.Stop()
|
||||||
if !watcherClosed {
|
|
||||||
watcher.Stop()
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -201,11 +197,7 @@ func (c *csiAttacher) waitForVolumeAttachmentInternal(volumeHandle, attachID str
|
|||||||
return "", errors.New("volume attachment has been deleted")
|
return "", errors.New("volume attachment has been deleted")
|
||||||
|
|
||||||
case watch.Error:
|
case watch.Error:
|
||||||
// close the watcher to avoid keeping the watcher too log
|
klog.Warningf("waitForVolumeAttachmentInternal received watch error: %v", event)
|
||||||
watcher.Stop()
|
|
||||||
watcherClosed = true
|
|
||||||
// start another cycle
|
|
||||||
return c.waitForVolumeAttachmentInternal(volumeHandle, attachID, timer, timeout)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
|
@ -221,6 +221,8 @@ func TestAttacherAttach(t *testing.T) {
|
|||||||
status.AttachError = &storage.VolumeError{
|
status.AttachError = &storage.VolumeError{
|
||||||
Message: "attacher error",
|
Message: "attacher error",
|
||||||
}
|
}
|
||||||
|
errStatus := apierrs.NewInternalError(fmt.Errorf("we got an error")).Status()
|
||||||
|
fakeWatcher.Error(&errStatus)
|
||||||
} else {
|
} else {
|
||||||
status.Attached = true
|
status.Attached = true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user