Move CSIVolumeFSGroupPolicy to beta

This commit is contained in:
Christian Huffman
2020-10-21 13:30:13 -04:00
parent 6b9348e878
commit 01f70d69b7
4 changed files with 50 additions and 5 deletions

View File

@@ -1873,7 +1873,12 @@ func TestCSIDriverValidationUpdate(t *testing.T) {
notRequiresRepublish := false
=======
resourceVersion := "1"
<<<<<<< HEAD
>>>>>>> Relax validation for CSIVolumeFSGroupPolicy
=======
invalidFSGroupPolicy := storage.ReadWriteOnceWithFSTypeFSGroupPolicy
invalidFSGroupPolicy = "invalid-mode"
>>>>>>> Move CSIVolumeFSGroupPolicy to beta
old := storage.CSIDriver{
ObjectMeta: metav1.ObjectMeta{Name: driverName, ResourceVersion: resourceVersion},
Spec: storage.CSIDriverSpec{
@@ -1887,11 +1892,27 @@ func TestCSIDriverValidationUpdate(t *testing.T) {
},
}
// Currently there is only one success case: exactly the same
// as the existing object.
successCases := []storage.CSIDriver{old}
// Currently we compare the object against itself
// and ensure updates succeed
successCases := []storage.CSIDriver{
old,
// An invalid FSGroupPolicy should still pass
{
ObjectMeta: metav1.ObjectMeta{Name: driverName, ResourceVersion: resourceVersion},
Spec: storage.CSIDriverSpec{
AttachRequired: &attachNotRequired,
PodInfoOnMount: &notPodInfoOnMount,
VolumeLifecycleModes: []storage.VolumeLifecycleMode{
storage.VolumeLifecycleEphemeral,
storage.VolumeLifecyclePersistent,
},
FSGroupPolicy: &invalidFSGroupPolicy,
},
},
}
for _, csiDriver := range successCases {
if errs := ValidateCSIDriverUpdate(&csiDriver, &old); len(errs) != 0 {
newDriver := csiDriver.DeepCopy()
if errs := ValidateCSIDriverUpdate(&csiDriver, newDriver); len(errs) != 0 {
t.Errorf("expected success for %+v: %v", csiDriver, errs)
}
}
@@ -1967,6 +1988,21 @@ func TestCSIDriverValidationUpdate(t *testing.T) {
}
},
},
{
name: "FSGroupPolicy invalidated",
modify: func(new *storage.CSIDriver) {
invalidFSGroupPolicy := storage.ReadWriteOnceWithFSTypeFSGroupPolicy
invalidFSGroupPolicy = "invalid"
new.Spec.FSGroupPolicy = &invalidFSGroupPolicy
},
},
{
name: "FSGroupPolicy changed",
modify: func(new *storage.CSIDriver) {
fileFSGroupPolicy := storage.FileFSGroupPolicy
new.Spec.FSGroupPolicy = &fileFSGroupPolicy
},
},
}
for _, test := range errorCases {