From 7c7ba197815b2903e43c56bd309d061ffb644f3b Mon Sep 17 00:00:00 2001 From: Yecheng Fu Date: Mon, 21 Oct 2019 20:01:21 +0800 Subject: [PATCH 1/2] Revert "Disable local block volume reconstruction test" This reverts commit 7c240a18b6baa52d3d76a8c664d167f59c153f17. --- test/e2e/storage/testsuites/disruptive.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/e2e/storage/testsuites/disruptive.go b/test/e2e/storage/testsuites/disruptive.go index fe9a14a3176..34f3723aa9c 100644 --- a/test/e2e/storage/testsuites/disruptive.go +++ b/test/e2e/storage/testsuites/disruptive.go @@ -50,7 +50,6 @@ func InitDisruptiveTestSuite() TestSuite { }, } } - func (s *disruptiveTestSuite) getTestSuiteInfo() TestSuiteInfo { return s.tsInfo } @@ -145,12 +144,6 @@ func (s *disruptiveTestSuite) defineTests(driver TestDriver, pattern testpattern if (pattern.VolMode == v1.PersistentVolumeBlock && t.runTestBlock != nil) || (pattern.VolMode == v1.PersistentVolumeFilesystem && t.runTestFile != nil) { ginkgo.It(t.testItStmt, func() { - - if pattern.VolMode == v1.PersistentVolumeBlock && driver.GetDriverInfo().InTreePluginName == "kubernetes.io/local-volume" { - // TODO: https://github.com/kubernetes/kubernetes/issues/74552 - framework.Skipf("Local volume volume plugin does not support block volume reconstruction (#74552)") - } - init() defer cleanup() From 46b1e264dcef1f0583233abc5891efe7d1faa6ad Mon Sep 17 00:00:00 2001 From: Yecheng Fu Date: Tue, 22 Oct 2019 12:44:42 +0800 Subject: [PATCH 2/2] support local volume block mode reconstruction --- .../volumemanager/reconciler/reconciler.go | 26 ++++++++----------- pkg/volume/local/local.go | 1 + 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/pkg/kubelet/volumemanager/reconciler/reconciler.go b/pkg/kubelet/volumemanager/reconciler/reconciler.go index 1e346ab79cb..9e67f839b3c 100644 --- a/pkg/kubelet/volumemanager/reconciler/reconciler.go +++ b/pkg/kubelet/volumemanager/reconciler/reconciler.go @@ -586,24 +586,19 @@ func (rc *reconciler) updateDevicePath(volumesNeedUpdate map[v1.UniqueVolumeName } func getDeviceMountPath(volume *reconstructedVolume) (string, error) { - volumeAttacher, err := volume.attachablePlugin.NewAttacher() - if volumeAttacher == nil || err != nil { - return "", err - } - deviceMountPath, err := - volumeAttacher.GetDeviceMountPath(volume.volumeSpec) - if err != nil { - return "", err - } - if volume.blockVolumeMapper != nil { - deviceMountPath, err = - volume.blockVolumeMapper.GetGlobalMapPath(volume.volumeSpec) - if err != nil { + // for block volume, we return its global map path + return volume.blockVolumeMapper.GetGlobalMapPath(volume.volumeSpec) + } else if volume.attachablePlugin != nil { + // for filesystem volume, we return its device mount path if the plugin implements AttachableVolumePlugin + volumeAttacher, err := volume.attachablePlugin.NewAttacher() + if volumeAttacher == nil || err != nil { return "", err } + return volumeAttacher.GetDeviceMountPath(volume.volumeSpec) + } else { + return "", fmt.Errorf("blockVolumeMapper or attachablePlugin required") } - return deviceMountPath, nil } func (rc *reconciler) updateStates(volumesNeedUpdate map[v1.UniqueVolumeName]*reconstructedVolume) error { @@ -632,7 +627,8 @@ func (rc *reconciler) updateStates(volumesNeedUpdate map[v1.UniqueVolumeName]*re continue } klog.V(4).Infof("Volume: %s (pod UID %s) is marked as mounted and added into the actual state", volume.volumeName, volume.podName) - if volume.attachablePlugin != nil { + // If the volume has device to mount, we mark its device as mounted. + if volume.attachablePlugin != nil || volume.blockVolumeMapper != nil { deviceMountPath, err := getDeviceMountPath(volume) if err != nil { klog.Errorf("Could not find device mount path for volume %s", volume.volumeName) diff --git a/pkg/volume/local/local.go b/pkg/volume/local/local.go index faef40d7afd..987e1e65216 100644 --- a/pkg/volume/local/local.go +++ b/pkg/volume/local/local.go @@ -218,6 +218,7 @@ func (plugin *localVolumePlugin) ConstructBlockVolumeSpec(podUID types.UID, volu Spec: v1.PersistentVolumeSpec{ PersistentVolumeSource: v1.PersistentVolumeSource{ Local: &v1.LocalVolumeSource{ + // Not needed because we don't need to detach local device from the host. Path: "", }, },