-
Notifications
You must be signed in to change notification settings - Fork 216
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
fix: explicit workflow invocation uses the same resource intance that reconcile api #2686
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big fan of exposing this method only for tests…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for jumping in here, but if this method is not exposed, how a main reconciliation loop will be aware that the primary resource has changed if in the middle of one reconciliation an explicit dependent resource reconciliation is requested via
context.managedWorkflowAndDependentResourceContext().reconcileManagedWorkflow();
It may happen that the primary resource is updated, or either its status, and then the main reconciliation loop will not be using a most up to date version of the primary resource. Or am I wrong?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@afalhambra-hivemq usually you get this as a parameter for example here for dependent resources:
java-operator-sdk/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentResource.java
Line 254 in 1e3ac83
It is not part of the interface (Context) just the impl so it is unit testable but you never access this primary resource through this method. I think @metacosm has a point I'm not big fan either, but on the other hand if there is no other way to unit test it I prefer to be just pragmatic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that's the intent here, though. Also, the primary should probably not changed during a reconciliation loop but be the target of a subsequent reconciliation because otherwise the current one might be operating on inconsistent basis (for example, some dependents might have seen the old primary version and taken decisions based on that, while others might see a new, possibly contradictory version…)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use SSA should not change, otherwise fine. We should explain that in docs maybe more thoroughly or in a separate blogpost.
Will expand that section in release blogpost (currently there is a TODO 😶🌫️ )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your replies both.
Just to clarify our current scenario here.
Currently on JOSDK 4.9.7 we have managed dependent resources where in their reconcile method we update the status of the primary resource.... then the main/primary reconcile method is called afterwards with the primary and context as a parameter. - Did I understand then that updating the status of the primary on the DR renconcile method may lead to inconsistencies?
Am just asking cause we're already planning to upgrade to JOSDK 5.0.1, and would like to use the new feature to call explicitly the reconcile method on the managed dependent resources by calling
context.managedWorkflowAndDependentResourceContext().reconcileManagedWorkflow()
from the main/primary reconcile method, but then of course, once the method is done and the DR are reconciled, the primary object on this main/primary reconcile method won't be up to date with potential changes from the reconcile calls on the DRs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @afalhambra-hivemq ,
currently working on blogpost regarding to this, what you do should to be fine if you set:
ConfigurationService.useSSAToPatchPrimaryResource
to false and this PR change released.
For SSA, basically it is required that you just create a resources where you set fields which you have "opinion". See
https://kubernetes.io/docs/reference/using-api/server-side-apply/
But it is not mandatory to use that in JOSDK, this flag to don't use SSA is not just for making the migration doable in multiple steps, we want to keep it also for the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you both, I tested it and works like a charm. Even with
ConfigurationService.useSSAToPatchPrimaryResource
set totrue
.