@@ -327,7 +327,6 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
327
327
// a hash over the full CSV to store as an annotation
328
328
copiedCSVTransformFunc := func (i interface {}) (interface {}, error ) {
329
329
if csv , ok := i .(* v1alpha1.ClusterServiceVersion ); ok {
330
- config .logger .WithField ("name" , fmt .Sprintf ("%s/%s" , csv .Namespace , csv .Name )).Info ("Transforming copied CSV" )
331
330
specHash , statusHash , err := copyableCSVHash (csv )
332
331
if err != nil {
333
332
return nil , err
@@ -385,7 +384,7 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
385
384
queueinformer .WithLogger (op .logger ),
386
385
queueinformer .WithQueue (copiedCSVGCQueue ),
387
386
queueinformer .WithIndexer (copiedCSVInformer .GetIndexer ()),
388
- queueinformer .WithSyncer (queueinformer .LegacySyncHandler (op .syncRevertGcCsv ).ToSyncer ()),
387
+ queueinformer .WithSyncer (queueinformer .LegacySyncHandler (op .syncResyncCsv ).ToSyncer ()),
389
388
)
390
389
if err != nil {
391
390
return nil , err
@@ -1739,8 +1738,6 @@ func (a *Operator) syncCopyCSV(obj interface{}) (syncError error) {
1739
1738
return fmt .Errorf ("casting ClusterServiceVersion failed" )
1740
1739
}
1741
1740
1742
- a .logger .WithField ("name" , fmt .Sprintf ("%s/%s" , clusterServiceVersion .Namespace , clusterServiceVersion .Name )).Info ("syncCopyCSV" )
1743
-
1744
1741
olmConfig , err := a .client .OperatorsV1 ().OLMConfigs ().Get (context .TODO (), "cluster" , metav1.GetOptions {})
1745
1742
if err != nil && ! apierrors .IsNotFound (err ) {
1746
1743
return err
@@ -1932,24 +1929,7 @@ func (a *Operator) createCSVCopyingDisabledEvent(csv *v1alpha1.ClusterServiceVer
1932
1929
return nil
1933
1930
}
1934
1931
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 {
1953
1933
csv , ok := obj .(* v1alpha1.ClusterServiceVersion )
1954
1934
if ! ok {
1955
1935
a .logger .Debugf ("wrong type: %#v" , obj )
@@ -1959,39 +1939,23 @@ func (a *Operator) syncRevertGcCsv(obj interface{}) error {
1959
1939
return nil
1960
1940
}
1961
1941
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" )
1963
1945
1964
1946
// check for any garbage collection
1965
- logger .Info ("syncRevertGcCsv: removeDanglingChildCSVs" )
1966
1947
err := a .removeDanglingChildCSVs (csv )
1967
1948
if err != nil {
1968
1949
return err
1969
1950
}
1970
1951
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 )
1975
1956
return nil
1976
1957
}
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 )
1995
1959
}
1996
1960
1997
1961
// operatorGroupFromAnnotations returns the OperatorGroup for the CSV only if the CSV is active one in the group
0 commit comments