mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-15 14:53:44 +00:00
Rename PVCProtection feature gate so that PV protection can share the feature gate with PVC protection
This commit is contained in:
parent
494664a736
commit
2a2f88b939
@ -393,7 +393,7 @@ func startGarbageCollectorController(ctx ControllerContext) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func startPVCProtectionController(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(
|
go pvcprotection.NewPVCProtectionController(
|
||||||
ctx.InformerFactory.Core().V1().PersistentVolumeClaims(),
|
ctx.InformerFactory.Core().V1().PersistentVolumeClaims(),
|
||||||
ctx.InformerFactory.Core().V1().Pods(),
|
ctx.InformerFactory.Core().V1().Pods(),
|
||||||
|
@ -203,10 +203,10 @@ const (
|
|||||||
BlockVolume utilfeature.Feature = "BlockVolume"
|
BlockVolume utilfeature.Feature = "BlockVolume"
|
||||||
|
|
||||||
// owner: @pospispa
|
// owner: @pospispa
|
||||||
//
|
|
||||||
// alpha: v1.9
|
// 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
|
// owner: @aveshagarwal
|
||||||
// alpha: v1.9
|
// alpha: v1.9
|
||||||
@ -261,7 +261,7 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
|
|||||||
CSIPersistentVolume: {Default: false, PreRelease: utilfeature.Alpha},
|
CSIPersistentVolume: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
CustomPodDNS: {Default: false, PreRelease: utilfeature.Alpha},
|
CustomPodDNS: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
BlockVolume: {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},
|
ResourceLimitsPriorityFunction: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
SupportIPVSProxyMode: {Default: false, PreRelease: utilfeature.Beta},
|
SupportIPVSProxyMode: {Default: false, PreRelease: utilfeature.Beta},
|
||||||
SupportPodPidsLimit: {Default: false, PreRelease: utilfeature.Alpha},
|
SupportPodPidsLimit: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
|
@ -434,7 +434,7 @@ func (dswp *desiredStateOfWorldPopulator) getPVCExtractPV(
|
|||||||
err)
|
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.
|
// 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
|
// In case an old kubelet is running without this check or some kubelets
|
||||||
|
@ -80,7 +80,7 @@ func (c *pvcProtectionPlugin) ValidateInitialization() error {
|
|||||||
//
|
//
|
||||||
// This prevents users from deleting a PVC that's used by a running pod.
|
// This prevents users from deleting a PVC that's used by a running pod.
|
||||||
func (c *pvcProtectionPlugin) Admit(a admission.Attributes) error {
|
func (c *pvcProtectionPlugin) Admit(a admission.Attributes) error {
|
||||||
if !feature.DefaultFeatureGate.Enabled(features.PVCProtection) {
|
if !feature.DefaultFeatureGate.Enabled(features.StorageProtection) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ func TestAdmit(t *testing.T) {
|
|||||||
ctrl.SetInternalKubeInformerFactory(informerFactory)
|
ctrl.SetInternalKubeInformerFactory(informerFactory)
|
||||||
|
|
||||||
for _, test := range tests {
|
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()
|
obj := test.object.DeepCopyObject()
|
||||||
attrs := admission.NewAttributesRecord(
|
attrs := admission.NewAttributesRecord(
|
||||||
obj, // new object
|
obj, // new object
|
||||||
@ -102,5 +102,5 @@ func TestAdmit(t *testing.T) {
|
|||||||
|
|
||||||
// Disable the feature for rest of the tests.
|
// Disable the feature for rest of the tests.
|
||||||
// TODO: remove after alpha
|
// TODO: remove after alpha
|
||||||
feature.DefaultFeatureGate.Set("PVCProtection=false")
|
feature.DefaultFeatureGate.Set("StorageProtection=false")
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ func buildControllerRoles() ([]rbac.ClusterRole, []rbac.ClusterRoleBinding) {
|
|||||||
eventsRule(),
|
eventsRule(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.PVCProtection) {
|
if utilfeature.DefaultFeatureGate.Enabled(features.StorageProtection) {
|
||||||
addControllerRole(&controllerRoles, &controllerRoleBindings, rbac.ClusterRole{
|
addControllerRole(&controllerRoles, &controllerRoleBindings, rbac.ClusterRole{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: saRolePrefix + "pvc-protection-controller"},
|
ObjectMeta: metav1.ObjectMeta{Name: saRolePrefix + "pvc-protection-controller"},
|
||||||
Rules: []rbac.PolicyRule{
|
Rules: []rbac.PolicyRule{
|
||||||
|
@ -33,7 +33,7 @@ import (
|
|||||||
"k8s.io/kubernetes/test/e2e/storage/utils"
|
"k8s.io/kubernetes/test/e2e/storage/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = utils.SIGDescribe("PVC Protection [Feature:PVCProtection]", func() {
|
var _ = utils.SIGDescribe("PVC Protection [Feature:StorageProtection]", func() {
|
||||||
var (
|
var (
|
||||||
client clientset.Interface
|
client clientset.Interface
|
||||||
nameSpace string
|
nameSpace string
|
||||||
|
Loading…
Reference in New Issue
Block a user