From 6f20b28a6c35b6b58d83571c293fe4c975143f66 Mon Sep 17 00:00:00 2001 From: rakeshgm Date: Wed, 30 Aug 2023 21:36:28 +0530 Subject: [PATCH] metrics:set metrics if not nil Signed-off-by: rakeshgm --- controllers/drplacementcontrol_controller.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/controllers/drplacementcontrol_controller.go b/controllers/drplacementcontrol_controller.go index 5a946217e..67d7e8faa 100644 --- a/controllers/drplacementcontrol_controller.go +++ b/controllers/drplacementcontrol_controller.go @@ -1506,7 +1506,9 @@ func (r *DRPlacementControlReconciler) updateResourceCondition( drpc.Status.ResourceConditions = rmn.VRGConditions{} drpc.Status.LastGroupSyncTime = nil - r.setLastSyncTimeMetric(syncmetric, nil, log) + if syncmetric != nil { + r.setLastSyncTimeMetric(syncmetric, nil, log) + } } else { drpc.Status.ResourceConditions.ResourceMeta.Kind = vrg.Kind drpc.Status.ResourceConditions.ResourceMeta.Name = vrg.Name @@ -1522,7 +1524,9 @@ func (r *DRPlacementControlReconciler) updateResourceCondition( drpc.Status.ResourceConditions.ResourceMeta.ProtectedPVCs = protectedPVCs drpc.Status.LastGroupSyncTime = vrg.Status.LastGroupSyncTime - r.setLastSyncTimeMetric(syncmetric, vrg.Status.LastGroupSyncTime, log) + if syncmetric != nil { + r.setLastSyncTimeMetric(syncmetric, vrg.Status.LastGroupSyncTime, log) + } } }