Move CSIInlineVolume feature to GA
This commit is contained in:
@@ -47,9 +47,6 @@ func (csiDriverStrategy) NamespaceScoped() bool {
|
||||
// PrepareForCreate clears the fields for which the corresponding feature is disabled.
|
||||
func (csiDriverStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
||||
csiDriver := obj.(*storage.CSIDriver)
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.CSIInlineVolume) {
|
||||
csiDriver.Spec.VolumeLifecycleModes = nil
|
||||
}
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.SELinuxMountReadWriteOncePod) {
|
||||
csiDriver.Spec.SELinuxMount = nil
|
||||
}
|
||||
@@ -81,11 +78,6 @@ func (csiDriverStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.
|
||||
newCSIDriver := obj.(*storage.CSIDriver)
|
||||
oldCSIDriver := old.(*storage.CSIDriver)
|
||||
|
||||
if oldCSIDriver.Spec.VolumeLifecycleModes == nil &&
|
||||
!utilfeature.DefaultFeatureGate.Enabled(features.CSIInlineVolume) {
|
||||
newCSIDriver.Spec.VolumeLifecycleModes = nil
|
||||
}
|
||||
|
||||
if oldCSIDriver.Spec.SELinuxMount == nil &&
|
||||
!utilfeature.DefaultFeatureGate.Enabled(features.SELinuxMountReadWriteOncePod) {
|
||||
newCSIDriver.Spec.SELinuxMount = nil
|
||||
|
@@ -79,72 +79,6 @@ func TestCSIDriverStrategy(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCSIDriverPrepareForCreate(t *testing.T) {
|
||||
ctx := genericapirequest.WithRequestInfo(genericapirequest.NewContext(), &genericapirequest.RequestInfo{
|
||||
APIGroup: "storage.k8s.io",
|
||||
APIVersion: "v1",
|
||||
Resource: "csidrivers",
|
||||
})
|
||||
|
||||
attachRequired := true
|
||||
podInfoOnMount := true
|
||||
storageCapacity := true
|
||||
requiresRepublish := true
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
withInline bool
|
||||
}{
|
||||
{
|
||||
name: "inline enabled",
|
||||
withInline: true,
|
||||
},
|
||||
{
|
||||
name: "inline disabled",
|
||||
withInline: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIInlineVolume, test.withInline)()
|
||||
|
||||
csiDriver := &storage.CSIDriver{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
Spec: storage.CSIDriverSpec{
|
||||
AttachRequired: &attachRequired,
|
||||
PodInfoOnMount: &podInfoOnMount,
|
||||
StorageCapacity: &storageCapacity,
|
||||
VolumeLifecycleModes: []storage.VolumeLifecycleMode{
|
||||
storage.VolumeLifecyclePersistent,
|
||||
},
|
||||
TokenRequests: []storage.TokenRequest{},
|
||||
RequiresRepublish: &requiresRepublish,
|
||||
},
|
||||
}
|
||||
Strategy.PrepareForCreate(ctx, csiDriver)
|
||||
errs := Strategy.Validate(ctx, csiDriver)
|
||||
if len(errs) != 0 {
|
||||
t.Errorf("unexpected validating errors: %v", errs)
|
||||
}
|
||||
if csiDriver.Spec.StorageCapacity == nil || *csiDriver.Spec.StorageCapacity != storageCapacity {
|
||||
t.Errorf("StorageCapacity modified: %v", csiDriver.Spec.StorageCapacity)
|
||||
}
|
||||
if test.withInline {
|
||||
if len(csiDriver.Spec.VolumeLifecycleModes) != 1 {
|
||||
t.Errorf("VolumeLifecycleModes modified: %v", csiDriver.Spec)
|
||||
}
|
||||
} else {
|
||||
if len(csiDriver.Spec.VolumeLifecycleModes) != 0 {
|
||||
t.Errorf("VolumeLifecycleModes not stripped: %v", csiDriver.Spec)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCSIDriverPrepareForUpdate(t *testing.T) {
|
||||
ctx := genericapirequest.WithRequestInfo(genericapirequest.NewContext(), &genericapirequest.RequestInfo{
|
||||
APIGroup: "storage.k8s.io",
|
||||
@@ -171,18 +105,6 @@ func TestCSIDriverPrepareForUpdate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
driverWithEphemeral := &storage.CSIDriver{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
Spec: storage.CSIDriverSpec{
|
||||
AttachRequired: &attachRequired,
|
||||
PodInfoOnMount: &podInfoOnMount,
|
||||
VolumeLifecycleModes: []storage.VolumeLifecycleMode{
|
||||
storage.VolumeLifecycleEphemeral,
|
||||
},
|
||||
},
|
||||
}
|
||||
enabled := true
|
||||
disabled := false
|
||||
gcp := "gcp"
|
||||
@@ -233,7 +155,6 @@ func TestCSIDriverPrepareForUpdate(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
old, update *storage.CSIDriver
|
||||
csiInlineVolumeEnabled bool
|
||||
seLinuxMountReadWriteOncePodEnabled bool
|
||||
wantCapacity *bool
|
||||
wantModes []storage.VolumeLifecycleMode
|
||||
@@ -255,22 +176,9 @@ func TestCSIDriverPrepareForUpdate(t *testing.T) {
|
||||
wantCapacity: &disabled,
|
||||
},
|
||||
{
|
||||
name: "inline feature enabled, before: none, update: persistent",
|
||||
csiInlineVolumeEnabled: true,
|
||||
old: driverWithNothing,
|
||||
update: driverWithPersistent,
|
||||
wantModes: resultPersistent,
|
||||
},
|
||||
{
|
||||
name: "inline feature disabled, before: none, update: persistent",
|
||||
name: "inline feature enabled, before: none, update: persistent",
|
||||
old: driverWithNothing,
|
||||
update: driverWithPersistent,
|
||||
wantModes: nil,
|
||||
},
|
||||
{
|
||||
name: "inline feature disabled, before: ephemeral, update: persistent",
|
||||
old: driverWithEphemeral,
|
||||
update: driverWithPersistent,
|
||||
wantModes: resultPersistent,
|
||||
},
|
||||
{
|
||||
@@ -333,7 +241,6 @@ func TestCSIDriverPrepareForUpdate(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIInlineVolume, test.csiInlineVolumeEnabled)()
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.SELinuxMountReadWriteOncePod, test.seLinuxMountReadWriteOncePodEnabled)()
|
||||
|
||||
csiDriver := test.update.DeepCopy()
|
||||
|
Reference in New Issue
Block a user