EricGao888 commented on code in PR #13550:
URL:
https://github.com/apache/dolphinscheduler/pull/13550#discussion_r1112571056
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/BaseTaskProcessor.java:
##########
@@ -635,18 +633,39 @@ public Map<String, String>
getResourceFullNames(TaskInstance taskInstance) {
}
/**
- * set k8s task relation
- * @param k8sTaskExecutionContext k8sTaskExecutionContext
+ * get k8s task execution context based on task type and deploy mode
+ *
* @param taskInstance taskInstance
*/
- private void setK8sTaskRelation(K8sTaskExecutionContext
k8sTaskExecutionContext, TaskInstance taskInstance) {
- K8sTaskParameters k8sTaskParameters =
- JSONUtils.parseObject(taskInstance.getTaskParams(),
K8sTaskParameters.class);
- Map<String, String> namespace =
JSONUtils.toMap(k8sTaskParameters.getNamespace());
- String clusterName = namespace.get(CLUSTER);
- String configYaml = processService.findConfigYamlByName(clusterName);
- if (configYaml != null) {
- k8sTaskExecutionContext.setConfigYaml(configYaml);
+ private K8sTaskExecutionContext setK8sTaskRelation(TaskInstance
taskInstance) {
+ K8sTaskExecutionContext k8sTaskExecutionContext = null;
+ String namespace = "";
+ switch (taskInstance.getTaskType()) {
+ case "K8S":
+ case "KUBEFLOW":
+ K8sTaskParameters k8sTaskParameters =
+ JSONUtils.parseObject(taskInstance.getTaskParams(),
K8sTaskParameters.class);
+ namespace = k8sTaskParameters.getNamespace();
+ break;
+ case "SPARK":
+ SparkParameters sparkParameters =
+ JSONUtils.parseObject(taskInstance.getTaskParams(),
SparkParameters.class);
+ if (StringUtils.isNotEmpty(sparkParameters.getNamespace())) {
+ namespace = sparkParameters.getNamespace();
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (StringUtils.isNotEmpty(namespace)) {
+ String clusterName = JSONUtils.toMap(namespace).get(CLUSTER);
+ String configYaml =
processService.findConfigYamlByName(clusterName);
Review Comment:
https://github.com/apache/dolphinscheduler/blob/eaf2541018a1818ad5a0f1cbefe98b095bcc9b8b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java#L2661-L2671
Not sure why method `findConfigYamlByName` was defined in interface
`ProcessService`. But this is not related to this PR, we could improve it later.
--
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]