@@ -97,7 +97,7 @@ type Operator struct {
97
97
csvQueueSet * queueinformer.ResourceQueueSet
98
98
olmConfigQueue workqueue.TypedRateLimitingInterface [types.NamespacedName ]
99
99
csvCopyQueueSet * queueinformer.ResourceQueueSet
100
- copiedCSVGCQueueSet * queueinformer.ResourceQueueSet
100
+ copiedCSVQueueSet * queueinformer.ResourceQueueSet
101
101
nsQueueSet workqueue.TypedRateLimitingInterface [types.NamespacedName ]
102
102
apiServiceQueue workqueue.TypedRateLimitingInterface [types.NamespacedName ]
103
103
csvIndexers map [string ]cache.Indexer
@@ -216,8 +216,8 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
216
216
Name : "olmConfig" ,
217
217
}),
218
218
219
- csvCopyQueueSet : queueinformer .NewEmptyResourceQueueSet (),
220
- copiedCSVGCQueueSet : queueinformer .NewEmptyResourceQueueSet (),
219
+ csvCopyQueueSet : queueinformer .NewEmptyResourceQueueSet (),
220
+ copiedCSVQueueSet : queueinformer .NewEmptyResourceQueueSet (),
221
221
apiServiceQueue : workqueue .NewTypedRateLimitingQueueWithConfig [types.NamespacedName ](
222
222
workqueue .DefaultTypedControllerRateLimiter [types.NamespacedName ](),
223
223
workqueue.TypedRateLimitingQueueConfig [types.NamespacedName ]{
@@ -371,25 +371,26 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
371
371
informersByNamespace [namespace ].CopiedCSVInformer = copiedCSVInformer
372
372
informersByNamespace [namespace ].CopiedCSVLister = op .copiedCSVLister
373
373
374
- // Register separate queue for gcing copied csvs
375
- copiedCSVGCQueue := workqueue .NewTypedRateLimitingQueueWithConfig [types.NamespacedName ](
374
+ // Register separate queue for gcing/syncing/deletion of copied csvs
375
+ copiedCSVQueue := workqueue .NewTypedRateLimitingQueueWithConfig [types.NamespacedName ](
376
376
workqueue .DefaultTypedControllerRateLimiter [types.NamespacedName ](),
377
377
workqueue.TypedRateLimitingQueueConfig [types.NamespacedName ]{
378
- Name : fmt .Sprintf ("%s/csv-gc-revert " , namespace ),
378
+ Name : fmt .Sprintf ("%s/csv-copied-sync " , namespace ),
379
379
})
380
- op .copiedCSVGCQueueSet .Set (namespace , copiedCSVGCQueue )
381
- copiedCSVGCQueueInformer , err := queueinformer .NewQueueInformer (
380
+ op .copiedCSVQueueSet .Set (namespace , copiedCSVQueue )
381
+ copiedCSVQueueInformer , err := queueinformer .NewQueueInformer (
382
382
ctx ,
383
383
queueinformer .WithInformer (copiedCSVInformer ),
384
384
queueinformer .WithLogger (op .logger ),
385
- queueinformer .WithQueue (copiedCSVGCQueue ),
385
+ queueinformer .WithQueue (copiedCSVQueue ),
386
386
queueinformer .WithIndexer (copiedCSVInformer .GetIndexer ()),
387
- queueinformer .WithSyncer (queueinformer .LegacySyncHandler (op .syncResyncCsv ).ToSyncer ()),
387
+ queueinformer .WithSyncer (queueinformer .LegacySyncHandler (op .syncCopiedCsv ).ToSyncer ()),
388
+ queueinformer .WithDeletionHandler (op .deleteCopiedCsv ),
388
389
)
389
390
if err != nil {
390
391
return nil , err
391
392
}
392
- if err := op .RegisterQueueInformer (copiedCSVGCQueueInformer ); err != nil {
393
+ if err := op .RegisterQueueInformer (copiedCSVQueueInformer ); err != nil {
393
394
return nil , err
394
395
}
395
396
@@ -1266,7 +1267,7 @@ func (a *Operator) handleClusterServiceVersionDeletion(obj interface{}) {
1266
1267
for _ , namespace := range namespaces {
1267
1268
if namespace != operatorNamespace {
1268
1269
logger .WithField ("targetNamespace" , namespace ).Debug ("requeueing child csv for deletion" )
1269
- if err := a .copiedCSVGCQueueSet .Requeue (namespace , clusterServiceVersion .GetName ()); err != nil {
1270
+ if err := a .copiedCSVQueueSet .Requeue (namespace , clusterServiceVersion .GetName ()); err != nil {
1270
1271
logger .WithError (err ).Warn ("unable to requeue" )
1271
1272
}
1272
1273
}
@@ -1929,7 +1930,35 @@ func (a *Operator) createCSVCopyingDisabledEvent(csv *v1alpha1.ClusterServiceVer
1929
1930
return nil
1930
1931
}
1931
1932
1932
- func (a * Operator ) syncResyncCsv (obj interface {}) error {
1933
+ func (a * Operator ) requeueParentCsv (csv * v1alpha1.ClusterServiceVersion ) error {
1934
+ name := csv .GetName ()
1935
+ copiedNamespace := csv .GetNamespace ()
1936
+ a .logger .WithField ("csv" , fmt .Sprintf ("%s/%s" , copiedNamespace , name )).Debug ("syncing copied CSV" )
1937
+
1938
+ // Requeue parent CSV to deal with any changes to the copied CSV
1939
+ copiedFromNamespace , ok := csv .GetLabels ()[v1alpha1 .CopiedLabelKey ]
1940
+ if ! ok {
1941
+ a .logger .Infof ("no %q label found in CSV, skipping requeue" , v1alpha1 .CopiedLabelKey )
1942
+ return nil
1943
+ }
1944
+ return a .csvCopyQueueSet .Requeue (copiedFromNamespace , name )
1945
+ }
1946
+
1947
+ func (a * Operator ) deleteCopiedCsv (obj interface {}) {
1948
+ csv , ok := obj .(* v1alpha1.ClusterServiceVersion )
1949
+ if ! ok {
1950
+ a .logger .Debugf ("casting ClusterServiceVersion failed: wrong type: %#v" , obj )
1951
+ return
1952
+ }
1953
+ if ! v1alpha1 .IsCopied (csv ) {
1954
+ return
1955
+ }
1956
+
1957
+ // Trigger partent reconciliation
1958
+ a .requeueParentCsv (csv )
1959
+ }
1960
+
1961
+ func (a * Operator ) syncCopiedCsv (obj interface {}) error {
1933
1962
csv , ok := obj .(* v1alpha1.ClusterServiceVersion )
1934
1963
if ! ok {
1935
1964
a .logger .Debugf ("wrong type: %#v" , obj )
@@ -1939,23 +1968,14 @@ func (a *Operator) syncResyncCsv(obj interface{}) error {
1939
1968
return nil
1940
1969
}
1941
1970
1942
- name := csv .GetName ()
1943
- copiedNamespace := csv .GetNamespace ()
1944
- a .logger .WithField ("csv" , fmt .Sprintf ("%s/%s" , copiedNamespace , name )).Debug ("syncing copied CSV" )
1945
-
1946
1971
// check for any garbage collection
1947
1972
err := a .removeDanglingChildCSVs (csv )
1948
1973
if err != nil {
1949
1974
return err
1950
1975
}
1951
1976
1952
- // Requeue parent CSV to deal with any changes to the copied CSV
1953
- copiedFromNamespace , ok := csv .GetLabels ()[v1alpha1 .CopiedLabelKey ]
1954
- if ! ok {
1955
- a .logger .Infof ("no %q label found in CSV, skipping requeue" , v1alpha1 .CopiedLabelKey )
1956
- return nil
1957
- }
1958
- return a .csvCopyQueueSet .Requeue (copiedFromNamespace , name )
1977
+ // Trigger partent reconciliation
1978
+ return a .requeueParentCsv (csv )
1959
1979
}
1960
1980
1961
1981
// operatorGroupFromAnnotations returns the OperatorGroup for the CSV only if the CSV is active one in the group
0 commit comments