mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Move nil check for mapperPlugin earlier in reconstructVolume
This commit is contained in:
parent
2306d2ff31
commit
c130b77a48
@ -470,6 +470,11 @@ func (rc *reconciler) reconstructVolume(volume podVolume) (*reconstructedVolume,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// TODO: remove feature gate check after no longer needed
|
||||||
|
if utilfeature.DefaultFeatureGate.Enabled(features.BlockVolume) && volume.volumeMode == v1.PersistentVolumeBlock && mapperPlugin == nil {
|
||||||
|
return nil, fmt.Errorf("Could not find block volume plugin %q (spec.Name: %q) pod %q (UID: %q)", volume.pluginName, volume.volumeSpecName, volume.podName, pod.UID)
|
||||||
|
}
|
||||||
|
|
||||||
volumeSpec, err := rc.operationExecutor.ReconstructVolumeOperation(
|
volumeSpec, err := rc.operationExecutor.ReconstructVolumeOperation(
|
||||||
volume.volumeMode,
|
volume.volumeMode,
|
||||||
plugin,
|
plugin,
|
||||||
@ -501,22 +506,20 @@ func (rc *reconciler) reconstructVolume(volume podVolume) (*reconstructedVolume,
|
|||||||
// TODO: remove feature gate check after no longer needed
|
// TODO: remove feature gate check after no longer needed
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.BlockVolume) && volume.volumeMode == v1.PersistentVolumeBlock {
|
if utilfeature.DefaultFeatureGate.Enabled(features.BlockVolume) && volume.volumeMode == v1.PersistentVolumeBlock {
|
||||||
var newMapperErr error
|
var newMapperErr error
|
||||||
if mapperPlugin != nil {
|
volumeMapper, newMapperErr = mapperPlugin.NewBlockVolumeMapper(
|
||||||
volumeMapper, newMapperErr = mapperPlugin.NewBlockVolumeMapper(
|
volumeSpec,
|
||||||
volumeSpec,
|
pod,
|
||||||
pod,
|
volumepkg.VolumeOptions{})
|
||||||
volumepkg.VolumeOptions{})
|
if newMapperErr != nil {
|
||||||
if newMapperErr != nil {
|
return nil, fmt.Errorf(
|
||||||
return nil, fmt.Errorf(
|
"reconstructVolume.NewBlockVolumeMapper failed for volume %q (spec.Name: %q) pod %q (UID: %q) with: %v",
|
||||||
"reconstructVolume.NewBlockVolumeMapper failed for volume %q (spec.Name: %q) pod %q (UID: %q) with: %v",
|
uniqueVolumeName,
|
||||||
uniqueVolumeName,
|
volumeSpec.Name(),
|
||||||
volumeSpec.Name(),
|
volume.podName,
|
||||||
volume.podName,
|
pod.UID,
|
||||||
pod.UID,
|
newMapperErr)
|
||||||
newMapperErr)
|
|
||||||
}
|
|
||||||
checkPath, _ = volumeMapper.GetPodDeviceMapPath()
|
|
||||||
}
|
}
|
||||||
|
checkPath, _ = volumeMapper.GetPodDeviceMapPath()
|
||||||
} else {
|
} else {
|
||||||
var err error
|
var err error
|
||||||
volumeMounter, err = plugin.NewMounter(
|
volumeMounter, err = plugin.NewMounter(
|
||||||
|
@ -899,13 +899,7 @@ func (oe *operationExecutor) ReconstructVolumeOperation(
|
|||||||
// Block Volume case
|
// Block Volume case
|
||||||
// Create volumeSpec from mount path
|
// Create volumeSpec from mount path
|
||||||
klog.V(5).Infof("Starting operationExecutor.ReconstructVolume")
|
klog.V(5).Infof("Starting operationExecutor.ReconstructVolume")
|
||||||
if mapperPlugin == nil {
|
|
||||||
return nil, fmt.Errorf("Could not find block volume plugin %q (spec.Name: %q) pod %q (UID: %q)",
|
|
||||||
pluginName,
|
|
||||||
volumeSpecName,
|
|
||||||
podName,
|
|
||||||
uid)
|
|
||||||
}
|
|
||||||
// volumePath contains volumeName on the path. In the case of block volume, {volumeName} is symbolic link
|
// volumePath contains volumeName on the path. In the case of block volume, {volumeName} is symbolic link
|
||||||
// corresponding to raw block device.
|
// corresponding to raw block device.
|
||||||
// ex. volumePath: pods/{podUid}}/{DefaultKubeletVolumeDevicesDirName}/{escapeQualifiedPluginName}/{volumeName}
|
// ex. volumePath: pods/{podUid}}/{DefaultKubeletVolumeDevicesDirName}/{escapeQualifiedPluginName}/{volumeName}
|
||||||
|
Loading…
Reference in New Issue
Block a user