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:
Masaki Kimura
2019-11-04 20:01:37 +00:00
parent 27067540ff
commit f363a03f0b
18 changed files with 202 additions and 223 deletions

View File

@@ -372,9 +372,17 @@ func TestMapUnmap(t *testing.T) {
if volName != testPVName {
t.Errorf("Got unexpected volNamne: %s, expected %s", volName, testPVName)
}
devPath, err := mapper.SetUpDevice()
if err != nil {
t.Errorf("Failed to SetUpDevice, err: %v", err)
var devPath string
if customMapper, ok := mapper.(volume.CustomBlockVolumeMapper); ok {
err = customMapper.SetUpDevice()
if err != nil {
t.Errorf("Failed to SetUpDevice, err: %v", err)
}
devPath, err = customMapper.MapPodDevice()
if err != nil {
t.Errorf("Failed to MapPodDevice, err: %v", err)
}
}
if _, err := os.Stat(devPath); err != nil {
@@ -393,8 +401,14 @@ func TestMapUnmap(t *testing.T) {
t.Fatalf("Got a nil Unmapper")
}
if err := unmapper.TearDownDevice(globalPath, devPath); err != nil {
t.Errorf("TearDownDevice failed, err: %v", err)
if customUnmapper, ok := unmapper.(volume.CustomBlockVolumeUnmapper); ok {
if err := customUnmapper.UnmapPodDevice(); err != nil {
t.Errorf("UnmapPodDevice failed, err: %v", err)
}
if err := customUnmapper.TearDownDevice(globalPath, devPath); err != nil {
t.Errorf("TearDownDevice failed, err: %v", err)
}
}
}