Skip to content
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 proto.Merge of IntOrString type #83956

Merged
merged 1 commit into from
Oct 16, 2019

Conversation

liggitt
Copy link
Member

@liggitt liggitt commented Oct 15, 2019

What type of PR is this?
/kind bug

What this PR does / why we need it:
The unsized int in the IntOrString type breaks proto.Merge. The proto serialization was already using int64, and json serialization used custom marshaling, so this doesn't change serialization at all.

Which issue(s) this PR fixes:
Fixes #83912

Does this PR introduce a user-facing change?:

Switched intstr.Type to sized integer to follow API guidelines and improve compatibility with proto libraries

/sig api-machinery
/cc @smarterclayton

@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Oct 15, 2019
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 15, 2019
@liggitt
Copy link
Member Author

liggitt commented Oct 15, 2019

https://prow.k8s.io/view/gcs/kubernetes-jenkins/pr-logs/pull/83956/pull-kubernetes-e2e-kind/1184127598125387777

ERROR: failed to create cluster: failed to init node with kubeadm: command "docker exec --privileged kind-control-plane kubeadm init --ignore-preflight-errors=all --config=/kind/kubeadm.conf --skip-token-print --v=6" failed with error: signal: broken pipe

cc @BenTheElder

/retest

Copy link
Contributor

@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@BenTheElder
Copy link
Member

BenTheElder commented Oct 15, 2019

@liggitt thanks - this is kubernetes-sigs/kind#949, it's happening very rarely and I've not been able to replicate it in a controlled environment yet, seems like possibly a docker issue :(

https://prow.k8s.io/?job=pull-kubernetes-e2e-kind - 93% / 92% / 79 % passing for the past 3 / 12 / 48 hours, the failing runs are generally bad commits (EG code that doesn't compile).

func TestIntstr(t *testing.T) {
x := FromString("1")
y := FromString("2")
proto.Merge(&x, &y)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we generally support proto.Merge? What are people using this for? What is the result of this operation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using proto.Clone which seems to call proto.Merge at some point in the call tree

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using that rather than the DeepCopy functions we generate? (assuming it does the same thing?)

@lavalamp
Copy link
Member

I don't object to this change, but I am not at all sure I want to sign up for promising that proto.Merge works on all of our objects; we don't test it AFAIK, I have no idea if it does the right thing.

@liggitt
Copy link
Member Author

liggitt commented Oct 15, 2019

I am not at all sure I want to sign up for promising that proto.Merge works on all of our objects

agree, I care more about this because all serialized primitive fields should be sized (even though practically this field value would only be 0 or 1 and the size wouldn't affect serialization). the fact that it fixes a serialization-related panic is a bonus.

@lavalamp
Copy link
Member

But... Type is not serialized?

@liggitt
Copy link
Member Author

liggitt commented Oct 15, 2019

But... Type is not serialized?

It is in proto.

i = encodeVarintGenerated(dAtA, i, uint64(m.Type))

case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
}
m.Type = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenerated
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Type |= Type(b&0x7F) << shift
if b < 0x80 {
break
}
}

@lavalamp
Copy link
Member

ew. hm. OK.

Is there a way to test this that won't imply to people that we expect proto.Merge to function everywhere?

@liggitt
Copy link
Member Author

liggitt commented Oct 15, 2019

Is there a way to test this that won't imply to people that we expect proto.Merge to function everywhere?

other than dropping the proto.Merge test or adding a comment to that effect, not that I can think of... preference?

@lavalamp
Copy link
Member

lavalamp commented Oct 15, 2019 via email

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 15, 2019
@liggitt
Copy link
Member Author

liggitt commented Oct 15, 2019

dropped the proto.Merge test

@liggitt
Copy link
Member Author

liggitt commented Oct 15, 2019

/priority backlog

@k8s-ci-robot k8s-ci-robot added priority/backlog Higher priority than priority/awaiting-more-evidence. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Oct 15, 2019
@lavalamp
Copy link
Member

/lgtm
/approve

(I can't believe I asked you to remove a test, sigh... ;) )

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 15, 2019
@liggitt
Copy link
Member Author

liggitt commented Oct 15, 2019

I can't believe I asked you to remove a test, sigh... ;)

I know... where is Daniel and what have you done with him?

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lavalamp, liggitt

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot k8s-ci-robot merged commit 554412c into kubernetes:master Oct 16, 2019
@k8s-ci-robot k8s-ci-robot added this to the v1.17 milestone Oct 16, 2019
@liggitt liggitt deleted the intstr-type branch October 17, 2019 12:21
k8s-ci-robot added a commit that referenced this pull request Oct 28, 2019
…6-upstream-release-1.16

Automated cherry pick of #83956: Fix proto.Merge of IntOrString type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

proto.Merge broken on intstr in Kubernetes 1.16 apimachinary
6 participants