mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
Refactor BlockVolumeMapper and BlockVolumeUnmapper interface
- Rename MapDevice to MapPodDevice in BlockVolumeMapper - Add UnmapPodDevice in BlockVolumeUnmapper (This will be used by csi driver later) - Add CustomBlockVolumeMapper and CustomBlockVolumeUnmapper interface - Move SetUpDevice and MapPodDevice to CustomBlockVolumeMapper - Move TearDownDevice and UnmapPodDevice to CustomBlockVolumeUnmapper - Implement CustomBlockVolumeMapper only in local and csi plugin - Implement CustomBlockVolumeUnmapper only in fc, iscsi, rbd, and csi plugin - Change MapPodDevice to return path and SetUpDevice not to return path
This commit is contained in:
@@ -804,7 +804,8 @@ type FakeVolume struct {
|
||||
GetDeviceMountPathCallCount int
|
||||
SetUpDeviceCallCount int
|
||||
TearDownDeviceCallCount int
|
||||
MapDeviceCallCount int
|
||||
MapPodDeviceCallCount int
|
||||
UnmapPodDeviceCallCount int
|
||||
GlobalMapPathCallCount int
|
||||
PodDeviceMapPathCallCount int
|
||||
}
|
||||
@@ -880,11 +881,11 @@ func (fv *FakeVolume) TearDownAt(dir string) error {
|
||||
}
|
||||
|
||||
// Block volume support
|
||||
func (fv *FakeVolume) SetUpDevice() (string, error) {
|
||||
func (fv *FakeVolume) SetUpDevice() error {
|
||||
fv.Lock()
|
||||
defer fv.Unlock()
|
||||
fv.SetUpDeviceCallCount++
|
||||
return "", nil
|
||||
return nil
|
||||
}
|
||||
|
||||
// Block volume support
|
||||
@@ -950,18 +951,33 @@ func (fv *FakeVolume) GetTearDownDeviceCallCount() int {
|
||||
}
|
||||
|
||||
// Block volume support
|
||||
func (fv *FakeVolume) MapDevice(devicePath, globalMapPath, volumeMapPath, volumeMapName string, pod types.UID) error {
|
||||
func (fv *FakeVolume) UnmapPodDevice() error {
|
||||
fv.Lock()
|
||||
defer fv.Unlock()
|
||||
fv.MapDeviceCallCount++
|
||||
fv.UnmapPodDeviceCallCount++
|
||||
return nil
|
||||
}
|
||||
|
||||
// Block volume support
|
||||
func (fv *FakeVolume) GetMapDeviceCallCount() int {
|
||||
func (fv *FakeVolume) GetUnmapPodDeviceCallCount() int {
|
||||
fv.RLock()
|
||||
defer fv.RUnlock()
|
||||
return fv.MapDeviceCallCount
|
||||
return fv.UnmapPodDeviceCallCount
|
||||
}
|
||||
|
||||
// Block volume support
|
||||
func (fv *FakeVolume) MapPodDevice() (string, error) {
|
||||
fv.Lock()
|
||||
defer fv.Unlock()
|
||||
fv.MapPodDeviceCallCount++
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// Block volume support
|
||||
func (fv *FakeVolume) GetMapPodDeviceCallCount() int {
|
||||
fv.RLock()
|
||||
defer fv.RUnlock()
|
||||
return fv.MapPodDeviceCallCount
|
||||
}
|
||||
|
||||
func (fv *FakeVolume) Attach(spec *Spec, nodeName types.NodeName) (string, error) {
|
||||
@@ -1493,22 +1509,22 @@ func VerifyGetPodDeviceMapPathCallCount(
|
||||
expectedPodDeviceMapPathCallCount)
|
||||
}
|
||||
|
||||
// VerifyGetMapDeviceCallCount ensures that at least one of the Mappers for this
|
||||
// plugin has the expectedMapDeviceCallCount number of calls. Otherwise it
|
||||
// VerifyGetMapPodDeviceCallCount ensures that at least one of the Mappers for this
|
||||
// plugin has the expectedMapPodDeviceCallCount number of calls. Otherwise it
|
||||
// returns an error.
|
||||
func VerifyGetMapDeviceCallCount(
|
||||
expectedMapDeviceCallCount int,
|
||||
func VerifyGetMapPodDeviceCallCount(
|
||||
expectedMapPodDeviceCallCount int,
|
||||
fakeVolumePlugin *FakeVolumePlugin) error {
|
||||
for _, mapper := range fakeVolumePlugin.GetBlockVolumeMapper() {
|
||||
actualCallCount := mapper.GetMapDeviceCallCount()
|
||||
if actualCallCount >= expectedMapDeviceCallCount {
|
||||
actualCallCount := mapper.GetMapPodDeviceCallCount()
|
||||
if actualCallCount >= expectedMapPodDeviceCallCount {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf(
|
||||
"No Mapper have expected MapdDeviceCallCount. Expected: <%v>.",
|
||||
expectedMapDeviceCallCount)
|
||||
"No Mapper have expected MapPodDeviceCallCount. Expected: <%v>.",
|
||||
expectedMapPodDeviceCallCount)
|
||||
}
|
||||
|
||||
// GetTestVolumePluginMgr creates, initializes, and returns a test volume plugin
|
||||
|
||||
Reference in New Issue
Block a user