From e07d7365229f7b711518dc22b5a11219c80fa058 Mon Sep 17 00:00:00 2001 From: Konstantin Misyutin Date: Tue, 5 Oct 2021 22:16:21 +0300 Subject: [PATCH 1/2] Lock StorageObjectInUseProtection feature gate to default Signed-off-by: Konstantin Misyutin --- pkg/features/kube_features.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index 3fdf0752dde..7c7ea26b245 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -800,7 +800,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS MemoryManager: {Default: true, PreRelease: featuregate.Beta}, CPUCFSQuotaPeriod: {Default: false, PreRelease: featuregate.Alpha}, TopologyManager: {Default: true, PreRelease: featuregate.Beta}, - StorageObjectInUseProtection: {Default: true, PreRelease: featuregate.GA}, + StorageObjectInUseProtection: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25 CSIMigration: {Default: true, PreRelease: featuregate.Beta}, CSIMigrationGCE: {Default: false, PreRelease: featuregate.Beta}, // Off by default (requires GCE PD CSI Driver) InTreePluginGCEUnregister: {Default: false, PreRelease: featuregate.Alpha}, From dbc9d7b71ab9e1791d7ed403724d23445c105aad Mon Sep 17 00:00:00 2001 From: Konstantin Misyutin Date: Fri, 15 Oct 2021 19:39:37 +0800 Subject: [PATCH 2/2] Remove tests when StorageObjectInUseProtection feature is disabled As well as feature gate are locked, the tests when this feature is disabled will crash. So we should remove them together with locking the feature. Signed-off-by: Konstantin Misyutin --- .../volume/persistentvolume/index_test.go | 32 +++---------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/pkg/controller/volume/persistentvolume/index_test.go b/pkg/controller/volume/persistentvolume/index_test.go index 827a76cd2f7..3098c6905a6 100644 --- a/pkg/controller/volume/persistentvolume/index_test.go +++ b/pkg/controller/volume/persistentvolume/index_test.go @@ -1231,30 +1231,18 @@ func TestStorageObjectInUseProtectionFiltering(t *testing.T) { pvc *v1.PersistentVolumeClaim enableStorageObjectInUseProtection bool }{ - "feature enabled - pv deletionTimeStamp not set": { + "pv deletionTimeStamp not set": { isExpectedMatch: true, vol: pv, pvc: pvc, enableStorageObjectInUseProtection: true, }, - "feature enabled - pv deletionTimeStamp set": { + "pv deletionTimeStamp set": { isExpectedMatch: false, vol: pvToDelete, pvc: pvc, enableStorageObjectInUseProtection: true, }, - "feature disabled - pv deletionTimeStamp not set": { - isExpectedMatch: true, - vol: pv, - pvc: pvc, - enableStorageObjectInUseProtection: false, - }, - "feature disabled - pv deletionTimeStamp set": { - isExpectedMatch: true, - vol: pvToDelete, - pvc: pvc, - enableStorageObjectInUseProtection: false, - }, } for name, testCase := range satisfyingTestCases { @@ -1279,30 +1267,18 @@ func TestStorageObjectInUseProtectionFiltering(t *testing.T) { pvc *v1.PersistentVolumeClaim enableStorageObjectInUseProtection bool }{ - "feature enabled - pv deletionTimeStamp not set": { + "pv deletionTimeStamp not set": { isExpectedMatch: true, vol: createTestVolOrderedIndex(pv), pvc: pvc, enableStorageObjectInUseProtection: true, }, - "feature enabled - pv deletionTimeStamp set": { + "pv deletionTimeStamp set": { isExpectedMatch: false, vol: createTestVolOrderedIndex(pvToDelete), pvc: pvc, enableStorageObjectInUseProtection: true, }, - "feature disabled - pv deletionTimeStamp not set": { - isExpectedMatch: true, - vol: createTestVolOrderedIndex(pv), - pvc: pvc, - enableStorageObjectInUseProtection: false, - }, - "feature disabled - pv deletionTimeStamp set": { - isExpectedMatch: true, - vol: createTestVolOrderedIndex(pvToDelete), - pvc: pvc, - enableStorageObjectInUseProtection: false, - }, } for name, testCase := range filteringTestCases { t.Run(name, func(t *testing.T) {