Skip to content

Commit ccb8d53

Browse files
Kiall Mac Inneskiall
Kiall Mac Innes
authored andcommitted
Remove unused WaitForDetach from Detacher interface and plugins
This has been unused since 542f2dc, and relies on deviceName, which can no longer be relied upon (see issue #33128). This needs to be removed now, as part of #33128, as the code can't be updated to attempt device detection and fallback through to the Cinder provided deviceName, as detection "fails" when the device is gone, and if cinder has reported a deviceName that another volume has used in relaity, then this will block forever (or until the other, unreleated, volume has been detached)
1 parent 3eae250 commit ccb8d53

File tree

7 files changed

+0
-111
lines changed

7 files changed

+0
-111
lines changed

pkg/volume/aws_ebs/attacher.go

-21
Original file line numberDiff line numberDiff line change
@@ -244,27 +244,6 @@ func (detacher *awsElasticBlockStoreDetacher) Detach(deviceMountPath string, nod
244244
return nil
245245
}
246246

247-
func (detacher *awsElasticBlockStoreDetacher) WaitForDetach(devicePath string, timeout time.Duration) error {
248-
ticker := time.NewTicker(checkSleepDuration)
249-
defer ticker.Stop()
250-
timer := time.NewTimer(timeout)
251-
defer timer.Stop()
252-
253-
for {
254-
select {
255-
case <-ticker.C:
256-
glog.V(5).Infof("Checking device %q is detached.", devicePath)
257-
if pathExists, err := volumeutil.PathExists(devicePath); err != nil {
258-
return fmt.Errorf("Error checking if device path exists: %v", err)
259-
} else if !pathExists {
260-
return nil
261-
}
262-
case <-timer.C:
263-
return fmt.Errorf("Timeout reached; PD Device %v is still attached", devicePath)
264-
}
265-
}
266-
}
267-
268247
func (detacher *awsElasticBlockStoreDetacher) UnmountDevice(deviceMountPath string) error {
269248
return volumeutil.UnmountPath(deviceMountPath, detacher.mounter)
270249
}

pkg/volume/azure_dd/attacher.go

-14
Original file line numberDiff line numberDiff line change
@@ -270,20 +270,6 @@ func (detacher *azureDiskDetacher) Detach(diskName string, nodeName types.NodeNa
270270
return err
271271
}
272272

273-
// WaitForDetach detects if the disk is detached on the node
274-
func (detacher *azureDiskDetacher) WaitForDetach(devicePath string, timeout time.Duration) error {
275-
return wait.Poll(checkSleepDuration, timeout, func() (bool, error) {
276-
glog.V(4).Infof("Checking device %q is detached.", devicePath)
277-
if pathExists, err := util.PathExists(devicePath); err != nil {
278-
return false, fmt.Errorf("Error checking if device path exists: %v", err)
279-
} else if !pathExists {
280-
return true, nil
281-
} else {
282-
return false, nil
283-
}
284-
})
285-
}
286-
287273
// UnmountDevice unmounts the volume on the node
288274
func (detacher *azureDiskDetacher) UnmountDevice(deviceMountPath string) error {
289275
volume := path.Base(deviceMountPath)

pkg/volume/cinder/attacher.go

-21
Original file line numberDiff line numberDiff line change
@@ -276,27 +276,6 @@ func (detacher *cinderDiskDetacher) Detach(deviceMountPath string, nodeName type
276276
return nil
277277
}
278278

279-
func (detacher *cinderDiskDetacher) WaitForDetach(devicePath string, timeout time.Duration) error {
280-
ticker := time.NewTicker(checkSleepDuration)
281-
defer ticker.Stop()
282-
timer := time.NewTimer(timeout)
283-
defer timer.Stop()
284-
285-
for {
286-
select {
287-
case <-ticker.C:
288-
glog.V(5).Infof("Checking device %q is detached.", devicePath)
289-
if pathExists, err := volumeutil.PathExists(devicePath); err != nil {
290-
return fmt.Errorf("Error checking if device path exists: %v", err)
291-
} else if !pathExists {
292-
return nil
293-
}
294-
case <-timer.C:
295-
return fmt.Errorf("Timeout reached; PD Device %v is still attached", devicePath)
296-
}
297-
}
298-
}
299-
300279
func (detacher *cinderDiskDetacher) UnmountDevice(deviceMountPath string) error {
301280
return volumeutil.UnmountPath(deviceMountPath, detacher.mounter)
302281
}

pkg/volume/gce_pd/attacher.go

-21
Original file line numberDiff line numberDiff line change
@@ -270,27 +270,6 @@ func (detacher *gcePersistentDiskDetacher) Detach(deviceMountPath string, nodeNa
270270
return nil
271271
}
272272

273-
func (detacher *gcePersistentDiskDetacher) WaitForDetach(devicePath string, timeout time.Duration) error {
274-
ticker := time.NewTicker(checkSleepDuration)
275-
defer ticker.Stop()
276-
timer := time.NewTimer(timeout)
277-
defer timer.Stop()
278-
279-
for {
280-
select {
281-
case <-ticker.C:
282-
glog.V(5).Infof("Checking device %q is detached.", devicePath)
283-
if pathExists, err := volumeutil.PathExists(devicePath); err != nil {
284-
return fmt.Errorf("Error checking if device path exists: %v", err)
285-
} else if !pathExists {
286-
return nil
287-
}
288-
case <-timer.C:
289-
return fmt.Errorf("Timeout reached; PD Device %v is still attached", devicePath)
290-
}
291-
}
292-
}
293-
294273
func (detacher *gcePersistentDiskDetacher) UnmountDevice(deviceMountPath string) error {
295274
return volumeutil.UnmountPath(deviceMountPath, detacher.host.GetMounter())
296275
}

pkg/volume/testing/testing.go

-8
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ type FakeVolume struct {
312312
AttachCallCount int
313313
DetachCallCount int
314314
WaitForAttachCallCount int
315-
WaitForDetachCallCount int
316315
MountDeviceCallCount int
317316
UnmountDeviceCallCount int
318317
GetDeviceMountPathCallCount int
@@ -435,13 +434,6 @@ func (fv *FakeVolume) GetDetachCallCount() int {
435434
return fv.DetachCallCount
436435
}
437436

438-
func (fv *FakeVolume) WaitForDetach(devicePath string, timeout time.Duration) error {
439-
fv.Lock()
440-
defer fv.Unlock()
441-
fv.WaitForDetachCallCount++
442-
return nil
443-
}
444-
445437
func (fv *FakeVolume) UnmountDevice(globalMountPath string) error {
446438
fv.Lock()
447439
defer fv.Unlock()

pkg/volume/volume.go

-5
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,6 @@ type Detacher interface {
172172
// Detach the given device from the node with the given Name.
173173
Detach(deviceName string, nodeName types.NodeName) error
174174

175-
// WaitForDetach blocks until the device is detached from this
176-
// node. If the device does not detach within the given timeout
177-
// period an error is returned.
178-
WaitForDetach(devicePath string, timeout time.Duration) error
179-
180175
// UnmountDevice unmounts the global mount of the disk. This
181176
// should only be called once all bind mounts have been
182177
// unmounted.

pkg/volume/vsphere_volume/attacher.go

-21
Original file line numberDiff line numberDiff line change
@@ -251,27 +251,6 @@ func (detacher *vsphereVMDKDetacher) Detach(deviceMountPath string, nodeName typ
251251
return nil
252252
}
253253

254-
func (detacher *vsphereVMDKDetacher) WaitForDetach(devicePath string, timeout time.Duration) error {
255-
ticker := time.NewTicker(checkSleepDuration)
256-
defer ticker.Stop()
257-
timer := time.NewTimer(timeout)
258-
defer timer.Stop()
259-
260-
for {
261-
select {
262-
case <-ticker.C:
263-
glog.V(5).Infof("Checking device %q is detached.", devicePath)
264-
if pathExists, err := volumeutil.PathExists(devicePath); err != nil {
265-
return fmt.Errorf("Error checking if device path exists: %v", err)
266-
} else if !pathExists {
267-
return nil
268-
}
269-
case <-timer.C:
270-
return fmt.Errorf("Timeout reached; Device %v is still attached", devicePath)
271-
}
272-
}
273-
}
274-
275254
func (detacher *vsphereVMDKDetacher) UnmountDevice(deviceMountPath string) error {
276255
return volumeutil.UnmountPath(deviceMountPath, detacher.mounter)
277256
}

0 commit comments

Comments
 (0)