Will-Lo commented on code in PR #3532:
URL: https://github.com/apache/gobblin/pull/3532#discussion_r937128646


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/DagManager.java:
##########
@@ -1132,24 +1035,39 @@ private void cleanUp() {
           DagNode<JobExecutionPlan> dagNode = dagNodeList.poll();
           deleteJobState(dagId, dagNode);
         }
-        log.info("Dag {} has finished with status FAILED; Cleaning up dag from 
the state store.", dagId);
-        onFlowFailure(dagId);
+        Dag<JobExecutionPlan> dag = this.dags.get(dagId);
+        String status = TimingEvent.FlowTimings.FLOW_FAILED;
+        if 
(TimingEvent.FlowTimings.FLOW_RUN_DEADLINE_EXCEEDED.equals(dag.getFlowEvent())) 
{
+          
this.dagManagerMetrics.emitFlowSlaExceededMetrics(DagManagerUtils.getFlowId(dag));
+        } else if 
(!TimingEvent.FlowTimings.FLOW_START_DEADLINE_EXCEEDED.equals(dag.getFlowEvent()))
 {
+          
dagManagerMetrics.emitFlowFailedMetrics(DagManagerUtils.getFlowId(this.dags.get(dagId)));
+        }
+        addFailedDag(dagId);
+        log.info("Dag {} has finished with status {}; Cleaning up dag from the 
state store.", dagId, status);
         // send an event before cleaning up dag
-        DagManagerUtils.emitFlowEvent(this.eventSubmitter, 
this.dags.get(dagId), TimingEvent.FlowTimings.FLOW_FAILED);
+        DagManagerUtils.emitFlowEvent(this.eventSubmitter, 
this.dags.get(dagId), status);
         dagIdstoClean.add(dagId);
       }
 
-      //Clean up completed dags
-      for (String dagId : this.dags.keySet()) {
+      // Remove dags that are finished and emit their appropriate metrics
+      for (Map.Entry<String, Dag<JobExecutionPlan>> dagIdKeyPair : 
this.dags.entrySet()) {
+        String dagId = dagIdKeyPair.getKey();
+        Dag<JobExecutionPlan> dag = dagIdKeyPair.getValue();
         if (!hasRunningJobs(dagId) && 
!this.failedDagIdsFinishRunning.contains(dagId)) {
           String status = TimingEvent.FlowTimings.FLOW_SUCCEEDED;
           if (this.failedDagIdsFinishAllPossible.contains(dagId)) {
-            onFlowFailure(dagId);
+            if 
(TimingEvent.FlowTimings.FLOW_RUN_DEADLINE_EXCEEDED.equals(dag.getFlowEvent())) 
{
+              
this.dagManagerMetrics.emitFlowSlaExceededMetrics(DagManagerUtils.getFlowId(dag));
+            } else if 
(!TimingEvent.FlowTimings.FLOW_START_DEADLINE_EXCEEDED.equals(dag.getFlowEvent()))
 {
+              
this.dagManagerMetrics.conditionallyMarkFlowAsState(DagManagerUtils.getFlowId(this.dags.get(dagId)),
+                  DagManager.FlowState.FAILED);
+              
dagManagerMetrics.emitFlowFailedMetrics(DagManagerUtils.getFlowId(this.dags.get(dagId)));
+            }
             status = TimingEvent.FlowTimings.FLOW_FAILED;
+            addFailedDag(dagId);
             this.failedDagIdsFinishAllPossible.remove(dagId);
-            conditionallyUpdateFlowGaugeExecutionState(flowGauges, 
DagManagerUtils.getFlowId(this.dags.get(dagId)), FlowState.FAILED);

Review Comment:
   I think it was unintentional, I went back and forth on where to add the flow 
gauge removal and mistakenly left it out of addFailedDag(), will add it there



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to