Skip to content

Commit 7d7c492

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]>
1 parent 13ee1a2 commit 7d7c492

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
@@ -1666,6 +1666,7 @@ func (r *DRPlacementControlReconciler) getStatusCheckDelay(
16661666
return time.Until(beforeProcessing.Add(StatusCheckDelay))
16671667
}
16681668

1669+
//nolint:cyclop
16691670
func (r *DRPlacementControlReconciler) updateDRPCStatus(
16701671
ctx context.Context, drpc *rmn.DRPlacementControl, userPlacement client.Object, log logr.Logger,
16711672
) error {
@@ -1681,9 +1682,12 @@ func (r *DRPlacementControlReconciler) updateDRPCStatus(
16811682
r.updateResourceCondition(drpc, clusterDecision.ClusterName, vrgNamespace, log)
16821683
}
16831684

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

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

0 commit comments

Comments
 (0)