-
Notifications
You must be signed in to change notification settings - Fork 204
Fix the kubernetes manifest diff #5154
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
Signed-off-by: Shinnosuke Sawada <[email protected]>
Signed-off-by: Shinnosuke Sawada <[email protected]>
Signed-off-by: Shinnosuke Sawada <[email protected]>
Signed-off-by: Shinnosuke Sawada <[email protected]>
normalize both of old and new manifests Signed-off-by: Shinnosuke Sawada <[email protected]>
Signed-off-by: Shinnosuke Sawada <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5154 +/- ##
==========================================
+ Coverage 22.79% 22.82% +0.02%
==========================================
Files 412 412
Lines 43827 43833 +6
==========================================
+ Hits 9992 10003 +11
+ Misses 33047 33040 -7
- Partials 788 790 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ffjlabo
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.
Thank you! This is the nice improvement!
I left nit comments.
| for _, change := range result.Changes { | ||
| t.Log(change.Old.Key, change.New.Key) | ||
| for _, node := range change.Diff.Nodes() { | ||
| t.Log(node.PathString) | ||
| t.Log(node.ValueX) | ||
| t.Log(node.ValueY) | ||
| t.Log("---") | ||
| } | ||
| } | ||
| for _, add := range result.Adds { | ||
| t.Log(add.Key) | ||
| } | ||
| for _, delete := range result.Deletes { | ||
| t.Log(delete.Key) | ||
| } |
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.
[ask] This codes are for checking the diff when result.NoChange() is false?
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.
Yes, and these are logs for debugging, not assertions.
|
|
||
| normalizedOld, err := remarshal(old.u) | ||
| if err != nil { | ||
| logger.Info("compare manifests directly since it was unable to remarshal Kubernetes manifest to normalize special fields", zap.Error(err)) |
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.
[nit] It would be nice to show old or new when investigating with this log.
It is the same for the remarshal new one.
| logger.Info("compare manifests directly since it was unable to remarshal Kubernetes manifest to normalize special fields", zap.Error(err)) | |
| logger.Info("compare manifests directly since it was unable to remarshal old Kubernetes manifest to normalize special fields", zap.Error(err)) |
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.
Fixed by this commit
ead1e14
khanhtc1202
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.
Nice catch, thank you 👍
Signed-off-by: Shinnosuke Sawada <[email protected]>
ffjlabo
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.
🚀
khanhtc1202
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.
ready to go 🚀
* Add TestLoadAndDiff Signed-off-by: Shinnosuke Sawada <[email protected]> * Make testcase smaller Signed-off-by: Shinnosuke Sawada <[email protected]> * Separate test cases Signed-off-by: Shinnosuke Sawada <[email protected]> * Add test cases Signed-off-by: Shinnosuke Sawada <[email protected]> * FIx the k8s diff normalize both of old and new manifests Signed-off-by: Shinnosuke Sawada <[email protected]> * Rename the testcase Signed-off-by: Shinnosuke Sawada <[email protected]> --------- Signed-off-by: Shinnosuke Sawada <[email protected]> Signed-off-by: pipecd-bot <[email protected]>
* Add TestLoadAndDiff Signed-off-by: Shinnosuke Sawada <[email protected]> * Make testcase smaller Signed-off-by: Shinnosuke Sawada <[email protected]> * Separate test cases Signed-off-by: Shinnosuke Sawada <[email protected]> * Add test cases Signed-off-by: Shinnosuke Sawada <[email protected]> * FIx the k8s diff normalize both of old and new manifests Signed-off-by: Shinnosuke Sawada <[email protected]> * Rename the testcase Signed-off-by: Shinnosuke Sawada <[email protected]> --------- Signed-off-by: Shinnosuke Sawada <[email protected]> Signed-off-by: pipecd-bot <[email protected]>
* Add note to RELEASE file (#5149) Signed-off-by: khanhtc1202 <[email protected]> Signed-off-by: pipecd-bot <[email protected]> * Fix the kubernetes manifest diff (#5154) * Add TestLoadAndDiff Signed-off-by: Shinnosuke Sawada <[email protected]> * Make testcase smaller Signed-off-by: Shinnosuke Sawada <[email protected]> * Separate test cases Signed-off-by: Shinnosuke Sawada <[email protected]> * Add test cases Signed-off-by: Shinnosuke Sawada <[email protected]> * FIx the k8s diff normalize both of old and new manifests Signed-off-by: Shinnosuke Sawada <[email protected]> * Rename the testcase Signed-off-by: Shinnosuke Sawada <[email protected]> --------- Signed-off-by: Shinnosuke Sawada <[email protected]> Signed-off-by: pipecd-bot <[email protected]> * Release v0.48.7 (#5157) Signed-off-by: Shinnosuke Sawada <[email protected]> Signed-off-by: pipecd-bot <[email protected]> --------- Signed-off-by: khanhtc1202 <[email protected]> Signed-off-by: pipecd-bot <[email protected]> Signed-off-by: Shinnosuke Sawada <[email protected]> Co-authored-by: Khanh Tran <[email protected]> Co-authored-by: Shinnosuke Sawada-Dazai <[email protected]>
What this PR does / why we need it:
Normalize both old and new manifests when calculating diff.
Without this PR, the unexpected difference is calculated when resource/limit numbers have floating-point values such as
cpu: "1.5"The diff signs 1.5 and 1500m are different.
This occurs because the new manifests are normalized, but the old ones are not.
Which issue(s) this PR fixes:
N/A
Does this PR introduce a user-facing change?: Yes
How are users affected by this change:
Users can get the correct plan-preview diffs.
Some deployments triggered by incorrect diffs become not triggered.
Is this breaking change:
How to migrate (if breaking change):