Merge pull request #117752 from liggitt/automated-cherry-pick-of-#117751-upstream-release-1.27

Automated cherry pick of #117751: Disable NewVolumeManagerReconstruction / SELinuxMountReadWriteOncePod feature gates
This commit is contained in:
Kubernetes Prow Robot
2023-05-05 13:51:17 -07:00
committed by GitHub
3 changed files with 92 additions and 3 deletions

View File

@@ -1650,6 +1650,9 @@ func TestCSINodeUpdateValidation(t *testing.T) {
}
func TestCSIDriverValidation(t *testing.T) {
// assume this feature is on for this test, detailed enabled/disabled tests in TestCSIDriverValidationSELinuxMountEnabledDisabled
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.SELinuxMountReadWriteOncePod, true)()
driverName := "test-driver"
longName := "my-a-b-c-d-c-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-ABCDEFGHIJKLMNOPQRSTUVWXYZ-driver"
invalidName := "-invalid-@#$%^&*()-"
@@ -1925,6 +1928,9 @@ func TestCSIDriverValidation(t *testing.T) {
}
func TestCSIDriverValidationUpdate(t *testing.T) {
// assume this feature is on for this test, detailed enabled/disabled tests in TestCSIDriverValidationSELinuxMountEnabledDisabled
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.SELinuxMountReadWriteOncePod, true)()
driverName := "test-driver"
longName := "my-a-b-c-d-c-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-ABCDEFGHIJKLMNOPQRSTUVWXYZ-driver"
invalidName := "-invalid-@#$%^&*()-"
@@ -2329,7 +2335,7 @@ func TestCSIServiceAccountToken(t *testing.T) {
}
}
func TestCSIDriverValidationSELinuxMountAlpha(t *testing.T) {
func TestCSIDriverValidationSELinuxMountEnabledDisabled(t *testing.T) {
tests := []struct {
name string
featureEnabled bool
@@ -2383,4 +2389,84 @@ func TestCSIDriverValidationSELinuxMountAlpha(t *testing.T) {
}
})
}
updateTests := []struct {
name string
featureEnabled bool
oldValue *bool
newValue *bool
expectError bool
}{{
name: "feature enabled, nil->nil",
featureEnabled: true,
oldValue: nil,
newValue: nil,
expectError: true, // populated by defaulting and required when feature is enabled
}, {
name: "feature enabled, nil->set",
featureEnabled: true,
oldValue: nil,
newValue: utilpointer.Bool(true),
expectError: false,
}, {
name: "feature enabled, set->set",
featureEnabled: true,
oldValue: utilpointer.Bool(true),
newValue: utilpointer.Bool(true),
expectError: false,
}, {
name: "feature enabled, set->nil",
featureEnabled: true,
oldValue: utilpointer.Bool(true),
newValue: nil,
expectError: true, // populated by defaulting and required when feature is enabled
}, {
name: "feature disabled, nil->nil",
featureEnabled: false,
oldValue: nil,
newValue: nil,
expectError: false,
}, {
name: "feature disabled, nil->set",
featureEnabled: false,
oldValue: nil,
newValue: utilpointer.Bool(true),
expectError: false,
}, {
name: "feature disabled, set->set",
featureEnabled: false,
oldValue: utilpointer.Bool(true),
newValue: utilpointer.Bool(true),
expectError: false,
}, {
name: "feature disabled, set->nil",
featureEnabled: false,
oldValue: utilpointer.Bool(true),
newValue: nil,
expectError: false,
}}
for _, test := range updateTests {
t.Run(test.name, func(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.SELinuxMountReadWriteOncePod, test.featureEnabled)()
oldCSIDriver := &storage.CSIDriver{
ObjectMeta: metav1.ObjectMeta{Name: "foo", ResourceVersion: "1"},
Spec: storage.CSIDriverSpec{
AttachRequired: utilpointer.Bool(true),
PodInfoOnMount: utilpointer.Bool(true),
RequiresRepublish: utilpointer.Bool(true),
StorageCapacity: utilpointer.Bool(true),
SELinuxMount: test.oldValue,
},
}
newCSIDriver := oldCSIDriver.DeepCopy()
newCSIDriver.Spec.SELinuxMount = test.newValue
err := ValidateCSIDriverUpdate(newCSIDriver, oldCSIDriver)
if test.expectError && err == nil {
t.Error("Expected validation error, got nil")
}
if !test.expectError && err != nil {
t.Errorf("Validation returned error: %s", err)
}
})
}
}

View File

@@ -1078,7 +1078,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
NetworkPolicyStatus: {Default: false, PreRelease: featuregate.Alpha},
NewVolumeManagerReconstruction: {Default: true, PreRelease: featuregate.Beta},
NewVolumeManagerReconstruction: {Default: false, PreRelease: featuregate.Beta}, // disabled for https://github.com/kubernetes/kubernetes/issues/117745
NodeLogQuery: {Default: false, PreRelease: featuregate.Alpha},
@@ -1160,7 +1160,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
NodeInclusionPolicyInPodTopologySpread: {Default: true, PreRelease: featuregate.Beta},
SELinuxMountReadWriteOncePod: {Default: true, PreRelease: featuregate.Beta},
SELinuxMountReadWriteOncePod: {Default: false, PreRelease: featuregate.Beta}, // disabled for https://github.com/kubernetes/kubernetes/issues/117745
InPlacePodVerticalScaling: {Default: false, PreRelease: featuregate.Alpha},

View File

@@ -20,6 +20,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
@@ -432,6 +433,8 @@ func TestCSIDriverValidation(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
// assume this feature is on for this test, detailed enabled/disabled tests in TestCSIDriverValidationSELinuxMountEnabledDisabled
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.SELinuxMountReadWriteOncePod, true)()
testValidation := func(csiDriver *storage.CSIDriver, apiVersion string) field.ErrorList {
ctx := genericapirequest.WithRequestInfo(genericapirequest.NewContext(), &genericapirequest.RequestInfo{