@@ -356,33 +356,11 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
356356 informersByNamespace [namespace ].CopiedCSVInformer = copiedCSVInformer
357357 informersByNamespace [namespace ].CopiedCSVLister = op .copiedCSVLister
358358
359- // Register separate queue for reverting copied csvs
360- copiedCSVRevertQueue := workqueue .NewTypedRateLimitingQueueWithConfig [types.NamespacedName ](
361- workqueue .DefaultTypedControllerRateLimiter [types.NamespacedName ](),
362- workqueue.TypedRateLimitingQueueConfig [types.NamespacedName ]{
363- Name : fmt .Sprintf ("%s/csv-revert" , namespace ),
364- })
365- op .copiedCSVGCQueueSet .Set (namespace , copiedCSVRevertQueue )
366- copiedCSVRevertQueueInformer , err := queueinformer .NewQueueInformer (
367- ctx ,
368- queueinformer .WithInformer (copiedCSVInformer ),
369- queueinformer .WithLogger (op .logger ),
370- queueinformer .WithQueue (copiedCSVRevertQueue ),
371- queueinformer .WithIndexer (copiedCSVInformer .GetIndexer ()),
372- queueinformer .WithSyncer (queueinformer .LegacySyncHandler (op .syncRevertCsv ).ToSyncer ()),
373- )
374- if err != nil {
375- return nil , err
376- }
377- if err := op .RegisterQueueInformer (copiedCSVRevertQueueInformer ); err != nil {
378- return nil , err
379- }
380-
381359 // Register separate queue for gcing copied csvs
382360 copiedCSVGCQueue := workqueue .NewTypedRateLimitingQueueWithConfig [types.NamespacedName ](
383361 workqueue .DefaultTypedControllerRateLimiter [types.NamespacedName ](),
384362 workqueue.TypedRateLimitingQueueConfig [types.NamespacedName ]{
385- Name : fmt .Sprintf ("%s/csv-gc" , namespace ),
363+ Name : fmt .Sprintf ("%s/csv-gc-revert " , namespace ),
386364 })
387365 op .copiedCSVGCQueueSet .Set (namespace , copiedCSVGCQueue )
388366 copiedCSVGCQueueInformer , err := queueinformer .NewQueueInformer (
@@ -391,7 +369,7 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
391369 queueinformer .WithLogger (op .logger ),
392370 queueinformer .WithQueue (copiedCSVGCQueue ),
393371 queueinformer .WithIndexer (copiedCSVInformer .GetIndexer ()),
394- queueinformer .WithSyncer (queueinformer .LegacySyncHandler (op .syncGcCsv ).ToSyncer ()),
372+ queueinformer .WithSyncer (queueinformer .LegacySyncHandler (op .syncRevertGcCsv ).ToSyncer ()),
395373 )
396374 if err != nil {
397375 return nil , err
@@ -1955,51 +1933,51 @@ func GetCopiedNamespace(c *v1alpha1.ClusterServiceVersion) string {
19551933 return ""
19561934}
19571935
1958- func (a * Operator ) syncRevertCsv (obj interface {}) error {
1936+ func (a * Operator ) syncRevertGcCsv (obj interface {}) error {
19591937 csv , ok := obj .(* v1alpha1.ClusterServiceVersion )
19601938 if ! ok {
19611939 a .logger .Debugf ("wrong type: %#v" , obj )
19621940 return fmt .Errorf ("casting ClusterServiceVersion failed" )
19631941 }
1964- logger := a .logger .WithField ("csv" , fmt .Sprintf ("%s/%s" , csv .GetNamespace (), csv .GetName ()))
1965- logger .Info ("syncRevertCsv" )
1942+ if ! v1alpha1 .IsCopied (csv ) {
1943+ return nil
1944+ }
1945+
1946+ logger := a .logger .WithField ("csv" , fmt .Sprintf ("%s/%s" , csv .Namespace , csv .Name ))
1947+
1948+ // check for any garbage collection
1949+ logger .Info ("syncRevertGcCsv: removeDanglingChildCSVs" )
1950+ err := a .removeDanglingChildCSVs (csv )
1951+ if err != nil {
1952+ return err
1953+ }
1954+
1955+ // Check for a revert
19661956 ns := GetCopiedNamespace (csv )
19671957 if ns == "" {
1968- logger .Info ("syncRevertCsv: Unable to get copied-from namespace" )
1958+ logger .Info ("syncRevertGcCsv: Failed to get copied-from namespace" )
19691959 return nil
19701960 }
1971- prototype , err := a .client .OperatorsV1alpha1 ().ClusterServiceVersions (ns ).Get (context .TODO (), csv .GetName () , metav1.GetOptions {})
1961+ prototype , err := a .client .OperatorsV1alpha1 ().ClusterServiceVersions (ns ).Get (context .TODO (), csv .Name , metav1.GetOptions {})
19721962 if err != nil {
1973- logger .Info ("syncRevertCsv: Unable to get prototype" )
1963+ logger .Info ("syncRevertGcCsv: Failed to get prototype" )
19741964 return err
19751965 }
19761966 var copyPrototype v1alpha1.ClusterServiceVersion
19771967 csvCopyPrototype (prototype , & copyPrototype )
19781968 specHash , statusHash , err := copyableCSVHash (& copyPrototype )
19791969 if err != nil {
1980- logger .Info ("syncRevertCsv: Unable to hash" )
1970+ logger .Info ("syncRevertGcCsv: Failed to hash" )
19811971 return err
19821972 }
1983- _ , err = a .copyToNamespace (& copyPrototype , ns , csv .GetNamespace (), specHash , statusHash )
1973+ logger .Info ("syncRevertGcCsv: copyToNamespace" )
1974+ _ , err = a .copyToNamespace (& copyPrototype , ns , csv .Namespace , specHash , statusHash )
19841975 if err != nil {
1985- logger .WithError (err ).Info ("syncRevertCsv : copyToNamespace failed" )
1976+ logger .WithError (err ).Info ("syncRevertGcCsv : copyToNamespace failed" )
19861977 }
19871978 return err
19881979}
19891980
1990- func (a * Operator ) syncGcCsv (obj interface {}) (syncError error ) {
1991- clusterServiceVersion , ok := obj .(* v1alpha1.ClusterServiceVersion )
1992- if ! ok {
1993- a .logger .Debugf ("wrong type: %#v" , obj )
1994- return fmt .Errorf ("casting ClusterServiceVersion failed" )
1995- }
1996- if v1alpha1 .IsCopied (clusterServiceVersion ) {
1997- syncError = a .removeDanglingChildCSVs (clusterServiceVersion )
1998- return
1999- }
2000- return
2001- }
2002-
20031981// operatorGroupFromAnnotations returns the OperatorGroup for the CSV only if the CSV is active one in the group
20041982func (a * Operator ) operatorGroupFromAnnotations (logger * logrus.Entry , csv * v1alpha1.ClusterServiceVersion ) * operatorsv1.OperatorGroup {
20051983 annotations := csv .GetAnnotations ()
0 commit comments