-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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 mergepatch.HasConflicts(). #43469
Conversation
/assign @caesarxuchao |
/assign @mengqiy |
@@ -17,6 +17,8 @@ limitations under the License. | |||
package mergepatch | |||
|
|||
import ( | |||
"bytes" | |||
"encoding/json" |
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.
Should use "apimachinery/pkg/util/json"
Using this json pkg can avoid some number conversion issue.
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.
Done.
@enisoc Can you give me an example? |
There are some examples in the unit test. |
I think this WAI. I think the reason why same numeric value with different types are passed to |
I encountered the numeric value issue in the form of this error when attempting to PATCH:
If you're saying that should be fixed at a different layer, that makes sense. I will revert the numeric part of this change. |
This error message is interesting. |
This fixes some false negatives: * If a map had multiple entries, only the first was checked. * If a list had multiple entries, only the first was checked.
In staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest.go, |
Can you try to switch the json pkg in that file to see if it help your numeric value issue? |
@mengqiy Yup you're right. I will send a separate PR to fix that. Can you review this one for the other fixes? |
/lgtm |
@caesarxuchao Your turn for approval. |
Do we need to cherrypick this to 1.6? |
Automatic merge from submit-queue PATCH: Fix erroneous meaningful conflict for numeric values. The wrong json package was used, resulting in patches being unmarshaled with numbers as float64 rather than int64. This in turn confused `HasConflicts()` which expects numeric types to match. The end result was false positives of meaningful conflicts, such as: ``` there is a meaningful conflict (firstResourceVersion: "8517", currentResourceVersion: "8519"): diff1={"metadata":{"resourceVersion":"8519"},"spec":{"replicas":0},"status":"conditions":null,"fullyLabeledReplicas":null,"replicas":0}} , diff2={"spec":{"replicas":0}} ``` This is branched from a discussion on #43469. ```release-note Fix false positive "meaningful conflict" detection for strategic merge patch with integer values. ```
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: caesarxuchao, enisoc, mengqiy
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
Automatic merge from submit-queue |
What this PR does / why we need it:
This fixes some false negatives:
Which issue this PR fixes:
Special notes for your reviewer:
Release note: