pratapaditya04 commented on code in PR #4197:
URL: https://github.com/apache/gobblin/pull/4197#discussion_r3347374001


##########
gobblin-temporal/src/main/java/org/apache/gobblin/temporal/joblauncher/GobblinTemporalJobLauncher.java:
##########
@@ -97,9 +107,64 @@ public GobblinTemporalJobLauncher(Properties jobProps, Path 
appWorkDir,
 
     // non-null value indicates job has been submitted
     this.workflowId = null;
+    // Reset the process-wide terminal-status cache for this fresh launcher. 
In a real AM JVM only one
+    // launcher ever runs, but tests re-instantiate within the same JVM and 
must not see leaked status.
+    setLastTerminalStatus(null);
     startCancellationExecutor();
   }
 
+  /**
+   * Query Temporal for the current execution status of {@link #workflowId}. 
Returns
+   * {@code WORKFLOW_EXECUTION_STATUS_UNSPECIFIED} as a safe fallback if the 
describe call fails, so callers
+   * downstream emit a JOB_FAILED rather than swallowing the GTE entirely.
+   */
+  private WorkflowExecutionStatus fetchWorkflowStatus() {
+    try {
+      WorkflowStub workflowStub = 
this.client.newUntypedWorkflowStub(this.workflowId);
+      DescribeWorkflowExecutionRequest request = 
DescribeWorkflowExecutionRequest.newBuilder()
+          .setNamespace(this.namespace)
+          .setExecution(workflowStub.getExecution())
+          .build();
+      DescribeWorkflowExecutionResponse response = 
managedWorkflowServiceStubs.getWorkflowServiceStubs()
+          .blockingStub().describeWorkflowExecution(request);
+      return response.getWorkflowExecutionInfo().getStatus();
+    } catch (Exception e) {
+      log.warn("Failed to describe workflow {} for completion GTE; treating as 
UNSPECIFIED (will emit JOB_FAILED)",
+          this.workflowId, e);
+      return WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_UNSPECIFIED;
+    }

Review Comment:
    I guess temporal sdk already internally retries on its apis,, that should 
be applicable here 



-- 
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