From 8209baea55cdd8b29e79752185499c04f90f1e28 Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Sun, 13 Oct 2024 21:40:39 -0700 Subject: [PATCH 1/3] support priority override for sub workflows --- .../common/metadata/workflow/SubWorkflowParams.java | 11 +++++++++++ .../core/execution/mapper/SubWorkflowTaskMapper.java | 1 + 2 files changed, 12 insertions(+) diff --git a/common/src/main/java/com/netflix/conductor/common/metadata/workflow/SubWorkflowParams.java b/common/src/main/java/com/netflix/conductor/common/metadata/workflow/SubWorkflowParams.java index 66040b593..5f5dd0143 100644 --- a/common/src/main/java/com/netflix/conductor/common/metadata/workflow/SubWorkflowParams.java +++ b/common/src/main/java/com/netflix/conductor/common/metadata/workflow/SubWorkflowParams.java @@ -45,6 +45,9 @@ public class SubWorkflowParams { private IdempotencyStrategy idempotencyStrategy; + //Priority of the sub workflow, not set inherits from the parent + private Integer priority; + public String getIdempotencyKey() { return idempotencyKey; } @@ -61,6 +64,14 @@ public void setIdempotencyStrategy(IdempotencyStrategy idempotencyStrategy) { this.idempotencyStrategy = idempotencyStrategy; } + public Integer getPriority() { + return priority; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + /** * @return the name */ diff --git a/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java b/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java index ab7d9c291..48636e435 100644 --- a/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java +++ b/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java @@ -83,6 +83,7 @@ public List getMappedTasks(TaskMapperContext taskMapperContext) { subWorkflowTask.addInput("workflowInput", taskMapperContext.getTaskInput()); subWorkflowTask.setStatus(TaskModel.Status.SCHEDULED); subWorkflowTask.setCallbackAfterSeconds(workflowTask.getStartDelay()); + subWorkflowTask.setWorkflowPriority(subWorkflowParams.getPriority()); LOGGER.debug("SubWorkflowTask {} created to be Scheduled", subWorkflowTask); return List.of(subWorkflowTask); } From c800fed36a37875728de9d6a88ccf251647f74b2 Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Sun, 13 Oct 2024 21:48:29 -0700 Subject: [PATCH 2/3] formatting --- .../conductor/common/metadata/workflow/SubWorkflowParams.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/com/netflix/conductor/common/metadata/workflow/SubWorkflowParams.java b/common/src/main/java/com/netflix/conductor/common/metadata/workflow/SubWorkflowParams.java index 5f5dd0143..d17378862 100644 --- a/common/src/main/java/com/netflix/conductor/common/metadata/workflow/SubWorkflowParams.java +++ b/common/src/main/java/com/netflix/conductor/common/metadata/workflow/SubWorkflowParams.java @@ -45,7 +45,7 @@ public class SubWorkflowParams { private IdempotencyStrategy idempotencyStrategy; - //Priority of the sub workflow, not set inherits from the parent + // Priority of the sub workflow, not set inherits from the parent private Integer priority; public String getIdempotencyKey() { From 16a7c0712899c9ab674f99dae1126c99727095fd Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Sun, 13 Oct 2024 21:56:00 -0700 Subject: [PATCH 3/3] handle NPE --- .../core/execution/mapper/SubWorkflowTaskMapper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java b/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java index 48636e435..fae54660b 100644 --- a/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java +++ b/core/src/main/java/com/netflix/conductor/core/execution/mapper/SubWorkflowTaskMapper.java @@ -83,7 +83,9 @@ public List getMappedTasks(TaskMapperContext taskMapperContext) { subWorkflowTask.addInput("workflowInput", taskMapperContext.getTaskInput()); subWorkflowTask.setStatus(TaskModel.Status.SCHEDULED); subWorkflowTask.setCallbackAfterSeconds(workflowTask.getStartDelay()); - subWorkflowTask.setWorkflowPriority(subWorkflowParams.getPriority()); + if (subWorkflowParams.getPriority() != null) { + subWorkflowTask.setWorkflowPriority(subWorkflowParams.getPriority()); + } LOGGER.debug("SubWorkflowTask {} created to be Scheduled", subWorkflowTask); return List.of(subWorkflowTask); }