Fixed clearing of devicePath after UnmountDevice

UnmountDevice must not clear devicepath, because such devicePath
may come from node.status (e.g. on AWS) and subsequent MountDevice
operation (that may be already enqueued) needs it.
This commit is contained in:
Jan Safranek
2018-11-16 13:24:42 +01:00
parent 973b5d291d
commit 5283537401
4 changed files with 118 additions and 5 deletions

View File

@@ -250,6 +250,10 @@ type FakeVolumePlugin struct {
LimitKey string
ProvisionDelaySeconds int
// Add callbacks as needed
WaitForAttachHook func(spec *Spec, devicePath string, pod *v1.Pod, spectimeout time.Duration) (string, error)
UnmountDeviceHook func(globalMountPath string) error
Mounters []*FakeVolume
Unmounters []*FakeVolume
Attachers []*FakeVolume
@@ -269,7 +273,10 @@ var _ DeviceMountableVolumePlugin = &FakeVolumePlugin{}
var _ FSResizableVolumePlugin = &FakeVolumePlugin{}
func (plugin *FakeVolumePlugin) getFakeVolume(list *[]*FakeVolume) *FakeVolume {
volume := &FakeVolume{}
volume := &FakeVolume{
WaitForAttachHook: plugin.WaitForAttachHook,
UnmountDeviceHook: plugin.UnmountDeviceHook,
}
*list = append(*list, volume)
return volume
}
@@ -551,6 +558,10 @@ type FakeVolume struct {
Plugin *FakeVolumePlugin
MetricsNil
// Add callbacks as needed
WaitForAttachHook func(spec *Spec, devicePath string, pod *v1.Pod, spectimeout time.Duration) (string, error)
UnmountDeviceHook func(globalMountPath string) error
SetUpCallCount int
TearDownCallCount int
AttachCallCount int
@@ -724,6 +735,9 @@ func (fv *FakeVolume) WaitForAttach(spec *Spec, devicePath string, pod *v1.Pod,
fv.Lock()
defer fv.Unlock()
fv.WaitForAttachCallCount++
if fv.WaitForAttachHook != nil {
return fv.WaitForAttachHook(spec, devicePath, pod, spectimeout)
}
return "/dev/sdb", nil
}
@@ -776,6 +790,9 @@ func (fv *FakeVolume) UnmountDevice(globalMountPath string) error {
fv.Lock()
defer fv.Unlock()
fv.UnmountDeviceCallCount++
if fv.UnmountDeviceHook != nil {
return fv.UnmountDeviceHook(globalMountPath)
}
return nil
}