Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accept callback_url #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion 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,11 +21,16 @@ 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
*/
public static final String TASKMASTER_INPUT_EXEC_KEY = "executors";

/**
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,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
27 changes: 26 additions & 1 deletion src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class TesTask {
@JsonProperty("description")
private String description;

@JsonProperty("callback_url")
private String callbackUrl;

@JsonProperty("inputs")
@Valid
private List<TesInput> inputs = null;
Expand Down Expand Up @@ -144,6 +147,26 @@ public void setDescription(String description) {
this.description = description;
}

public TesTask callbackUrl(String callbackUrl) {
this.callbackUrl = callbackUrl;
return this;
}

/**
* Optional user-provided callback URL.
* @return callbackUrl
*/
@ApiModelProperty(value = "Optional user-provided callback URL.")


public String getCallbackUrl() {
return callbackUrl;
}

public void setCallbackUrl(String callbackUrl) {
this.callbackUrl = callbackUrl;
}

public TesTask inputs(List<TesInput> inputs) {
this.inputs = inputs;
return this;
Expand Down Expand Up @@ -372,6 +395,7 @@ public boolean equals(Object o) {
Objects.equals(this.state, tesTask.state) &&
Objects.equals(this.name, tesTask.name) &&
Objects.equals(this.description, tesTask.description) &&
Objects.equals(this.callbackUrl, tesTask.callbackUrl) &&
Objects.equals(this.inputs, tesTask.inputs) &&
Objects.equals(this.outputs, tesTask.outputs) &&
Objects.equals(this.resources, tesTask.resources) &&
Expand All @@ -384,7 +408,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(id, state, name, description, inputs, outputs, resources, executors, volumes, tags, logs, creationTime);
return Objects.hash(id, state, name, description, callbackUrl, inputs, outputs, resources, executors, volumes, tags, logs, creationTime);
}

@Override
Expand All @@ -396,6 +420,7 @@ public String toString() {
sb.append(" state: ").append(toIndentedString(state)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" callbackUrl: ").append(toIndentedString(callbackUrl)).append("\n");
sb.append(" inputs: ").append(toIndentedString(inputs)).append("\n");
sb.append(" outputs: ").append(toIndentedString(outputs)).append("\n");
sb.append(" resources: ").append(toIndentedString(resources)).append("\n");
Expand Down