-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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: keep array entries not found in live state #14602
fix: keep array entries not found in live state #14602
Conversation
This is probably a step in the right direction. It does fail to account for merge keys, though (e.g. in an |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #14602 +/- ##
==========================================
- Coverage 50.01% 50.00% -0.02%
==========================================
Files 266 262 -4
Lines 45971 45059 -912
==========================================
- Hits 22992 22530 -462
+ Misses 20731 20321 -410
+ Partials 2248 2208 -40
☔ View full report in Codecov by Sentry. |
There's an issue with `intersectMap` not appending items for array properties where the live array is smaller than the desired array. Hopefully fixes argoproj#9678. Signed-off-by: Blake Pettersson <[email protected]>
The following change between the live and target manifests and all changes should be present in the normalized result except the changes to `spec.replicas` and `spec.template.spec.containers[0].image` which are part of the ignore stanza. `metadata.labels` - added `appProcess: web` label `spec.replicas` - changed to 2 `spec.template.metadata.labels` - added `appProcess: web` label `spec.templatespec.containers[0].image` - Changed the image tag `spec.templatespec.containers[0].resources` - Changed from empty object to adding `requests.cpu: 400m` `spec.templatespec.containers[0]` - Added `env: [{"name": "EV", "value": "here"}] Signed-off-by: Blake Pettersson <[email protected]>
This makes the test case in 1cb1d86 pass, but this, on the other hand, makes the test case "will remove fields from target if not present in live" fail. Will need to dig in more to see if those two test cases can be reconciled. Signed-off-by: Blake Pettersson <[email protected]>
Previous test shows adding new values to the Deployment. This additional test reverses the target/live and tests removing said values. Renaming testdata to reflect the new usages Signed-off-by: Blake Pettersson <[email protected]>
This ensures that ignored fields which are not present in live do not get added to the generated patch. Signed-off-by: Blake Pettersson <[email protected]>
Signed-off-by: Blake Pettersson <[email protected]>
This merges array entries by their merge key if present. This is currently hardcoded to `name`, but could potentially be extended to allow for other merge keys if deemed necessary. This is still rough around the edges and likely to have edge cases where this won't work as intended and/or is not performant. Signed-off-by: Blake Pettersson <[email protected]>
Fixes e2e issue where `ports` (and any other array within an array) was a map instead of an array. Added a TODO as well. Signed-off-by: Blake Pettersson <[email protected]>
Signed-off-by: Blake Pettersson <[email protected]>
2c5f39e
to
fb3d3ba
Compare
@blakepettersson anything you need help with to move this to the finish line? |
The new logic looks nicely done, and I appreciate all the unit tests. But I think we might have to address the underlying issue and see if we can implement strategic merge patching instead of plain json patching in ignoreDifferences. |
@zswanson time - it's something which sadly has been sorely lacking for me lately. When digging into this locally there are edge-cases upon edge-cases which I bump into, and this is sadly not as trivial as it seems in this PR (and it's already far from trivial). The deeper I go into the rabbit hole, the more I think that this needs a rethink, and I agree with @crenshaw-dev that another approach is needed. @crenshaw-dev when you say strategic merge patching, is that the same thing as Server-Side Diff (hence potentially addressed with #13663)? |
@blakepettersson not exactly related to server-side diff. It's been a while since I've looked into this code in depth, but iirc we're generating patches using a generic JSON patch library. To handle k8s resources, we really need to use k8s libraries to generate "strategic merge patches," i.e. patches that respect resources' merge keys. |
That response is vague, and it's because I don't remember this code well enough to remember exactly how strategic merge patching would be used to solve the problem. :-P |
Hi @blakepettersson @crenshaw-dev any help needed to move this fix to completion? We also need a fix for this issue. |
Hi @saumeya @zswanson et al - due to life circumstances I haven't had the time to look at this for the past couple of months. I just changed jobs, and there's a reasonable chance that I can revisit this PR in a not too long time frame from now. Before iterating on this PR further though, I would like to see if the actual issue could be better addressed by instead making use of Server-Side Apply / Server-Side Diff. |
Closing this PR since I don't think this is a viable way to go, see comment. |
There's an issue with
intersectMap
not appending items for array properties where the live array is smaller than the desired array.Hopefully fixes #9678.
Note on DCO:
If the DCO action in the integration test fails, one or more of your commits are not signed off. Please click on the Details link next to the DCO action for instructions on how to resolve this.
Checklist:
Please see Contribution FAQs if you have questions about your pull-request.