Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
set owner reference for CR created by OpReq
Signed-off-by: Daniel Fan <[email protected]>
  • Loading branch information
Daniel-Fan committed May 15, 2023
commit 7e9a739c9172cc2f99843ff26fe8cf97320e1f8c
5 changes: 5 additions & 0 deletions controllers/operandrequest/reconcile_operand.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/discovery"
"k8s.io/klog"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

operatorv1alpha1 "github.com/IBM/operand-deployment-lifecycle-manager/api/v1alpha1"
constant "github.com/IBM/operand-deployment-lifecycle-manager/controllers/constant"
Expand Down Expand Up @@ -380,6 +381,10 @@ func (r *Reconciler) reconcileCRwithRequest(ctx context.Context, requestInstance
crFromRequest.SetNamespace(requestKey.Namespace)
crFromRequest.SetAPIVersion(operand.APIVersion)
crFromRequest.SetKind(operand.Kind)
// Set the OperandRequest as the controller of the CR from request
if err := controllerutil.SetControllerReference(requestInstance, &crFromRequest, r.Scheme); err != nil {
merr.Add(errors.Wrapf(err, "failed to set ownerReference for custom resource %s/%s", requestKey.Namespace, name))
}

err := r.Client.Get(ctx, types.NamespacedName{
Name: name,
Expand Down