From d3cda2bb568b5e5cc861d962238920defb096f6e Mon Sep 17 00:00:00 2001 From: Suyash Gupta Date: Thu, 11 Aug 2022 20:53:40 +0530 Subject: [PATCH] add callback url to taskmaster env variables --- .../uk/ac/ebi/tsc/tesk/k8s/constant/Constants.java | 10 +++++----- .../tsc/tesk/k8s/convert/TesKubernetesConverter.java | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/uk/ac/ebi/tsc/tesk/k8s/constant/Constants.java b/src/main/java/uk/ac/ebi/tsc/tesk/k8s/constant/Constants.java index 9419dd3..ede544b 100644 --- a/src/main/java/uk/ac/ebi/tsc/tesk/k8s/constant/Constants.java +++ b/src/main/java/uk/ac/ebi/tsc/tesk/k8s/constant/Constants.java @@ -21,6 +21,11 @@ public class Constants { */ public static final String TASKMASTER_INPUT = "JSON_INPUT"; + /** + * ENV var that stores the callback URL + */ + public static final String TASKMASTER_CALLBACK_URL = "CALLBACK_URL"; + /** * Key in JSON taskmaster input, which holds list of executors */ @@ -69,11 +74,6 @@ public class Constants { */ public static final String ANN_JSON_INPUT_KEY = "json-input"; - /** - * Key of the annotation, that stores the callback URL - */ - public static final String ANN_CALLBACK_URL_KEY = "callback_url"; - /** * Key of the label, that stores taskmaster's name (==TES task generated ID) in executor jobs */ diff --git a/src/main/java/uk/ac/ebi/tsc/tesk/k8s/convert/TesKubernetesConverter.java b/src/main/java/uk/ac/ebi/tsc/tesk/k8s/convert/TesKubernetesConverter.java index b5b3ba9..e12e2e4 100644 --- a/src/main/java/uk/ac/ebi/tsc/tesk/k8s/convert/TesKubernetesConverter.java +++ b/src/main/java/uk/ac/ebi/tsc/tesk/k8s/convert/TesKubernetesConverter.java @@ -75,10 +75,6 @@ public V1Job fromTesTaskToK8sJob(TesTask task, User user) { V1Job taskMasterJob = this.taskmasterTemplateSupplier.get(); //put input task name as annotation taskMasterJob.getMetadata().putAnnotationsItem(ANN_TESTASK_NAME_KEY, task.getName()); - // put callback URL as annotation - if (task.getCallbackUrl() != null) { - taskMasterJob.getMetadata().putAnnotationsItem(ANN_CALLBACK_URL_KEY, task.getCallbackUrl()); - } //creating user and owning group taskMasterJob.getMetadata().putLabelsItem(LABEL_USERID_KEY, user.getUsername()); if (task.getTags() != null && task.getTags().containsKey("GROUP_NAME")) { @@ -117,6 +113,10 @@ public V1Job fromTesTaskToK8sJob(TesTask task, User user) { String taskMasterInputAsJSON = this.gson.toJson(taskMasterInput); //placing taskmaster's parameter (JSONed map of: inputs, outputs, volumes, executors (as jobs) into ENV variable in taskmaster spec taskMasterJob.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv().stream().filter(x -> x.getName().equals(TASKMASTER_INPUT)).forEach(x -> x.setValue(taskMasterInputAsJSON)); + //place callback URL as ENV variable in taskmaster spec + if (task.getCallbackUrl() != null) { + taskMasterJob.getSpec().getTemplate().getSpec().getContainers().get(0).addEnvItem(new V1EnvVar().name(TASKMASTER_CALLBACK_URL).value(task.getCallbackUrl())); + } return taskMasterJob; }