Skip to content

Commit

Permalink
add callback url to taskmaster env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
sgalpha01 committed Aug 16, 2022
1 parent 7214a95 commit d3cda2b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/main/java/uk/ac/ebi/tsc/tesk/k8s/constant/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit d3cda2b

Please sign in to comment.