Merge pull request #123549 from carlory/kep-3751-finalizer

A new controller adds/removes finalizer to VAC for protection
This commit is contained in:
Kubernetes Prow Robot
2024-11-05 21:45:30 +00:00
committed by GitHub
9 changed files with 1052 additions and 0 deletions

View File

@@ -567,6 +567,7 @@ func NewControllerDescriptors() map[string]*ControllerDescriptor {
register(newClusterRoleAggregrationControllerDescriptor())
register(newPersistentVolumeClaimProtectionControllerDescriptor())
register(newPersistentVolumeProtectionControllerDescriptor())
register(newVolumeAttributesClassProtectionControllerDescriptor())
register(newTTLAfterFinishedControllerDescriptor())
register(newRootCACertificatePublisherControllerDescriptor())
register(newEphemeralVolumeControllerDescriptor())

View File

@@ -86,6 +86,7 @@ func TestControllerNamesDeclaration(t *testing.T) {
names.ClusterRoleAggregationController,
names.PersistentVolumeClaimProtectionController,
names.PersistentVolumeProtectionController,
names.VolumeAttributesClassProtectionController,
names.TTLAfterFinishedController,
names.RootCACertificatePublisherController,
names.EphemeralVolumeController,

View File

@@ -64,6 +64,7 @@ import (
persistentvolumecontroller "k8s.io/kubernetes/pkg/controller/volume/persistentvolume"
"k8s.io/kubernetes/pkg/controller/volume/pvcprotection"
"k8s.io/kubernetes/pkg/controller/volume/pvprotection"
"k8s.io/kubernetes/pkg/controller/volume/vacprotection"
"k8s.io/kubernetes/pkg/features"
quotainstall "k8s.io/kubernetes/pkg/quota/v1/install"
"k8s.io/kubernetes/pkg/volume/csimigration"
@@ -684,6 +685,31 @@ func startPersistentVolumeProtectionController(ctx context.Context, controllerCo
return nil, true, nil
}
func newVolumeAttributesClassProtectionControllerDescriptor() *ControllerDescriptor {
return &ControllerDescriptor{
name: names.VolumeAttributesClassProtectionController,
initFunc: startVolumeAttributesClassProtectionController,
requiredFeatureGates: []featuregate.Feature{
features.VolumeAttributesClass,
},
}
}
func startVolumeAttributesClassProtectionController(ctx context.Context, controllerContext ControllerContext, controllerName string) (controller.Interface, bool, error) {
vacProtectionController, err := vacprotection.NewVACProtectionController(
klog.FromContext(ctx),
controllerContext.ClientBuilder.ClientOrDie("volumeattributesclass-protection-controller"),
controllerContext.InformerFactory.Core().V1().PersistentVolumeClaims(),
controllerContext.InformerFactory.Core().V1().PersistentVolumes(),
controllerContext.InformerFactory.Storage().V1beta1().VolumeAttributesClasses(),
)
if err != nil {
return nil, true, fmt.Errorf("failed to start the vac protection controller: %w", err)
}
go vacProtectionController.Run(ctx, 1)
return nil, true, nil
}
func newTTLAfterFinishedControllerDescriptor() *ControllerDescriptor {
return &ControllerDescriptor{
name: names.TTLAfterFinishedController,

View File

@@ -82,6 +82,7 @@ const (
ResourceClaimController = "resourceclaim-controller"
LegacyServiceAccountTokenCleanerController = "legacy-serviceaccount-token-cleaner-controller"
ValidatingAdmissionPolicyStatusController = "validatingadmissionpolicy-status-controller"
VolumeAttributesClassProtectionController = "volumeattributesclass-protection-controller"
ServiceCIDRController = "service-cidr-controller"
StorageVersionMigratorController = "storage-version-migrator-controller"
)