-
Notifications
You must be signed in to change notification settings - Fork 63
Merge would fail if an rhs partially specified object omits key fields despite they can be derived from paths #273
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
Can you describe the steps that lead to that situation? It's a bit unclear how you get that. |
Call Note, that it's not enough to just add key fields to the If I understand correctly, the solution would be to update Merge's validation logic to not require key fields paths to be present if they can be derived from other paths. I.e. if we have |
Is this actually a reachable scenario using server-side apply? I don't really think we should open the door to allowing the key field to be absent and non-defaulted from a RHS |
It's happening with server-side diff, see the linked ArgoCD issue (argoproj/argo-cd#20792). |
@jpbetz, do you have any thoughts on this? |
This is the part where I get lost. A associative list in an apply configuration is just a list of objects where the logical map keys are defined to be fields of that list entries. Without the Is this maybe a problem with error messaging, or is there a reason that a |
The problem is when we compute the comparison and get Removed part, paths like |
Ah, so the issue is specifically taking result of It seems to me that cc @yongruilin |
It's tricky. If Removed was used to remove some fields from lhs, we won't want the |
We may need two different versions of Merge or Merge to infer the key fields from other paths. |
Right. We have multiple semantics we need to support. @andrii-korotkov-verkada would you be able to define a set of unit tests that cover the expected cases? (we don't need them to pass, we just need to declare our success criteria as clearly as possible). I suspect we can fix this either by changing when/how we include/exclude key fields, or by supplementing Merge (either with options or some other information).. |
Sure, I'll post some test cases. |
I'll show paths for lhs, rhs and merge result. Test case 1:
Test case 2:
Test case 3:
Test case 4:
Test case 5:
Test case 6:
Test case 7:
|
Just providing a bit more context that may help on taking the decision about the fix. We use the structured-merge-diff library inside Argo CD codebase to support with some of our features. One of the features is what we call ServerSideDiff. Basically we run SSA in dryrun mode and compare the result (predicted live state aka
liveRmValues := typedLive.ExtractItems(comparison.Removed)
// revert removed fields not owned by any manager
typedPredictedLive, err = typedPredictedLive.Merge(liveRmValues) @andrii-korotkov-verkada is working on a bug where the last During his investigation, he found the issue with the key field absent in the I don't exclude the fact that maybe we are misusing the library somehow but we didn't find anything too obvious. Any help is greatly appreciated. |
I have concerns with the soundness of trying to undo mutating admission via analysis of managed fields, but setting that aside for a moment.. @yongruilin has volunteered to look into the merge problem encountered here. |
IMO, first, the I propose to extend the Thoughts? |
That would work, but I wonder whether we can update Merge to look at key field values as parts of paths. |
It is the merging between 2 |
From my exploration the paths would be like
So even if
is not present, we can extract name = "nginx" from other path elements. |
Yes, the fieldPath.Set used to extract has the key field value name="nginx", but not the extracted result ( |
Ah, I see. Yeah, I guess we can go with an extra option for ExtractItems. |
/assign |
Proposed with PR: #275 |
Off topic:
@jpbetz I am also concerned with this strategy. This is a beta feature in Argo CD (disabled by default) and we are experimenting with it. |
We got the confirmation that that the patch provided by @yongruilin addresses the issue. |
/close |
@yongruilin: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Hello, I hope your day is going well.
I'm encountering the errors like
The code in question is here.
Here are examples of manifests used:
Here's an example of a part of rhs (derived from
Compare
result,Removed
field):So it doesn't have
since it's not getting removed.
But trying to merge this kind of rhs seems to depend on having that field explicitly.
If I do post-processing using the code
it works properly.
However, the values of key fields should already be available as a part of paths, so in theory Merge should just use those and don't complain about missing keys. Maybe it can already do that, just validation step complains.
Here is how we use the library. Here is the relevant ArgoCD issue.
Please, let me know what's the best course of action here and if this is something that can be addressed in Structured Merge Diff. Thank you!
Addendum: full manifests used:
Target:
Live:
Predicted live:
The text was updated successfully, but these errors were encountered: