mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 18:54:06 +00:00
Merge pull request #121795 from carlory/cleanup-after-blockvolume-featuregate-removed
cleanup todo after feature.BlockVolume gate was removed
This commit is contained in:
commit
8cc47b64b2
@ -522,17 +522,11 @@ func (dswp *desiredStateOfWorldPopulator) createVolumeSpec(
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: replace this with util.GetVolumeMode() when features.BlockVolume is removed.
|
||||
// The function will return the right value then.
|
||||
volumeMode := v1.PersistentVolumeFilesystem
|
||||
if volumeSpec.PersistentVolume != nil && volumeSpec.PersistentVolume.Spec.VolumeMode != nil {
|
||||
volumeMode = *volumeSpec.PersistentVolume.Spec.VolumeMode
|
||||
volumeMode, err := util.GetVolumeMode(volumeSpec)
|
||||
if err != nil {
|
||||
return nil, nil, "", err
|
||||
}
|
||||
|
||||
// TODO: remove features.BlockVolume checks / comments after no longer needed
|
||||
// Error if a container has volumeMounts but the volumeMode of PVC isn't Filesystem.
|
||||
// Do not check feature gate here to make sure even when the feature is disabled in kubelet,
|
||||
// because controller-manager / API server can already contain block PVs / PVCs.
|
||||
if mounts.Has(podVolume.Name) && volumeMode != v1.PersistentVolumeFilesystem {
|
||||
return nil, nil, "", fmt.Errorf(
|
||||
"volume %s has volumeMode %s, but is specified in volumeMounts",
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
"time"
|
||||
|
||||
"k8s.io/klog/v2/ktesting"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"fmt"
|
||||
|
||||
@ -848,13 +849,13 @@ func TestCreateVolumeSpec_Valid_Nil_VolumeMounts(t *testing.T) {
|
||||
},
|
||||
Spec: v1.PersistentVolumeSpec{
|
||||
ClaimRef: &v1.ObjectReference{Namespace: "ns", Name: "file-bound"},
|
||||
VolumeMode: nil,
|
||||
VolumeMode: ptr.To(v1.PersistentVolumeFilesystem),
|
||||
},
|
||||
}
|
||||
pvc := &v1.PersistentVolumeClaim{
|
||||
Spec: v1.PersistentVolumeClaimSpec{
|
||||
VolumeName: "dswp-test-volume-name",
|
||||
VolumeMode: nil,
|
||||
VolumeMode: ptr.To(v1.PersistentVolumeFilesystem),
|
||||
},
|
||||
Status: v1.PersistentVolumeClaimStatus{
|
||||
Phase: v1.ClaimBound,
|
||||
@ -1285,6 +1286,7 @@ func TestCheckVolumeSELinux(t *testing.T) {
|
||||
Name: "dswp-test-volume-name",
|
||||
},
|
||||
Spec: v1.PersistentVolumeSpec{
|
||||
VolumeMode: ptr.To(v1.PersistentVolumeFilesystem),
|
||||
PersistentVolumeSource: v1.PersistentVolumeSource{RBD: &v1.RBDPersistentVolumeSource{}},
|
||||
Capacity: volumeCapacity(1),
|
||||
ClaimRef: &v1.ObjectReference{Namespace: "ns", Name: "file-bound"},
|
||||
@ -1293,6 +1295,7 @@ func TestCheckVolumeSELinux(t *testing.T) {
|
||||
}
|
||||
pvc := &v1.PersistentVolumeClaim{
|
||||
Spec: v1.PersistentVolumeClaimSpec{
|
||||
VolumeMode: ptr.To(v1.PersistentVolumeFilesystem),
|
||||
VolumeName: pv.Name,
|
||||
Resources: v1.VolumeResourceRequirements{
|
||||
Requests: pv.Spec.Capacity,
|
||||
|
Loading…
Reference in New Issue
Block a user