Skip to content

Commit 24ae4d6

Browse files
authored
Merge pull request kubernetes#84173 from cofyc/fix83693
Support local volume block mode reconstruction
2 parents 2a1ac8b + 46b1e26 commit 24ae4d6

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

pkg/kubelet/volumemanager/reconciler/reconciler.go

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -586,24 +586,19 @@ func (rc *reconciler) updateDevicePath(volumesNeedUpdate map[v1.UniqueVolumeName
586586
}
587587

588588
func getDeviceMountPath(volume *reconstructedVolume) (string, error) {
589-
volumeAttacher, err := volume.attachablePlugin.NewAttacher()
590-
if volumeAttacher == nil || err != nil {
591-
return "", err
592-
}
593-
deviceMountPath, err :=
594-
volumeAttacher.GetDeviceMountPath(volume.volumeSpec)
595-
if err != nil {
596-
return "", err
597-
}
598-
599589
if volume.blockVolumeMapper != nil {
600-
deviceMountPath, err =
601-
volume.blockVolumeMapper.GetGlobalMapPath(volume.volumeSpec)
602-
if err != nil {
590+
// for block volume, we return its global map path
591+
return volume.blockVolumeMapper.GetGlobalMapPath(volume.volumeSpec)
592+
} else if volume.attachablePlugin != nil {
593+
// for filesystem volume, we return its device mount path if the plugin implements AttachableVolumePlugin
594+
volumeAttacher, err := volume.attachablePlugin.NewAttacher()
595+
if volumeAttacher == nil || err != nil {
603596
return "", err
604597
}
598+
return volumeAttacher.GetDeviceMountPath(volume.volumeSpec)
599+
} else {
600+
return "", fmt.Errorf("blockVolumeMapper or attachablePlugin required")
605601
}
606-
return deviceMountPath, nil
607602
}
608603

609604
func (rc *reconciler) updateStates(volumesNeedUpdate map[v1.UniqueVolumeName]*reconstructedVolume) error {
@@ -632,7 +627,8 @@ func (rc *reconciler) updateStates(volumesNeedUpdate map[v1.UniqueVolumeName]*re
632627
continue
633628
}
634629
klog.V(4).Infof("Volume: %s (pod UID %s) is marked as mounted and added into the actual state", volume.volumeName, volume.podName)
635-
if volume.attachablePlugin != nil {
630+
// If the volume has device to mount, we mark its device as mounted.
631+
if volume.attachablePlugin != nil || volume.blockVolumeMapper != nil {
636632
deviceMountPath, err := getDeviceMountPath(volume)
637633
if err != nil {
638634
klog.Errorf("Could not find device mount path for volume %s", volume.volumeName)

pkg/volume/local/local.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ func (plugin *localVolumePlugin) ConstructBlockVolumeSpec(podUID types.UID, volu
218218
Spec: v1.PersistentVolumeSpec{
219219
PersistentVolumeSource: v1.PersistentVolumeSource{
220220
Local: &v1.LocalVolumeSource{
221+
// Not needed because we don't need to detach local device from the host.
221222
Path: "",
222223
},
223224
},

test/e2e/storage/testsuites/disruptive.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ func InitDisruptiveTestSuite() TestSuite {
5050
},
5151
}
5252
}
53-
5453
func (s *disruptiveTestSuite) getTestSuiteInfo() TestSuiteInfo {
5554
return s.tsInfo
5655
}
@@ -145,12 +144,6 @@ func (s *disruptiveTestSuite) defineTests(driver TestDriver, pattern testpattern
145144
if (pattern.VolMode == v1.PersistentVolumeBlock && t.runTestBlock != nil) ||
146145
(pattern.VolMode == v1.PersistentVolumeFilesystem && t.runTestFile != nil) {
147146
ginkgo.It(t.testItStmt, func() {
148-
149-
if pattern.VolMode == v1.PersistentVolumeBlock && driver.GetDriverInfo().InTreePluginName == "kubernetes.io/local-volume" {
150-
// TODO: https://github.com/kubernetes/kubernetes/issues/74552
151-
framework.Skipf("Local volume volume plugin does not support block volume reconstruction (#74552)")
152-
}
153-
154147
init()
155148
defer cleanup()
156149

0 commit comments

Comments
 (0)