-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Convert k8s.io/kubelet/pkg/apis/dra
from gogo to protoc
#133026
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
base: master
Are you sure you want to change the base?
Conversation
/retest |
/retest |
New changes are detected. LGTM label has been removed. |
0797f74
to
062d44a
Compare
out.state = in.state | ||
out.Namespace = in.Namespace | ||
out.UID = in.UID | ||
out.Uid = in.Uid | ||
out.Name = in.Name | ||
out.XXX_NoUnkeyedLiteral = in.XXX_NoUnkeyedLiteral | ||
out.XXX_sizecache = in.XXX_sizecache | ||
out.unknownFields = *(*[]byte)(unsafe.Pointer(&in.unknownFields)) | ||
out.sizeCache = in.sizeCache |
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.
@liggitt is there a way to avoid converting the internal types? This will lead into build failures, we may also wanna consider a different type of conversion here.
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 missed this question... did you get this resolved?
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.
Not by using conversion-gen
, which may require a feature for that. I switched to manually maintain the conversion for now in staging/src/k8s.io/kubelet/pkg/apis/dra/v1beta1/conversion_internal.go
.
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.
@pohly I don't really understand what is going on with this file ... this is trying to do version-to-version conversion between grpc proto types, not REST API types? Is there fuzzed round-trip testing done to make sure these convert with fidelity and aren't missing any fields?
If we do end up sticking with a hand-written conversion like this, as a general comment, use of unsafe.Pointer
in a non-generated conversion file is super fragile, the generator has checks to make sure the in/out is memory-identical before using this.
Separately, I realized there's nothing requiring changes under kubelet/pkg/apis to go through API review, which is disconcerting, any general kubelet approver can accidentally approve API changes (fixed in #133275)
/hold
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.
one possibility is to improve conversion-gen to stop trying to set these unexported fields, so we can mostly lean on the generation bits for memory equality testing and mechanical field copying
POC in https://github.com/liggitt/kubernetes/commits/dra-proto/
that led down a rabbit trail:
- teaching conversion-gen it can't be sure about converting a field means it will generate the autoConvert_... function with warnings, but not the final Convert_... function
- because in this case we're fine with ignoring the unexported bookkeeping proto fields, I just copied the Convert_ implementations that delegate to autoConvert_... as-is
- once I did that, conversion-gen couldn't find/use custom
Convert_
functions for maps and slices to pointers, so I fixed that as well
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.
Awesome! I was also thinking about the overall approach of skipping unexported fields in conversion-gen and would prefer that route.
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.
updated https://github.com/liggitt/kubernetes/commits/dra-proto/ with conversion-gen tests, opened #133325 containing just the conversion-gen bits as a prereq PR
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.
Do you want this to be merged in 1.34?
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.
No, it can wait for 1.35
hack/_update-generated-proto-bindings-dockerized.sh protoc "${apis_using_protoc[@]}" | ||
hack/_update-generated-proto-bindings-dockerized.sh protoc "${apis[@]}" |
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'll follow-up on the script part in a separate PR.
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.
follow-up is good, if we don't have any gogo proto bindings now, let's delete all the gogo logic from that path completely (drop the generator
arg check, delete generate_proto_gogo
, etc)
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.
Ref: #133271
8121c70
to
a3368ee
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dims, saschagrunert, SergeyKanzhelev 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 |
Use standard protoc for the dra instead of gogo. Part of kubernetes#96564 Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
cc @pohly |
@saschagrunert: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
/skip |
@@ -1020,10 +1020,8 @@ function codegen::protobindings() { | |||
|
|||
# Each element of this array is a directory containing subdirectories which | |||
# eventually contain a file named "api.proto". | |||
local apis_using_gogo=( | |||
local apis=( |
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.
can we discover those instead of listing explicitly?
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.
(separate PR, not blocking this one)
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.
are you asking if we can automatically distinguish which api.proto files are using gogo and which are using standard protoc, or if we can discover all api.proto files anywhere in the tree?
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.
second. We switched to protoc everywhere. Now instead of listing APIs maybe we can discover them in the tree
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.
yeah, it's possible, can look into doing that as a follow-up
I assume having this part of the v1.34 release would be beneficial considering that the API is now v1. |
I asked today: https://kubernetes.slack.com/archives/C0409NGC1TK/p1753728775739929 |
/triage accepted |
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Use standard protoc for the dra instead of gogo.
Which issue(s) this PR is related to:
Part of #96564
Special notes for your reviewer:
None
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: