Skip to content

Workflow engine implementation #1153

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

Merged
merged 51 commits into from
May 25, 2022
Merged

Workflow engine implementation #1153

merged 51 commits into from
May 25, 2022

Conversation

csviri
Copy link
Collaborator

@csviri csviri commented Apr 11, 2022

No description provided.

import io.javaoperatorsdk.operator.api.reconciler.Context;

/**
* Dependents definition: so if B depends on A, the B is dependent of A.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is confusing since it's the reverse of what we use for DependentResource: the primary resource depends on the dependents…

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, I think the naming needs to be improved here in general. So this is a directed graph at the end, if reverse direction we could use simply parents. Not sure if dependents is actually bad, but yes can be confused with dependent resource from other context, maybe just use child?

@csviri csviri self-assigned this Apr 15, 2022
@csviri csviri changed the base branch from main to next April 19, 2022 15:50
@csviri csviri force-pushed the next branch 2 times, most recently from 60771e8 to 3666014 Compare May 9, 2022 08:19
@csviri csviri force-pushed the workflow branch 3 times, most recently from 011ad48 to 3972845 Compare May 16, 2022 09:52
@csviri csviri marked this pull request as ready for review May 23, 2022 10:33
@csviri csviri requested a review from metacosm May 23, 2022 10:34
Copy link
Collaborator

@metacosm metacosm left a comment

Choose a reason for hiding this comment

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

I think this is a good start we can merge.
Some comments:

  • I think the names being used are too confusing… I especially got confused by the dependents field in Workflow initially (and actually got rid of it in part because of this ^_^)
  • We should have the code fully reactive and only wait for all resources to be processed at the top level
  • Should we use a DAG library? We could probably find one that would handle our use case without needing to maintain our own (especially if we factor in other things like cycle detection and reduction of the graph)

public WebPageDependentsWorkflowReconciler(KubernetesClient kubernetesClient) {
initDependentResources(kubernetesClient);
workflow = new WorkflowBuilder<WebPage>()
.addDependent(configMapDR).build()
Copy link
Collaborator

Choose a reason for hiding this comment

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

that feels weird…

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you mean the addDependent ? could be addDependentResource(), or?

return erroredDependents;
}

public WorkflowExecutionResult setErroredDependents(
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we're not chaining calls, we shouldn't return this, imo…

.getTopLevelDependentResources()) {
handleReconcile(dependentResourceNode);
}
while (true) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't it be better to have the whole implementation reactive and block at a higher level instead of idling here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would be. First I tried with reactive, but this has quite dynamic nature, while with reactive (CompletableFuture etc) is meant to for static workflows. Pretty sure it would be possible somehow just probably not skilled enough in this.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 9 Code Smells

75.4% 75.4% Coverage
0.9% 0.9% Duplication

@csviri
Copy link
Collaborator Author

csviri commented May 25, 2022

Should we use a DAG library? We could probably find one that would handle our use case without needing to maintain our own (especially if we factor in other things like cycle detection and reduction of the graph)

Well we can take a look, but there are parts when the dag is actually traversed back and forth, for example on reconcile delete is made in reverse order on a sub-tree.
For cycle detection we can use a library, and maybe just convert the dag (actually set of dags, but that could be tranformed to single dag adding one parent to all dags) to the library's model just for cycle detection. (if that is hard to implement from scratch)

@csviri csviri merged commit c74756a into next May 25, 2022
@csviri csviri deleted the workflow branch May 25, 2022 14:11
csviri added a commit that referenced this pull request May 26, 2022
csviri added a commit that referenced this pull request May 30, 2022
csviri added a commit that referenced this pull request May 30, 2022
csviri added a commit that referenced this pull request May 31, 2022
csviri added a commit that referenced this pull request Jun 1, 2022
csviri added a commit that referenced this pull request Jun 2, 2022
csviri added a commit that referenced this pull request Jun 2, 2022
csviri added a commit that referenced this pull request Jun 7, 2022
csviri added a commit that referenced this pull request Jun 9, 2022
csviri added a commit that referenced this pull request Jun 17, 2022
csviri added a commit that referenced this pull request Jun 27, 2022
@metacosm metacosm mentioned this pull request Jul 1, 2022
csviri added a commit that referenced this pull request Jul 4, 2022
csviri added a commit that referenced this pull request Jul 13, 2022
csviri added a commit that referenced this pull request Jul 13, 2022
csviri added a commit that referenced this pull request Jul 13, 2022
csviri added a commit that referenced this pull request Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Depends On and Conditions to describe workflows Dependent Resources
2 participants