@@ -187,6 +187,12 @@ func (r *AdoptionReconciler) ReconcileClusterServiceVersion(ctx context.Context,
187
187
return reconcile.Result {}, err
188
188
}
189
189
190
+ // disown copied csvs - a previous release inadvertently adopted them, this cleans any up if they are adopted
191
+ if in .IsCopied () {
192
+ err := r .disownFromAll (ctx , in )
193
+ return reconcile.Result {}, err
194
+ }
195
+
190
196
// Adopt all resources owned by the CSV if necessary
191
197
return reconcile.Result {}, r .adoptComponents (ctx , in )
192
198
}
@@ -315,6 +321,31 @@ func (r *AdoptionReconciler) disown(ctx context.Context, operator *decorators.Op
315
321
return r .Patch (ctx , uCObj , client .MergeFrom (cObj ))
316
322
}
317
323
324
+ func (r * AdoptionReconciler ) disownFromAll (ctx context.Context , component runtime.Object ) error {
325
+ cObj , ok := component .(client.Object )
326
+ if ! ok {
327
+ return fmt .Errorf ("Unable to typecast runtime.Object to client.Object" )
328
+ }
329
+ var operators []decorators.Operator
330
+ for _ , name := range decorators .OperatorNames (cObj .GetLabels ()) {
331
+ o := & operatorsv1.Operator {}
332
+ o .SetName (name .Name )
333
+ operator , err := r .factory .NewOperator (o )
334
+ if err != nil {
335
+ return err
336
+ }
337
+ operators = append (operators , * operator )
338
+ }
339
+ errs := make ([]error ,0 )
340
+ for _ , operator := range operators {
341
+ if err := r .disown (ctx , & operator , component ); err != nil {
342
+ errs = append (errs , err )
343
+ }
344
+ }
345
+
346
+ return utilerrors .NewAggregate (errs )
347
+ }
348
+
318
349
func (r * AdoptionReconciler ) adoptees (ctx context.Context , operator decorators.Operator , csv * operatorsv1alpha1.ClusterServiceVersion ) ([]runtime.Object , error ) {
319
350
// Note: We need to figure out how to dynamically add new list types here (or some equivalent) in
320
351
// order to support operators composed of custom resources.
0 commit comments