Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

saschagrunert
Copy link
Member

@saschagrunert saschagrunert commented Jul 17, 2025

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?

Removed deprecated gogo protocol definitions from `k8s.io/kubelet/pkg/apis/dra` in favor of `google.golang.org/protobuf`.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

None

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jul 17, 2025
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. wg/device-management Categorizes an issue or PR as relevant to WG Device Management. labels Jul 17, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Jul 17, 2025
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jul 17, 2025
@k8s-ci-robot k8s-ci-robot added the area/dependency Issues or PRs related to dependency changes label Jul 17, 2025
@saschagrunert
Copy link
Member Author

/retest

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 19, 2025
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 21, 2025
@saschagrunert
Copy link
Member Author

/retest

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 22, 2025
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 23, 2025
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 25, 2025
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot added area/code-generation sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 25, 2025
@saschagrunert saschagrunert force-pushed the dra-proto branch 2 times, most recently from 0797f74 to 062d44a Compare July 25, 2025 08:03
Comment on lines 133 to 138
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
Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

@liggitt liggitt Jul 29, 2025

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

Copy link
Member

@liggitt liggitt Jul 29, 2025

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

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member

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?

Copy link
Member

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

Comment on lines -1054 to +1050
hack/_update-generated-proto-bindings-dockerized.sh protoc "${apis_using_protoc[@]}"
hack/_update-generated-proto-bindings-dockerized.sh protoc "${apis[@]}"
Copy link
Member Author

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.

Copy link
Member

@liggitt liggitt Jul 28, 2025

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)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ref: #133271

@saschagrunert saschagrunert force-pushed the dra-proto branch 2 times, most recently from 8121c70 to a3368ee Compare July 28, 2025 07:59
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Use standard protoc for the dra instead of gogo.

Part of kubernetes#96564

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
@saschagrunert
Copy link
Member Author

cc @pohly

@k8s-ci-robot
Copy link
Contributor

@saschagrunert: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-unit-windows-master 58c7e1a link false /test pull-kubernetes-unit-windows-master

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.

@saschagrunert
Copy link
Member Author

/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=(
Copy link
Member

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?

Copy link
Member

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)

Copy link
Member

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?

Copy link
Member

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

Copy link
Member

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

@saschagrunert
Copy link
Member Author

saschagrunert commented Jul 29, 2025

I assume having this part of the v1.34 release would be beneficial considering that the API is now v1.

@SergeyKanzhelev
Copy link
Member

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

@liggitt liggitt added this to the v1.35 milestone Jul 29, 2025
@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 29, 2025
@BenTheElder
Copy link
Member

/triage accepted
needs-rebase

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jul 29, 2025
@k8s-ci-robot
Copy link
Contributor

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.

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. area/code-generation area/dependency Issues or PRs related to dependency changes area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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. sig/node Categorizes an issue or PR as relevant to SIG Node. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on. wg/device-management Categorizes an issue or PR as relevant to WG Device Management.
Development

Successfully merging this pull request may close these issues.

6 participants