Merge pull request #84173 from cofyc/fix83693

Support local volume block mode reconstruction
This commit is contained in:
Kubernetes Prow Robot
2019-10-25 19:23:23 -07:00
committed by GitHub
3 changed files with 12 additions and 22 deletions

View File

@@ -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)

View File

@@ -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: "",
},
},

View File

@@ -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()