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) { 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 { if volume.blockVolumeMapper != nil {
deviceMountPath, err = // for block volume, we return its global map path
volume.blockVolumeMapper.GetGlobalMapPath(volume.volumeSpec) return volume.blockVolumeMapper.GetGlobalMapPath(volume.volumeSpec)
if err != nil { } 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 "", 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 { func (rc *reconciler) updateStates(volumesNeedUpdate map[v1.UniqueVolumeName]*reconstructedVolume) error {
@@ -632,7 +627,8 @@ func (rc *reconciler) updateStates(volumesNeedUpdate map[v1.UniqueVolumeName]*re
continue continue
} }
klog.V(4).Infof("Volume: %s (pod UID %s) is marked as mounted and added into the actual state", volume.volumeName, volume.podName) 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) deviceMountPath, err := getDeviceMountPath(volume)
if err != nil { if err != nil {
klog.Errorf("Could not find device mount path for volume %s", volume.volumeName) 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{ Spec: v1.PersistentVolumeSpec{
PersistentVolumeSource: v1.PersistentVolumeSource{ PersistentVolumeSource: v1.PersistentVolumeSource{
Local: &v1.LocalVolumeSource{ Local: &v1.LocalVolumeSource{
// Not needed because we don't need to detach local device from the host.
Path: "", Path: "",
}, },
}, },

View File

@@ -50,7 +50,6 @@ func InitDisruptiveTestSuite() TestSuite {
}, },
} }
} }
func (s *disruptiveTestSuite) getTestSuiteInfo() TestSuiteInfo { func (s *disruptiveTestSuite) getTestSuiteInfo() TestSuiteInfo {
return s.tsInfo return s.tsInfo
} }
@@ -145,12 +144,6 @@ func (s *disruptiveTestSuite) defineTests(driver TestDriver, pattern testpattern
if (pattern.VolMode == v1.PersistentVolumeBlock && t.runTestBlock != nil) || if (pattern.VolMode == v1.PersistentVolumeBlock && t.runTestBlock != nil) ||
(pattern.VolMode == v1.PersistentVolumeFilesystem && t.runTestFile != nil) { (pattern.VolMode == v1.PersistentVolumeFilesystem && t.runTestFile != nil) {
ginkgo.It(t.testItStmt, func() { 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() init()
defer cleanup() defer cleanup()