@@ -327,7 +327,6 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
327327 // a hash over the full CSV to store as an annotation
328328 copiedCSVTransformFunc := func (i interface {}) (interface {}, error ) {
329329 if csv , ok := i .(* v1alpha1.ClusterServiceVersion ); ok {
330- config .logger .WithField ("name" , fmt .Sprintf ("%s/%s" , csv .Namespace , csv .Name )).Info ("Transforming copied CSV" )
331330 specHash , statusHash , err := copyableCSVHash (csv )
332331 if err != nil {
333332 return nil , err
@@ -385,7 +384,7 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
385384 queueinformer .WithLogger (op .logger ),
386385 queueinformer .WithQueue (copiedCSVGCQueue ),
387386 queueinformer .WithIndexer (copiedCSVInformer .GetIndexer ()),
388- queueinformer .WithSyncer (queueinformer .LegacySyncHandler (op .syncRevertGcCsv ).ToSyncer ()),
387+ queueinformer .WithSyncer (queueinformer .LegacySyncHandler (op .syncResyncCsv ).ToSyncer ()),
389388 )
390389 if err != nil {
391390 return nil , err
@@ -1739,8 +1738,6 @@ func (a *Operator) syncCopyCSV(obj interface{}) (syncError error) {
17391738 return fmt .Errorf ("casting ClusterServiceVersion failed" )
17401739 }
17411740
1742- a .logger .WithField ("name" , fmt .Sprintf ("%s/%s" , clusterServiceVersion .Namespace , clusterServiceVersion .Name )).Info ("syncCopyCSV" )
1743-
17441741 olmConfig , err := a .client .OperatorsV1 ().OLMConfigs ().Get (context .TODO (), "cluster" , metav1.GetOptions {})
17451742 if err != nil && ! apierrors .IsNotFound (err ) {
17461743 return err
@@ -1932,24 +1929,7 @@ func (a *Operator) createCSVCopyingDisabledEvent(csv *v1alpha1.ClusterServiceVer
19321929 return nil
19331930}
19341931
1935- func GetCopiedNamespace (c * v1alpha1.ClusterServiceVersion ) string {
1936- annotations := c .GetAnnotations ()
1937- if annotations != nil {
1938- operatorNamespace , ok := annotations [v1alpha1 .OperatorGroupNamespaceAnnotationKey ]
1939- if ok && c .GetNamespace () != operatorNamespace {
1940- return operatorNamespace
1941- }
1942- }
1943-
1944- if labels := c .GetLabels (); labels != nil {
1945- if l , ok := labels [v1alpha1 .CopiedLabelKey ]; ok {
1946- return l
1947- }
1948- }
1949- return ""
1950- }
1951-
1952- func (a * Operator ) syncRevertGcCsv (obj interface {}) error {
1932+ func (a * Operator ) syncResyncCsv (obj interface {}) error {
19531933 csv , ok := obj .(* v1alpha1.ClusterServiceVersion )
19541934 if ! ok {
19551935 a .logger .Debugf ("wrong type: %#v" , obj )
@@ -1959,39 +1939,23 @@ func (a *Operator) syncRevertGcCsv(obj interface{}) error {
19591939 return nil
19601940 }
19611941
1962- logger := a .logger .WithField ("csv" , fmt .Sprintf ("%s/%s" , csv .Namespace , csv .Name ))
1942+ name := csv .GetName ()
1943+ copiedNamespace := csv .GetNamespace ()
1944+ a .logger .WithField ("csv" , fmt .Sprintf ("%s/%s" , copiedNamespace , name )).Debug ("syncing copied CSV" )
19631945
19641946 // check for any garbage collection
1965- logger .Info ("syncRevertGcCsv: removeDanglingChildCSVs" )
19661947 err := a .removeDanglingChildCSVs (csv )
19671948 if err != nil {
19681949 return err
19691950 }
19701951
1971- // Check for a revert
1972- ns := GetCopiedNamespace ( csv )
1973- if ns == "" {
1974- logger .Info ( "syncRevertGcCsv: Failed to get copied-from namespace" )
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 )
19751956 return nil
19761957 }
1977- prototype , err := a .client .OperatorsV1alpha1 ().ClusterServiceVersions (ns ).Get (context .TODO (), csv .Name , metav1.GetOptions {})
1978- if err != nil {
1979- logger .Info ("syncRevertGcCsv: Failed to get prototype" )
1980- return err
1981- }
1982- var copyPrototype v1alpha1.ClusterServiceVersion
1983- csvCopyPrototype (prototype , & copyPrototype )
1984- specHash , statusHash , err := copyableCSVHash (& copyPrototype )
1985- if err != nil {
1986- logger .Info ("syncRevertGcCsv: Failed to hash" )
1987- return err
1988- }
1989- logger .Info ("syncRevertGcCsv: copyToNamespace" )
1990- _ , err = a .copyToNamespace (& copyPrototype , ns , csv .Namespace , specHash , statusHash )
1991- if err != nil {
1992- logger .WithError (err ).Info ("syncRevertGcCsv: copyToNamespace failed" )
1993- }
1994- return err
1958+ return a .csvCopyQueueSet .Requeue (copiedFromNamespace , name )
19951959}
19961960
19971961// operatorGroupFromAnnotations returns the OperatorGroup for the CSV only if the CSV is active one in the group
0 commit comments