From 0e3239dee3ab49df2f8fddeab35228a68115cd3d Mon Sep 17 00:00:00 2001 From: vbadrina Date: Tue, 23 Apr 2024 14:51:43 +0530 Subject: [PATCH] Return not found error The commit fixes a bug where it throws a nil pointer reference when no error or mirrorpeer is returned from the function Signed-off-by: vbadrina --- controllers/drpolicy_controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/drpolicy_controller.go b/controllers/drpolicy_controller.go index a1120d6f..8e38679f 100644 --- a/controllers/drpolicy_controller.go +++ b/controllers/drpolicy_controller.go @@ -112,7 +112,7 @@ func (r *DRPolicyReconciler) getMirrorPeerForClusterSet(ctx context.Context, clu } klog.Info("could not find any mirrorpeer for drpolicy") - return nil, nil + return nil, k8serrors.NewNotFound(schema.GroupResource{Group: multiclusterv1alpha1.GroupVersion.Group, Resource: "MirrorPeer"}, fmt.Sprintf("ClusterSet-%s-%s", clusterSet[0], clusterSet[1])) } func (r *DRPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { klog.Infof("running DRPolicy reconciler on hub cluster")