This is an automated email from the ASF dual-hosted git repository.
weiraowang pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 93ea5f64c3 [Improvement][K8S] Custom label of a K8S task can be passed
to the pod (#15369)
93ea5f64c3 is described below
commit 93ea5f64c31311ab066d2093dbecd6e2f4215c68
Author: Gallardot <[email protected]>
AuthorDate: Thu Dec 28 13:49:29 2023 +0800
[Improvement][K8S] Custom label of a K8S task can be passed to the pod
(#15369)
Signed-off-by: Gallardot <[email protected]>
---
.../plugin/task/api/k8s/impl/K8sTaskExecutor.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git
a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/k8s/impl/K8sTaskExecutor.java
b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/k8s/impl/K8sTaskExecutor.java
index 1ce6b12c22..167cae8668 100644
---
a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/k8s/impl/K8sTaskExecutor.java
+++
b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/k8s/impl/K8sTaskExecutor.java
@@ -112,11 +112,17 @@ public class K8sTaskExecutor extends
AbstractK8sTaskExecutor {
Map<String, Quantity> limitRes = new HashMap<>();
limitRes.put(MEMORY, new Quantity(String.format("%s%s", limitPodMem,
MI)));
limitRes.put(CPU, new Quantity(String.valueOf(limitPodCpu)));
+
Map<String, String> labelMap = k8STaskMainParameters.getLabelMap();
- labelMap.put(LAYER_LABEL, LAYER_LABEL_VALUE);
- labelMap.put(NAME_LABEL, k8sJobName);
+ Map<String, String> jobLabelMap = new HashMap<>();
+ jobLabelMap.put(LAYER_LABEL, LAYER_LABEL_VALUE);
+ jobLabelMap.put(NAME_LABEL, k8sJobName);
+ jobLabelMap.putAll(labelMap);
+
Map<String, String> podLabelMap = new HashMap<>();
podLabelMap.put(UNIQUE_LABEL_NAME, taskRequest.getTaskAppId());
+ podLabelMap.putAll(labelMap);
+
EnvVar taskInstanceIdVar = new EnvVar(TASK_INSTANCE_ID,
taskInstanceId, null);
List<EnvVar> envVars = new ArrayList<>();
envVars.add(taskInstanceIdVar);
@@ -161,7 +167,7 @@ public class K8sTaskExecutor extends
AbstractK8sTaskExecutor {
.withApiVersion(API_VERSION)
.withNewMetadata()
.withName(k8sJobName)
- .withLabels(labelMap)
+ .withLabels(jobLabelMap)
.withNamespace(namespaceName)
.endMetadata()
.withNewSpec()