-
Notifications
You must be signed in to change notification settings - Fork 153
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 the kubernetes manifest diff #5154
Conversation
Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com>
Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com>
Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com>
Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com>
normalize both of old and new manifests Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com>
Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com>
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. |
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
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 <6warashi9@gmail.com>
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.
🚀
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 <6warashi9@gmail.com> * Make testcase smaller Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> * Separate test cases Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> * Add test cases Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> * FIx the k8s diff normalize both of old and new manifests Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> * Rename the testcase Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> --------- Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> Signed-off-by: pipecd-bot <pipecd.dev@gmail.com>
* Add TestLoadAndDiff Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> * Make testcase smaller Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> * Separate test cases Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> * Add test cases Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> * FIx the k8s diff normalize both of old and new manifests Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> * Rename the testcase Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> --------- Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> Signed-off-by: pipecd-bot <pipecd.dev@gmail.com>
* Add note to RELEASE file (#5149) Signed-off-by: khanhtc1202 <khanhtc1202@gmail.com> Signed-off-by: pipecd-bot <pipecd.dev@gmail.com> * Fix the kubernetes manifest diff (#5154) * Add TestLoadAndDiff Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> * Make testcase smaller Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> * Separate test cases Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> * Add test cases Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> * FIx the k8s diff normalize both of old and new manifests Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> * Rename the testcase Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> --------- Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> Signed-off-by: pipecd-bot <pipecd.dev@gmail.com> * Release v0.48.7 (#5157) Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> Signed-off-by: pipecd-bot <pipecd.dev@gmail.com> --------- Signed-off-by: khanhtc1202 <khanhtc1202@gmail.com> Signed-off-by: pipecd-bot <pipecd.dev@gmail.com> Signed-off-by: Shinnosuke Sawada <6warashi9@gmail.com> Co-authored-by: Khanh Tran <32532742+khanhtc1202@users.noreply.github.com> Co-authored-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
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):