What happened?
crossplane/provider-template#171 looks to be applicable to this repo as well, the pattern was probably picked up from provider-template in the first place.
TL;DR: The ClusterProviderConfig controller counts ClusterProviderConfigUsage records, and nothing in this provider creates one, so you can delete a ClusterProviderConfig that namespaced MRs for this provider are still using and it's not protected.
The ClusterProviderConfigUsage type can be removed, just use ProviderConfigUsage instead for namespaced MRs using either ProviderConfig or ClusterProviderConfig. That is the only usage kind crossplane-runtime's tracker creates for modern namespaced MRs.
- the cluster config controller:
|
of := resource.ProviderConfigKinds{ |
|
Config: v1alpha1.ClusterProviderConfigGroupVersionKind, |
|
Usage: v1alpha1.ClusterProviderConfigUsageGroupVersionKind, |
|
UsageList: v1alpha1.ClusterProviderConfigUsageListGroupVersionKind, |
|
} |
|
|
|
r := providerconfig.NewReconciler(mgr, of, |
|
providerconfig.WithLogger(o.Logger.WithValues("controller", name)), |
|
providerconfig.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name)))) //nolint:staticcheck |
|
|
|
return ctrl.NewControllerManagedBy(mgr). |
|
Named(name). |
|
WithOptions(o.ForControllerRuntime()). |
|
For(&v1alpha1.ClusterProviderConfig{}). |
|
Watches(&v1alpha1.ClusterProviderConfigUsage{}, &resource.EnqueueRequestForProviderConfig{}). |
- the tracker the managed resources use:
|
usage: resource.NewProviderConfigUsageTracker(mgr.GetClient(), &apisv1alpha1.ProviderConfigUsage{}), |
crossplane/provider-template#171 has more details, but the fix itself is small: point the controller and its watch at ProviderConfigUsage, then delete the unused ClusterProviderConfigUsage types and CRD.
How can we reproduce it?
I haven't run this particular provider directly, I'm just opening this from what was learned/observed in provider-template. But I expect that:
- a namespaced MR referencing a
ClusterProviderConfig, .status.users on that config should be 1 but will probably be 0
kubectl delete clusterproviderconfig <name> should be blocked while in use but it will probably be removed right away
What happened?
crossplane/provider-template#171 looks to be applicable to this repo as well, the pattern was probably picked up from provider-template in the first place.
TL;DR: The
ClusterProviderConfigcontroller countsClusterProviderConfigUsagerecords, and nothing in this provider creates one, so you can delete aClusterProviderConfigthat namespaced MRs for this provider are still using and it's not protected.The
ClusterProviderConfigUsagetype can be removed, just useProviderConfigUsageinstead for namespaced MRs using eitherProviderConfigorClusterProviderConfig. That is the only usage kind crossplane-runtime's tracker creates for modern namespaced MRs.provider-kafka/internal/controller/namespaced/config/config.go
Lines 62 to 76 in ead84f9
provider-kafka/internal/controller/namespaced/topic/topic.go
Line 80 in ead84f9
crossplane/provider-template#171 has more details, but the fix itself is small: point the controller and its watch at
ProviderConfigUsage, then delete the unusedClusterProviderConfigUsagetypes and CRD.How can we reproduce it?
I haven't run this particular provider directly, I'm just opening this from what was learned/observed in
provider-template. But I expect that:ClusterProviderConfig,.status.userson that config should be 1 but will probably be 0kubectl delete clusterproviderconfig <name>should be blocked while in use but it will probably be removed right away