Skip to content

Commit

Permalink
Do not use the ExecutionRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri1969 committed Sep 16, 2023
1 parent 039176b commit 2c2828a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ private Executor handleFlowTask(final Executor executor) {
);

try {
Execution execution = flowTask.createExecution(runContext, flowExecutorInterface());
Execution execution = flowTask.createExecution(runContext, flowExecutorInterface(), executor.getExecution());

WorkerTaskExecution workerTaskExecution = WorkerTaskExecution.builder()
.task(flowTask)
Expand Down
13 changes: 2 additions & 11 deletions core/src/main/java/io/kestra/core/tasks/flows/Flow.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import io.kestra.core.models.flows.State;
import io.kestra.core.models.tasks.RunnableTask;
import io.kestra.core.models.tasks.Task;
import io.kestra.core.repositories.ExecutionRepositoryInterface;
import io.kestra.core.runners.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
Expand Down Expand Up @@ -126,9 +125,8 @@ public String flowUidWithoutRevision() {
}

@SuppressWarnings("unchecked")
public Execution createExecution(RunContext runContext, FlowExecutorInterface flowExecutorInterface) throws Exception {
public Execution createExecution(RunContext runContext, FlowExecutorInterface flowExecutorInterface, Execution currentExecution) throws Exception {
RunnerUtils runnerUtils = runContext.getApplicationContext().getBean(RunnerUtils.class);
ExecutionRepositoryInterface executionRepository = runContext.getApplicationContext().getBean(ExecutionRepositoryInterface.class);

Map<String, String> inputs = new HashMap<>();
if (this.inputs != null) {
Expand All @@ -139,8 +137,7 @@ public Execution createExecution(RunContext runContext, FlowExecutorInterface fl

List<Label> labels = new ArrayList<>();
if (this.inheritLabels) {
Optional<Execution> currentExecution = getCurrentExecution(runContext, executionRepository);
labels.addAll(currentExecution.orElseThrow().getLabels());
labels.addAll(currentExecution.getLabels());
}
if (this.labels != null) {
for (Map.Entry<String, String> entry: this.labels.entrySet()) {
Expand Down Expand Up @@ -257,10 +254,4 @@ public static class Output implements io.kestra.core.models.tasks.Output {
)
private final Map<String, Object> outputs;
}

private Optional<Execution> getCurrentExecution(RunContext runContext, ExecutionRepositoryInterface executionRepository) {
final String executionId = ((Map<String, String>) runContext.getVariables().get("execution")).get("id");

return executionRepository.findById(executionId);
}
}

0 comments on commit 2c2828a

Please sign in to comment.