-
Notifications
You must be signed in to change notification settings - Fork 46
cleanup for maintaining subresource properties #4177
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
Conversation
Does the PR have any schema changes?Looking good! No breaking changes found. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4177 +/- ##
==========================================
- Coverage 58.08% 58.08% -0.01%
==========================================
Files 84 84
Lines 13535 13546 +11
==========================================
+ Hits 7862 7868 +6
- Misses 5081 5085 +4
- Partials 592 593 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
blampe
left a comment
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.
It seems reasonable but Daniel should also take a look.
All the talk of deep copying makes me nervous some other kind of mutation bug could sneak in, but I don't know enough about this.
|
This change is part of the following stack: Change managed by git-spice. |
danielrbradley
left a comment
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 a little nervous that the tests have changed in the same commit as the refactor work. Was the behavour documented by the tests incorrect or was there another reason for the test reworks?
I can't see anything obviously wrong about the refactored method - it's certainly nicer split into the smaller methods.
danielrbradley
left a comment
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.
Approved with a final cleanup of the unused propertyName struct property 👍
|
This PR has been shipped in release v3.5.1. |
This PR is a follow-up to #3040 to fix another variation of same basic problem, that the
writePropertiesToBodyfunction generates a malformed REST body. This variation happens in update cases, where theremoteStatehas existing values and thebodyParamsare empty (see test case).Note that the problem is not a 3.x regression, it repros in 2.x.
For example, given a basic NSG:
Imagine that the NSG has been deployed, and then we change the "revision" tag to force an update of the NSG.
The provider would a generate REST body containing a spurious
securityRulescontainer node, apparently due to howwritePropertiesToBodyranges over the whole property path, and how it misinterprets thepropertyNamefield.To make
writePropertiesToBodyeasier to understand and be more reliable, this PR brings in a simpler approach. For each property path, we get the value from the remote state, and if present, we set the value into the body parameters. This approach avoids prematurely creating intermediate container nodes. Note thatnestedFieldandsetNestedFieldimplementations were drawn from: https://github.com/kubernetes/apimachinery/blob/a925cd7fb3fd137a00c75870fbf7381f038993d0/pkg/apis/meta/v1/unstructured/helpers.go#L54With the fix, we see the actual
securityRulesbe maintained:Some test cases were updated to use the
propertyPathstructure correctly. Looking atfindUnsetPropertiesToMaintainthat generates thesepropertyPathstructs, thepathfield always contains the full path, andpropertyNamecontains the path element that wasn't found in the input map (which may be an intermediate node likeproperties). Also,propertyNameis not actually used anymore, is purely informational.Closes #4094