@@ -44,10 +44,12 @@ import (
4444)
4545
4646const (
47- fbcDeletionFinalizer = "olm.operatorframework.io/delete-server-cache"
47+ ClusterCatalogFinalizerOwner = "olm.operatorframework.io/clustercatalog-controller"
48+ fbcDeletionFinalizer = "olm.operatorframework.io/delete-server-cache"
4849 // CatalogSources are polled if PollInterval is mentioned, in intervals of wait.Jitter(pollDuration, maxFactor)
4950 // wait.Jitter returns a time.Duration between pollDuration and pollDuration + maxFactor * pollDuration.
50- requeueJitterMaxFactor = 0.01
51+ requeueJitterMaxFactor = 0.01
52+ lastAppliedConfiguration = "kubectl.kubernetes.io/last-applied-configuration"
5153)
5254
5355// ClusterCatalogReconciler reconciles a Catalog object
@@ -150,20 +152,16 @@ func (r *ClusterCatalogReconciler) reconcile(ctx context.Context, catalog *ocv1.
150152 return ctrl.Result {}, err
151153 }
152154
155+ // Set status.conditions[type=Progressing] to False as we are done with
156+ // all that needs to be done with the catalog
157+ updateStatusProgressingUserSpecifiedUnavailable (& catalog .Status , catalog .GetGeneration ())
158+
153159 // Remove the fbcDeletionFinalizer as we do not want a finalizer attached to the catalog
154160 // when it is disabled. Because the finalizer serves no purpose now.
155- if err := finalizerutil .RemoveFinalizer (ctx , r .Client , catalog , fbcDeletionFinalizer ); err != nil {
161+ if err := finalizerutil .RemoveFinalizers (ctx , ClusterCatalogFinalizerOwner , r .Client , catalog , fbcDeletionFinalizer ); err != nil {
156162 return ctrl.Result {}, fmt .Errorf ("error removing finalizer: %v" , err )
157163 }
158164
159- // Set status.conditions[type=Progressing] to True as we are done with
160- // all that needs to be done with the catalog
161- updateStatusProgressingUserSpecifiedUnavailable (& catalog .Status , catalog .GetGeneration ())
162- // Clear URLs, ResolvedSource, and LastUnpacked since catalog is unavailable
163- catalog .Status .ResolvedSource = nil
164- catalog .Status .URLs = nil
165- catalog .Status .LastUnpacked = nil
166-
167165 return ctrl.Result {}, nil
168166 }
169167
@@ -176,16 +174,16 @@ func (r *ClusterCatalogReconciler) reconcile(ctx context.Context, catalog *ocv1.
176174 if err := r .deleteCatalogCache (ctx , catalog ); err != nil {
177175 return ctrl.Result {}, fmt .Errorf ("finalizer %q failed: %w" , fbcDeletionFinalizer , err )
178176 }
179- if err := finalizerutil .RemoveFinalizer (ctx , r .Client , catalog , fbcDeletionFinalizer ); err != nil {
177+ if err := finalizerutil .RemoveFinalizers (ctx , ClusterCatalogFinalizerOwner , r .Client , catalog , fbcDeletionFinalizer ); err != nil {
180178 return ctrl.Result {}, fmt .Errorf ("error removing finalizer: %v" , err )
181179 }
182180 // Update status to reflect that catalog is no longer serving
183181 updateStatusNotServing (& catalog .Status , catalog .GetGeneration ())
184182 return ctrl.Result {}, nil
185183 }
186184
187- // Ensure finalizer is present
188- finalizerAdded , err := finalizerutil .EnsureFinalizer (ctx , r .Client , catalog , fbcDeletionFinalizer )
185+ // Add finalizer
186+ finalizerAdded , err := finalizerutil .AddFinalizers (ctx , ClusterCatalogFinalizerOwner , r .Client , catalog , fbcDeletionFinalizer )
189187 if err != nil {
190188 return ctrl.Result {}, fmt .Errorf ("error ensuring finalizer: %v" , err )
191189 }
@@ -417,10 +415,10 @@ func checkForUnexpectedFieldChange(a, b ocv1.ClusterCatalog) bool {
417415 a .ResourceVersion , b .ResourceVersion = "" , ""
418416 // Remove kubectl's last-applied-configuration annotation which may be added by the API server
419417 if a .Annotations != nil {
420- delete (a .Annotations , "kubectl.kubernetes.io/last-applied-configuration" )
418+ delete (a .Annotations , lastAppliedConfiguration )
421419 }
422420 if b .Annotations != nil {
423- delete (b .Annotations , "kubectl.kubernetes.io/last-applied-configuration" )
421+ delete (b .Annotations , lastAppliedConfiguration )
424422 }
425423 return ! equality .Semantic .DeepEqual (a , b )
426424}
0 commit comments