Skip to content

Remove gogo from proto bindings (part 1: CRI) #128653

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 Nov 7, 2024

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

gogo protobuf is deprecated since years and we should find alternatives or work without it.

Which issue(s) this PR fixes:

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/cri-api` 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 do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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. 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 Nov 7, 2024
@k8s-ci-robot k8s-ci-robot requested review from dims and yujuhong November 7, 2024 10:08
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 7, 2024
@saschagrunert saschagrunert force-pushed the cri-gogo branch 3 times, most recently from 2410a38 to ecfff8c Compare November 7, 2024 10:26
@k8s-ci-robot k8s-ci-robot added area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Nov 7, 2024
@saschagrunert saschagrunert force-pushed the cri-gogo branch 3 times, most recently from cbc9518 to 057da0a Compare November 7, 2024 10:53
@k8s-ci-robot k8s-ci-robot added the sig/auth Categorizes an issue or PR as relevant to SIG Auth. label Nov 7, 2024
@saschagrunert saschagrunert force-pushed the cri-gogo branch 7 times, most recently from e4cf381 to cb48f0b Compare November 7, 2024 12:23
@aojea
Copy link
Member

aojea commented Nov 7, 2024

@saschagrunert the alternative has to be backwards compatible and AFAIK that is the main blocker of getting rid of gogo-protobug

/cc: @liggitt

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 28, 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 Mar 2, 2025
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 2, 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 Mar 17, 2025
@elieser1101
Copy link
Contributor

👋 Hello! @saschagrunert @liggitt
Appreciate all of your efforts with this PR/! Is the plan still to resolve it for v1.33 release?

If so, a gentle reminder that the code freeze has started 02:00 UTC Friday 21st March 2025 . Please make sure any PRs have both lgtm and approved labels ASAP, and file an Exception if you haven't done it yet.
Thanks!

@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 Mar 18, 2025
Signed-off-by: Sascha Grunert <[email protected]>
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 18, 2025
@saschagrunert
Copy link
Member Author

/retest

1 similar comment
@saschagrunert
Copy link
Member Author

/retest

@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-e2e-capz-windows-master c157f37 link false /test pull-kubernetes-e2e-capz-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.

@@ -76,17 +91,36 @@ function kube::protoc::protoc() {
)
}

# Generates $1/api.pb.go from the protobuf file $1/api.proto without using gogo
# $1: Full path to the directory where the api.proto file is
function kube::protoc::protoc() {
Copy link
Member

Choose a reason for hiding this comment

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

I think that could be a follow-up that transitions both the kube::protoc::protoc_gogo / kube::protoc::protoc function names to add ::internal:: segments ... keeping this as focused on the specific delta between gogo protoc is helpful for reviewing this PR

Copy link
Member

Choose a reason for hiding this comment

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

any chance we can avoid an entire new script that replicates everything but the kube::protoc::generate_proto_gogo call?

we wouldn't need hack/_update-generated-proto-bindings-gogo-dockerized.sh if we require telling _update-generated-proto-bindings-dockerized.sh which generator to use, like this:

diff --git a/hack/_update-generated-proto-bindings-dockerized.sh b/hack/_update-generated-proto-bindings-dockerized.sh
index 163143b1af4..127f9a240a5 100755
--- a/hack/_update-generated-proto-bindings-dockerized.sh
+++ b/hack/_update-generated-proto-bindings-dockerized.sh
@@ -26,11 +26,13 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
 source "${KUBE_ROOT}/hack/lib/protoc.sh"
 source "${KUBE_ROOT}/hack/lib/util.sh"
 
-if [ "$#" == 0 ]; then
-    echo "usage: $0 <api_dir>..."
+if (( $# < 2 )); then
+    echo "usage: $0 [gogo|protoc] <api_dir>..."
     exit 1
 fi
 
+generator=$1; shift
+
 kube::protoc::check_protoc
 
 for api; do
@@ -47,6 +49,16 @@ for api; do
 
     for file in "${protos[@]}"; do
         dir="$(dirname "${file}")"
-        kube::protoc::generate_proto "${dir}"
+        case "${generator}" in
+        gogo)
+          kube::protoc::generate_proto_gogo "${dir}"
+          ;;
+        protoc)
+          kube::protoc::generate_proto "${dir}"
+          ;;
+        *)
+          echo "Unknown generator ${generator}" >&2
+          exit 1
+        esac
     done
 done
diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh
index a653eed737b..bb8a43149d5 100755
--- a/hack/update-codegen.sh
+++ b/hack/update-codegen.sh
@@ -945,15 +945,15 @@ function codegen::protobindings() {
     done
 
     if kube::protoc::check_protoc >/dev/null; then
-      hack/_update-generated-proto-bindings-gogo-dockerized.sh "${apis_using_gogo[@]}"
-      hack/_update-generated-proto-bindings-dockerized.sh "${apis_using_protoc[@]}"
+      hack/_update-generated-proto-bindings-dockerized.sh gogo   "${apis_using_gogo[@]}"
+      hack/_update-generated-proto-bindings-dockerized.sh protoc "${apis_using_protoc[@]}"
     else
       kube::log::status "protoc ${PROTOC_VERSION} not found (can install with hack/install-protoc.sh); generating containerized..."
       # NOTE: All output from this script needs to be copied back to the calling
       # source tree.  This is managed in kube::build::copy_output in build/common.sh.
       # If the output set is changed update that function.
-      build/run.sh hack/_update-generated-proto-bindings-gogo-dockerized.sh "${apis_using_gogo[@]}"
-      build/run.sh hack/_update-generated-proto-bindings-dockerized.sh "${apis_using_protoc[@]}"
+      build/run.sh hack/_update-generated-proto-bindings-dockerized.sh gogo   "${apis_using_gogo[@]}"
+      build/run.sh hack/_update-generated-proto-bindings-dockerized.sh protoc "${apis_using_protoc[@]}"
     fi
 }

if diff := cmp.Diff(tc.want, got.SecurityContext.NamespaceOptions); diff != "" {
if diff := cmp.Diff(
tc.want,
got.SecurityContext.NamespaceOptions,
Copy link
Member

Choose a reason for hiding this comment

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

is the need for this change a sign that the generated types are changing in ways that will break consumers?

@@ -156,7 +156,9 @@ func makeFakePodSandbox(t *testing.T, m *kubeGenericRuntimeManager, template san
Ip: ip,
})
}
podSandBoxStatus.Network.AdditionalIps = additionalPodIPs
if len(additionalPodIPs) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

curious why this change was required

@@ -160,7 +160,7 @@ func (p *criStatsProvider) listPodStatsPartiallyFromCRI(ctx context.Context, upd
// fsIDtoInfo is a map from filesystem id to its stats. This will be used
// as a cache to avoid querying cAdvisor for the filesystem stats with the
// same filesystem id many times.
fsIDtoInfo := make(map[runtimeapi.FilesystemIdentifier]*cadvisorapiv2.FsInfo)
fsIDtoInfo := make(map[*runtimeapi.FilesystemIdentifier]*cadvisorapiv2.FsInfo)
Copy link
Member

Choose a reason for hiding this comment

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

old:

// FilesystemIdentifier uniquely identify the filesystem.
type FilesystemIdentifier struct {
	// Mountpoint of a filesystem.
	Mountpoint           string   `protobuf:"bytes,1,opt,name=mountpoint,proto3" json:"mountpoint,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

new:

// FilesystemIdentifier uniquely identify the filesystem.
type FilesystemIdentifier struct {
	state protoimpl.MessageState `protogen:"open.v1"`
	// Mountpoint of a filesystem.
	Mountpoint    string `protobuf:"bytes,1,opt,name=mountpoint,proto3" json:"mountpoint,omitempty"`
	unknownFields protoimpl.UnknownFields
	sizeCache     protoimpl.SizeCache
}

changing a dedupe map from a comparable struct to a pointer smells like a bug

Copy link
Member

Choose a reason for hiding this comment

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

should this switch the key to just using the Mountpoint field? will that introduce bugs in the future if this type grows new fields?

@@ -3070,8 +3072,8 @@ func TestToKubeContainerImageVolumes(t *testing.T) {
"empty volumes": {},
"multiple volumes": {
pullResults: imageVolumePulls{
volume1: imageVolumePullResult{spec: imageSpec1},
volume2: imageVolumePullResult{spec: imageSpec2},
volume1: imageVolumePullResult{spec: &imageSpec1},
Copy link
Member

Choose a reason for hiding this comment

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

similar question about why a change from struct to pointer was required, and if that represents changes in the types that will break consumers as well

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 25, 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.

@liggitt liggitt modified the milestones: v1.33, v1.34 Apr 9, 2025
@Rajalakshmi-Girish Rajalakshmi-Girish moved this from Tracked to Pending inclusion in [sig-release] Bug Triage May 21, 2025
@tico88612
Copy link
Member

Hi @saschagrunert @liggitt
This PR has not been updated for 3 months, so I'd like to check the status. If there's anything we can do, please let us know.
The code freeze is starting 02:00 UTC Friday 25th July 2025 (about 3 weeks from now). Please make sure the PR has both lgtm and approved labels before the code freeze. Thanks!

@tico88612 tico88612 moved this from Pending inclusion to Tracked in [sig-release] Bug Triage Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/apiserver area/dependency Issues or PRs related to dependency changes area/kubelet area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. 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/auth Categorizes an issue or PR as relevant to SIG Auth. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/testing Categorizes an issue or PR as relevant to SIG Testing. 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/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging.
Projects
Status: !SIG Auth
Archived in project
Status: Tracked
Development

Successfully merging this pull request may close these issues.