Skip to content

Commit 46b1e26

Browse files
committed
support local volume block mode reconstruction
1 parent 7c7ba19 commit 46b1e26

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
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
},

0 commit comments

Comments
 (0)