From 2a2f88b9397a9b91cd1ce20149f8c10dcec4dbf8 Mon Sep 17 00:00:00 2001 From: NickrenREN Date: Wed, 24 Jan 2018 17:03:37 +0800 Subject: [PATCH] Rename PVCProtection feature gate so that PV protection can share the feature gate with PVC protection --- cmd/kube-controller-manager/app/core.go | 2 +- pkg/features/kube_features.go | 8 ++++---- .../populator/desired_state_of_world_populator.go | 2 +- .../persistentvolumeclaim/pvcprotection/admission.go | 2 +- .../persistentvolumeclaim/pvcprotection/admission_test.go | 4 ++-- .../authorizer/rbac/bootstrappolicy/controller_policy.go | 2 +- test/e2e/storage/pvc_protection.go | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/kube-controller-manager/app/core.go b/cmd/kube-controller-manager/app/core.go index 2fceb2370bc..13618b1cbc0 100644 --- a/cmd/kube-controller-manager/app/core.go +++ b/cmd/kube-controller-manager/app/core.go @@ -393,7 +393,7 @@ func startGarbageCollectorController(ctx ControllerContext) (bool, error) { } func startPVCProtectionController(ctx ControllerContext) (bool, error) { - if utilfeature.DefaultFeatureGate.Enabled(features.PVCProtection) { + if utilfeature.DefaultFeatureGate.Enabled(features.StorageProtection) { go pvcprotection.NewPVCProtectionController( ctx.InformerFactory.Core().V1().PersistentVolumeClaims(), ctx.InformerFactory.Core().V1().Pods(), diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index cfdcf614953..d563a8df24b 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -203,10 +203,10 @@ const ( BlockVolume utilfeature.Feature = "BlockVolume" // owner: @pospispa - // // alpha: v1.9 - // Postpone deletion of a persistent volume claim in case it is used by a pod - PVCProtection utilfeature.Feature = "PVCProtection" + // + // Postpone deletion of a PV or a PVC when they are being used + StorageProtection utilfeature.Feature = "StorageProtection" // owner: @aveshagarwal // alpha: v1.9 @@ -261,7 +261,7 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS CSIPersistentVolume: {Default: false, PreRelease: utilfeature.Alpha}, CustomPodDNS: {Default: false, PreRelease: utilfeature.Alpha}, BlockVolume: {Default: false, PreRelease: utilfeature.Alpha}, - PVCProtection: {Default: false, PreRelease: utilfeature.Alpha}, + StorageProtection: {Default: false, PreRelease: utilfeature.Alpha}, ResourceLimitsPriorityFunction: {Default: false, PreRelease: utilfeature.Alpha}, SupportIPVSProxyMode: {Default: false, PreRelease: utilfeature.Beta}, SupportPodPidsLimit: {Default: false, PreRelease: utilfeature.Alpha}, diff --git a/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go b/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go index f696becd3c4..110a66216af 100644 --- a/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go +++ b/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go @@ -434,7 +434,7 @@ func (dswp *desiredStateOfWorldPopulator) getPVCExtractPV( err) } - if utilfeature.DefaultFeatureGate.Enabled(features.PVCProtection) { + if utilfeature.DefaultFeatureGate.Enabled(features.StorageProtection) { // Pods that uses a PVC that is being deleted must not be started. // // In case an old kubelet is running without this check or some kubelets diff --git a/plugin/pkg/admission/persistentvolumeclaim/pvcprotection/admission.go b/plugin/pkg/admission/persistentvolumeclaim/pvcprotection/admission.go index 218bca4b829..00c70568db3 100644 --- a/plugin/pkg/admission/persistentvolumeclaim/pvcprotection/admission.go +++ b/plugin/pkg/admission/persistentvolumeclaim/pvcprotection/admission.go @@ -80,7 +80,7 @@ func (c *pvcProtectionPlugin) ValidateInitialization() error { // // This prevents users from deleting a PVC that's used by a running pod. func (c *pvcProtectionPlugin) Admit(a admission.Attributes) error { - if !feature.DefaultFeatureGate.Enabled(features.PVCProtection) { + if !feature.DefaultFeatureGate.Enabled(features.StorageProtection) { return nil } diff --git a/plugin/pkg/admission/persistentvolumeclaim/pvcprotection/admission_test.go b/plugin/pkg/admission/persistentvolumeclaim/pvcprotection/admission_test.go index 0815c40615b..9202e4dffb0 100644 --- a/plugin/pkg/admission/persistentvolumeclaim/pvcprotection/admission_test.go +++ b/plugin/pkg/admission/persistentvolumeclaim/pvcprotection/admission_test.go @@ -77,7 +77,7 @@ func TestAdmit(t *testing.T) { ctrl.SetInternalKubeInformerFactory(informerFactory) for _, test := range tests { - feature.DefaultFeatureGate.Set(fmt.Sprintf("PVCProtection=%v", test.featureEnabled)) + feature.DefaultFeatureGate.Set(fmt.Sprintf("StorageProtection=%v", test.featureEnabled)) obj := test.object.DeepCopyObject() attrs := admission.NewAttributesRecord( obj, // new object @@ -102,5 +102,5 @@ func TestAdmit(t *testing.T) { // Disable the feature for rest of the tests. // TODO: remove after alpha - feature.DefaultFeatureGate.Set("PVCProtection=false") + feature.DefaultFeatureGate.Set("StorageProtection=false") } diff --git a/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/controller_policy.go b/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/controller_policy.go index c94c0295334..29cae666fd6 100644 --- a/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/controller_policy.go +++ b/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/controller_policy.go @@ -324,7 +324,7 @@ func buildControllerRoles() ([]rbac.ClusterRole, []rbac.ClusterRoleBinding) { eventsRule(), }, }) - if utilfeature.DefaultFeatureGate.Enabled(features.PVCProtection) { + if utilfeature.DefaultFeatureGate.Enabled(features.StorageProtection) { addControllerRole(&controllerRoles, &controllerRoleBindings, rbac.ClusterRole{ ObjectMeta: metav1.ObjectMeta{Name: saRolePrefix + "pvc-protection-controller"}, Rules: []rbac.PolicyRule{ diff --git a/test/e2e/storage/pvc_protection.go b/test/e2e/storage/pvc_protection.go index 5ead6272635..ba9e9d76379 100644 --- a/test/e2e/storage/pvc_protection.go +++ b/test/e2e/storage/pvc_protection.go @@ -33,7 +33,7 @@ import ( "k8s.io/kubernetes/test/e2e/storage/utils" ) -var _ = utils.SIGDescribe("PVC Protection [Feature:PVCProtection]", func() { +var _ = utils.SIGDescribe("PVC Protection [Feature:StorageProtection]", func() { var ( client clientset.Interface nameSpace string