E57D Graduate image volume sources to beta · kubernetes/kubernetes@ca4065d · GitHub
[go: up one dir, main page]

Skip to content

Commit ca4065d

Browse files
committed
Graduate image volume sources to beta
Graduate the feature to beta, by: - Allowing `subPath`/`subPathExpr` for image volumes - Modifying the CRI to pass down the (resolved) sub path - Adding metrics which are outlined in the KEP Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
1 parent 2642d82 commit ca4065d

File tree

21 files changed

+697
-474
lines changed

21 files changed

+697
-474
lines changed

api/openapi-spec/swagger.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/openapi-spec/v3/api__v1_openapi.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/openapi-spec/v3/apis__apps__v1_openapi.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/openapi-spec/v3/apis__batch__v1_openapi.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/core/types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ type VolumeSource struct {
220220
// The types of objects that may be mounted by this volume are defined by the container runtime implementation on a host machine and at minimum must include all valid types supported by the container image field.
221221
// The OCI object gets mounted in a single directory (spec.containers[*].volumeMounts.mountPath) by merging the manifest layers in the same way as for container images.
222222
// The volume will be mounted read-only (ro) and non-executable files (noexec).
223-
// Sub path mounts for containers are not supported (spec.containers[*].volumeMounts.subpath).
224223
// The field spec.securityContext.fsGroupChangePolicy has no effect on this volume type.
225224
// +featureGate=ImageVolume
226225
// +optional

pkg/apis/core/validation/validation.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,16 +2937,6 @@ func ValidateVolumeMounts(mounts []core.VolumeMount, voldevices map[string]strin
29372937
allErrs = append(allErrs, field.Invalid(idxPath.Child("mountPath"), mnt.MountPath, "must not already exist as a path in volumeDevices"))
29382938
}
29392939

2940-
// Disallow subPath/subPathExpr for image volumes
2941-
if v, ok := volumes[mnt.Name]; ok && v.Image != nil {
2942-
if len(mnt.SubPath) != 0 {
2943-
allErrs = append(allErrs, field.Invalid(idxPath.Child("subPath"), mnt.SubPath, "not allowed in image volume sources"))
2944-
}
2945-
if len(mnt.SubPathExpr) != 0 {
2946-
allErrs = append(allErrs, field.Invalid(idxPath.Child("subPathExpr"), mnt.SubPathExpr, "not allowed in image volume sources"))
2947-
}
2948-
}
2949-
29502940
if len(mnt.SubPath) > 0 {
29512941
allErrs = append(allErrs, validateLocalDescendingPath(mnt.SubPath, fldPath.Child("subPath"))...)
29522942
}

pkg/apis/core/validation/validation_test.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7146,23 +7146,21 @@ func TestValidateVolumeMounts(t *testing.T) {
71467146
}
71477147

71487148
errorCases := map[string][]core.VolumeMount{
7149-
"empty name": {{Name: "", MountPath: "/foo"}},
7150-
"name not found": {{Name: "", MountPath: "/foo"}},
7151-
"empty mountpath": {{Name: "abc", MountPath: ""}},
7152-
"mountpath collision": {{Name: "foo", MountPath: "/path/a"}, {Name: "bar", MountPath: "/path/a"}},
7153-
"absolute subpath": {{Name: "abc", MountPath: "/bar", SubPath: "/baz"}},
7154-
"subpath in ..": {{Name: "abc", MountPath: "/bar", SubPath: "../baz"}},
7155-
"subpath contains ..": {{Name: "abc", MountPath: "/bar", SubPath: "baz/../bat"}},
7156-
"subpath ends in ..": {{Name: "abc", MountPath: "/bar", SubPath: "./.."}},
7157-
"disabled MountPropagation feature gate": {{Name: "abc", MountPath: "/bar", MountPropagation: &propagation}},
7158-
"name exists in volumeDevice": {{Name: "xyz", MountPath: "/bar"}},
7159-
"mountpath exists in volumeDevice": {{Name: "uvw", MountPath: "/mnt/exists"}},
7160-
"both exist in volumeDevice": {{Name: "xyz", MountPath: "/mnt/exists"}},
7161-
"rro but not ro": {{Name: "123", MountPath: "/rro-bad1", ReadOnly: false, RecursiveReadOnly: ptr.To(core.RecursiveReadOnlyEnabled)}},
7162-
"rro with incompatible propagation": {{Name: "123", MountPath: "/rro-bad2", ReadOnly: true, RecursiveReadOnly: ptr.To(core.RecursiveReadOnlyEnabled), MountPropagation: ptr.To(core.MountPropagationHostToContainer)}},
7163-
"rro-if-possible but not ro": {{Name: "123", MountPath: "/rro-bad1", ReadOnly: false, RecursiveReadOnly: ptr.To(core.RecursiveReadOnlyIfPossible)}},
7164-
"subPath not allowed for image volume sources": {{Name: "image-volume", MountPath: "/image-volume-err-1", SubPath: "/foo"}},
7165-
"subPathExpr not allowed for image volume sources": {{Name: "image-volume", MountPath: "/image-volume-err-2", SubPathExpr: "$(POD_NAME)"}},
7149+
"empty name": {{Name: "", MountPath: "/foo"}},
7150+
"name not found": {{Name: "", MountPath: "/foo"}},
7151+
"empty mountpath": {{Name: "abc", MountPath: ""}},
7152+
"mountpath collision": {{Name: "foo", MountPath: "/path/a"}, {Name: "bar", MountPath: "/path/a"}},
7153+
"absolute subpath": {{Name: "abc", MountPath: "/bar", SubPath: "/baz"}},
7154+
"subpath in ..": {{Name: "abc", MountPath: "/bar", SubPath: "../baz"}},
7155+
"subpath contains ..": {{Name: "abc", MountPath: "/bar", SubPath: "baz/../bat"}},
7156+
"subpath ends in ..": {{Name: "abc", MountPath: "/bar", SubPath: "./.."}},
7157+
"disabled MountPropagation feature gate": {{Name: "abc", MountPath: "/bar", MountPropagation: &propagation}},
7158+
"name exists in volumeDevice": {{Name: "xyz", MountPath: "/bar"}},
7159+
"mountpath exists in volumeDevice": {{Name: "uvw", MountPath: "/mnt/exists"}},
7160+
"both exist in volumeDevice": {{Name: "xyz", MountPath: "/mnt/exists"}},
7161+
"rro but not ro": {{Name: "123", MountPath: "/rro-bad1", ReadOnly: false, RecursiveReadOnly: ptr.To(core.RecursiveReadOnlyEnabled)}},
7162+
"rro with incompatible propagation": {{Name: "123", MountPath: "/rro-bad2", ReadOnly: true, RecursiveReadOnly: ptr.To(core.RecursiveReadOnlyEnabled), MountPropagation: ptr.To(core.MountPropagationHostToContainer)}},
7163+
"rro-if-possible but not ro": {{Name: "123", MountPath: "/rro-bad1", ReadOnly: false, RecursiveReadOnly: ptr.To(core.RecursiveReadOnlyIfPossible)}},
71667164
}
71677165
badVolumeDevice := []core.VolumeDevice{
71687166
{Name: "xyz", DevicePath: "/mnt/exists"},

pkg/features/versioned_kube_features.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
404404

405405
ImageVolume: {
406406
{Version: version.MustParse("1.31"), Default: false, PreRelease: featuregate.Alpha},
407+
{Version: version.MustParse("1.33"), Default: false, PreRelease: featuregate.Beta},
407408
},
408409

409410
InPlacePodVerticalScaling: {

0 commit comments

Comments
 (0)
0