-
Notifications
You must be signed in to change notification settings - Fork 218
Depends On and Conditions to describe workflows Dependent Resources #850
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
Comments
How could they be detected automatically? This processing needs to happen at build time so unless you perform static analysis I don't see how it would be possible… |
yep, don't think it's practically possible, without explicitly stating them anyways. So the best what can be easily done is the depends on. Will update the description. |
This is a good starting point to model state transitions! Something that I'm not sure about is if it should be modelled as an Another comment is around I think that a valid almost real-world use case to test this feature against could be:
NOTE1: I understand that the first NOTE2: Part of this feature is offered by some popular operators (e.g. Reloader) but is an arguably common task/pattern for operators and it would be nice if the SDK can take care of those details. I hope this comment doesn't go too much beyond the original scope of this issue. |
I guess we won't, that mean the resource A is somehow make sense to reconcile if the resource B is in a certain condition.
Agree, probably needs to be the target resource but maybe the whole context accessible from a condition API.
This use case would be perfectly covered with this design. We can create an e2e test for this. The use case you mentioned on community meeting, that there might be a job that is created and executed only once, and deleted is I think completely covered also with this: #851 Than you very much for feedback @andreaTP! |
I might be missing something, but I think that resource A reconciler should be triggered anyhow, with appropriate parameter/s(
|
This would be great ❤️ |
Updated the design also added description. There can be now a ( |
dependsOn
Construct for Dependent ResourcesdependsOn
and Conditions
to describe workflows Dependent Resources
dependsOn
and Conditions
to describe workflows Dependent Resources
Regarding exception handling but also for waitCondition and cleanupCondition, there is an interesting design option: being In other works if a reconciliation of a resource fails, but other independent resources might be still reconciled, should we proceed with them? Same for wait and cleanup conditions, if a wait condition does not met, now reconciler can exit immediately (of course wait for already running reconciliations to finish - since execution is parallel). Or still reconcile the the independent resources. And just return with the update control that is specified with the first wait condition not met. In the long terms, since the workflow can be executed concurrently (for independent resources), it might make sense to not fail fails. So the time to the target state is shorter. Assuming that some resources (like Deployments) might take time to get into ready state. |
An additional detail described here: So at the end it seems all dependent resources will provide an event source, more precisely a |
UPDATE: |
Problem statement
Solution
Both of these issues, can be addressed by with notions.
dependsOn
- If a dependent resourceB
depends on an other dependentA
, this will ensure thatB
will be reconciled afterA
is ready (see optionalReadyCondition
).ReconcilePrecondition
is optional for a dependent, if available it is evaluated if a resource should be reconciled or not.ReadyPostcondition
is optional, is provided the dependent is considered reconciled if the certain state reached. The condition check is async.DeletePostcondition
- on cleanup (backwards workflow) checks if the resource is deleted successfully (or delete completed) , or the cleanup execution should be re-scheduled (the finalizer not removed).Behavior Details
B
depends onA
, butA
has aReconcilePrecondition
is evaluated as false, thenB
will not be reconciled either.ReconcilePrecondition
is evaluated false onA
dependent resource it is aDeleter
, delete should be called on it. And all the resources which are dependent onA
and are deleters should be deleted. This should work in a transitive manner too ( in reveres order, so the resource with reconcile condition closer to the top is deleted later). (See: https://github.com/java-operator-sdk/java-operator-sdk/blob/4d63e1260efeb70ac7550d52e48117bf8982fabb/sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageStandaloneDependentsReconciler.java#L68-L72 )ReadyPostcondition
can define anUpdateControl
to return if the condition is now reached, this means that effectively wait is always async. It can also defined time delay to reschedule the reconciliation.Sync and Async Waiting Condition
Note that waiting for a state condition can happen synchronously or asynchronously, thus if we know that we will wait for deployment quite a long time to be ready, the scheduling algirthm can just exit the reonciliation and schedule a new reconciliation for a specified delay (
UpdateControl.noUpdate().rescheduleAfter(2, TimeUnit.MINUTES)
if the condition not holds at the moment.UPDATE: we discussed, for now and sync wait will be out of scope
Notes
Deleter
dependent resources.To Discuss
DeletePostcondition
could be replaced by returning a boolean fromdelete
ofDeleter
.The text was updated successfully, but these errors were encountered: