You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/08/02 03:43:04 UTC

[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #11119: [fixed-5105][BE][Common] #5105 yarn state is FINISHED,but FinalStatus is UNDEFINED,will cause task still in running

SbloodyS commented on code in PR #11119:
URL: https://github.com/apache/dolphinscheduler/pull/11119#discussion_r935086190


##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java:
##########
@@ -446,39 +447,39 @@ public ExecutionStatus getApplicationStatus(String applicationId) throws BaseExc
         if (StringUtils.isEmpty(applicationId)) {
             return null;
         }
+        String result = getResult(applicationId, "app", false);
+        if (result == null) {
+            //may be in job history
+            result = getResult(applicationId, "job", true);
+        }
+        return getExecutionStatus(result);
+    }
 
-        String result;
-        String applicationUrl = getApplicationUrl(applicationId);
-        logger.debug("generate yarn application url, applicationUrl={}", applicationUrl);
-
-        String responseContent = Boolean.TRUE.equals(PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false)) ? KerberosHttpClient.get(applicationUrl) : HttpUtils.get(applicationUrl);
+    private String getResult(String applicationId, String filedName, boolean isHistory) throws BaseException {
+        String url = isHistory ? getJobHistoryUrl(applicationId) : getApplicationUrl(applicationId);
+        logger.debug("generate yarn application url or job history application url, url={}", url);
+        String responseContent = Boolean.TRUE.equals(PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false)) ? KerberosHttpClient.get(url) : HttpUtils.get(url);
         if (responseContent != null) {
             ObjectNode jsonObject = JSONUtils.parseObject(responseContent);
-            if (!jsonObject.has("app")) {
-                return ExecutionStatus.FAILURE;
+            if (!jsonObject.has(filedName)) {
+                return Constants.FAILED;
             }
-            result = jsonObject.path("app").path("finalStatus").asText();

Review Comment:
   I think we could add the `UNDEFINED` logic here instead of making such a big change. WDYT?



-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org