-
Notifications
You must be signed in to change notification settings - Fork 231
feat: record desired state in Context #2922
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
base: main
Are you sure you want to change the base?
Conversation
I think we should agree that on these optimization issues we should see the numbers, so we can decide if it is worth it. But as we I think discussed before, there should be no blocking operation in desired state computation, that goes agains the pattern, calculating the desired (thus creating a pojo) is extremely fast - might be faster than getting a resource from a hash map (we need to measure), we should think though what we are actually optimizing with this. |
Agreed but it might also be a good idea to look at the different cache layers which are becoming too complex to properly maintain. |
Note that without this: |
Thinking about this some more, the memory usage should actually be minimal and there is no need to clean things because this isn't a new cache per se as the desired states are put in the |
if it does not survive the reconiliation, why to cache it? |
|
In what use case is the desired state cumputation costy? |
TBH I don't like the fact that we are calling the desired either - and by definition idempotent function. But I'm not convinced that this is the way to solving or should be solved in generic way, users are able to optimize that in some edge cases already. But this is not a strong opinion, so if we are able to solve this elegantly withing the Context I'm open for that. also maybe there is something I just don't see, so happy to dicuss further. Would be nice to see the users specific issue. |
private final ControllerConfiguration<P> controllerConfiguration; | ||
private final DefaultManagedWorkflowAndDependentResourceContext<P> | ||
defaultManagedDependentResourceContext; | ||
private final Map<DependentResource<?, P>, Object> desiredStates = new ConcurrentHashMap<>(); |
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.
This probably should be removed.
I don't have specific issues on hand but it's not unexpected that the desired state could be costly to compute if it requires accessing external systems. There's also the expectation since the beginning of the dependent resource feature that the desired method is only called once during the reconciliation process as it was the case until recently. Here are some issues related to this problem: |
makes sense, thank you! yeah if this can be solved elegantly with such caches, might be a nice improvement |
Signed-off-by: Chris Laprun <[email protected]>
8ca7d47
to
53b1e22
Compare
53b1e22
to
9c56e3d
Compare
Can we merge this, @csviri? |
private final ControllerConfiguration<P> controllerConfiguration; | ||
private final DefaultManagedWorkflowAndDependentResourceContext<P> | ||
defaultManagedDependentResourceContext; | ||
private final Map<DependentResource<?, P>, Object> desiredStates = new ConcurrentHashMap<>(); |
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.
Why are we leaking this into an explicit construct?
Shall this be part rather of ManagedWorkflowAndDependentResourceContext
?
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.
Could we reuse only the already existing map there:
Line 48 in 0dee1bf
<T> T put(Object key, T value); |
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.
Why are we leaking this into an explicit construct? Shall this be part rather of
ManagedWorkflowAndDependentResourceContext
?
It could indeed make sense there even though this isn't specific to managed dependents.
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.
Could we reuse only the already existing map there:
Line 48 in 0dee1bf
<T> T put(Object key, T value);
Sure but that'd be slightly more complex to handle and less type-safe.
added ine comment, sorry I though for some reason this is WIP |
I would also target |
Could we also add some integration test, or which test should cover this functionality? |
I'll look into it but basically the test should be that |
yeah, if you think unit tests are enough, it is fine by me also. thx! |
I disagree: this is a bug fix because the documentation states, and it was the case in v4, that |
I don't see where does it states in the documentation. But it was obvious from the changes for v5 that we can call this multiple times. So it is then more of a documentation problem. Note that that was a major version change, so changes is behavior are fine, and we released also a minor version since then, therefore I believe would be a nicer to have this change in the behavior in minor verison update, even if such behavior existed before. |
I guess it's not stated directly but the state diagram implies that the
Where? That's definitely not true as users keep getting confused by the fact that it can be called multiple times. |
Which users? Could you please link the related issue here?
And don't see why that diagram implies that, but mainly we explicitly state that in the docs that what users should do when to want to avoid calling desired multiple times: There is nothing wrong calling that multiple times, since it is inherently idempotent, and as we dicussed before should not be a blocking operation, we might want to also articulate in the docs. So I see this more of problem from user side we should point him to the docs, but we could also improve the documentation and/or also write a guide about it. We can add it to the FAQ. I also created to PR that improves the docs by adding pointers and adding similar capability that we have for KubernetesDependetResources for ExternalDependentResources, that is a good point that we should have it also there. But in any means since there were further improvements around this please target next branch. |
But I see this as a good improvement, we can get rid of that mechanism, pls target next and also update the documentation. |
Signed-off-by: Chris Laprun [email protected]