Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Pass context params from an execution to a workfflow exeuction #426

Closed
wants to merge 2 commits into from

Conversation

rgolangh
Copy link
Contributor

@rgolangh rgolangh commented Jun 14, 2023

Add invokingExecutionId to WorkflowRequestDTO to support context passing

Enable using arguments from different another execution to use its
execution level parameters.

This could be used when an assessment workflow gathers information and
stores it on the context and then when invoking a follow-up workflow
from the options of that assessment then the requester can pass the
execution ID of the assessment.

The data flow looks like that:

Start -> Assessment flow -> addParameter "foo": "bar" to WorkContext -> End with
option 1

Start -> Workflow from option 1 -> use Workcontext param "foo" -> work
-> End

The invoking execution ID isn't stored in the DB, it is just a request
argument passed in the POST request for invoking a workflow.

Signed-off-by: Roy Golan <rgolan@redhat.com>

FLPATH-458

Signed-off-by: Roy Golan <rgolan@redhat.com>
Enable using arguments from different another execution to use its
execution level parameters.

This could be used when an assessment workflow gathers inormation and
stores it on the context and then when invoking a follow up workflow
from the options of that assessment then the requester can pass the
execution ID of the assessment.

The data flow looks like that:

Start -> Asssessment flow -> addParameter "foo": "bar" to WorkContext -> End with
option 1

Start -> Workflow from option 1 -> use Workcontext param "foo" -> work
-> End

The invoking execution ID isn't stored in the DB, it is just a request
argument passed in the POST request for invoking a workflow.

Signed-off-by: Roy Golan <rgolan@redhat.com>
@openshift-ci
Copy link

openshift-ci bot commented Jun 14, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from rgolangh. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rgolangh
Copy link
Contributor Author

/WIP don't merge yet, needs testing

@rgolangh rgolangh changed the title branch info for mta Pass context params from an execution to a workfflow exeuction Jun 14, 2023
@rgolangh
Copy link
Contributor Author

/WIP

@rgolangh
Copy link
Contributor Author

/hold needs testing

@@ -76,9 +77,10 @@ public void createFails() {
public void createCompletes() {
ctx.put("applicationName", APP_NAME);
ctx.put("repositoryURL", REPO_URL);
ctx.put("branch", REPO_URL);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be a branch name (e.g. main/dev)

* The ID of the flow that lead to execution of this workflow. Useful for passing
* context from execution to execution
*/
private UUID invokingExecutionID;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls rename to invokingExecutionId (lowe d at the end to match convention projectId, workflowExecutionId...)

@@ -66,6 +72,8 @@ public static class WorkRequestDTO {
// recursive works
List<WorkRequestDTO> works;

UUID invokingExecutionID;
Copy link
Collaborator

@masayag masayag Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need it on work-unit level.
The context is expected to be shared - so should be set only on the top level.

*/
private void mergeContextArgumentsFromExecution(UUID executionId, WorkContext target) {
WorkFlowExecution invokedBy = workFlowRepository.getById(executionId);
if (invokedBy != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest wrapping this with com.redhat.parodos.common.exceptions.ResourceNotFoundException in case of failure to find it.
the global exception handler will know to handle it properly.

@@ -1603,6 +1603,10 @@
"$ref" : "#/components/schemas/ArgumentRequestDTO"
}
},
"invokingExecutionID" : {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the name :-)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@masayag
Copy link
Collaborator

masayag commented Jun 15, 2023

Closed since was merged by #433

@masayag masayag closed this Jun 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants