Skip to content

Commit a79e83d

Browse files
rakeshgmBenamarMk
authored andcommitted
Do not Set Metrics when DRPC is being deleted
When the request for DRPC to delete is received, we remove the finalizer and then delete the metrics. The object is then processed for deletion. The API server may not delete immediately and it may take some time for garbage collection to complete the request. Ramen may get the reconcile call again for which ramen may get the DRPC object which is the deletion state. At this point in time, we try to set the metrics with zero value and alerts are being fired. The fix here is that metrics will only be set if DRPC is not being deleted Signed-off-by: rakeshgm <[email protected]> (cherry picked from commit 7d7c492)
1 parent cb3c183 commit a79e83d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

controllers/drplacementcontrol_controller.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,7 @@ func (r *DRPlacementControlReconciler) getStatusCheckDelay(
16681668
return time.Until(beforeProcessing.Add(StatusCheckDelay))
16691669
}
16701670

1671+
//nolint:cyclop
16711672
func (r *DRPlacementControlReconciler) updateDRPCStatus(
16721673
ctx context.Context, drpc *rmn.DRPlacementControl, userPlacement client.Object, log logr.Logger,
16731674
) error {
@@ -1683,9 +1684,12 @@ func (r *DRPlacementControlReconciler) updateDRPCStatus(
16831684
r.updateResourceCondition(drpc, clusterDecision.ClusterName, vrgNamespace, log)
16841685
}
16851686

1686-
if err := r.setDRPCMetrics(ctx, drpc, log); err != nil {
1687-
// log the error but do not return the error
1688-
log.Info("failed to set drpc metrics", "errMSg", err)
1687+
// do not set metrics if DRPC is being deleted
1688+
if !isBeingDeleted(drpc, userPlacement) {
1689+
if err := r.setDRPCMetrics(ctx, drpc, log); err != nil {
1690+
// log the error but do not return the error
1691+
log.Info("failed to set drpc metrics", "errMSg", err)
1692+
}
16891693
}
16901694

16911695
for i, condition := range drpc.Status.Conditions {

0 commit comments

Comments
 (0)