Skip to content

Commit

Permalink
fix(crd): do not set ownerreference on CRD (opendatahub-io#725)
Browse files Browse the repository at this point in the history
-  we covered the case when set component from Managed to Remvoe
-  this is to cover the case when set have component as Managed and
delete DSC CR
- so if we do not set at first it wont get deleted

Signed-off-by: Wen Zhou <wenzhou@redhat.com>
  • Loading branch information
zdtsw committed Nov 11, 2023
1 parent da25fa5 commit e9461e0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,11 @@ func manageResource(ctx context.Context, cli client.Client, obj *unstructured.Un
// Create the resource if it doesn't exist and component is enabled
if apierrs.IsNotFound(err) {
// Set the owner reference for garbage collection
if err = ctrl.SetControllerReference(owner, metav1.Object(obj), cli.Scheme()); err != nil {
return err
// Skip set on CRD, e.g we should not delete notebook CRD if we delete DSC instance
if found.GetKind() != "CustomResourceDefinition" {
if err = ctrl.SetControllerReference(owner, metav1.Object(obj), cli.Scheme()); err != nil {
return err
}
}

return cli.Create(ctx, obj)
Expand Down

0 comments on commit e9461e0

Please sign in to comment.