feat!: migrate protobuf codegen to protoc-gen-go and grpc-gateway v2 - #16796
Draft
Joibel wants to merge 1 commit into
Draft
feat!: migrate protobuf codegen to protoc-gen-go and grpc-gateway v2#16796Joibel wants to merge 1 commit into
Joibel wants to merge 1 commit into
Conversation
Joibel
force-pushed
the
feat/protoc-gen-go-migration
branch
4 times, most recently
from
August 24, 2026 09:27
cf698bc to
98eef1d
Compare
Replace gogo/protobuf codegen (protoc-gen-gogofast) with the official
protoc-gen-go + protoc-gen-go-grpc. Migrate grpc-gateway from v1 to v2
and replace protoc-gen-swagger with protoc-gen-openapiv2. Drop
go-grpc-middleware v1 in favor of grpc.ChainUnaryInterceptor.
BREAKING CHANGE: the /api/v1/stream/events/{namespace} stream now wraps
each event as {"type", "object"}; some OpenAPI definitions are renamed
(e.g. WorkflowCreateRequest -> CreateWorkflowBody), renaming generated
SDK classes; HTTP error bodies use google.rpc.Status. See
docs/upgrading.md.
Key changes:
- Bump k8s.io/code-generator and proto deps to v0.35.4, aligned with
go.mod's k8s.io libraries
- protoc-gen-go generates .pb.go (messages), protoc-gen-go-grpc
generates _grpc.pb.go (service stubs)
- grpc-gateway v2 runtime in argoserver.go
- New leaf package util/grpc/gateway holds the gateway glue shared by
the server and the generated pkg/apiclient code: an SSE/fields-aware
stream forwarder (reusing util/fields.Cleaner) and gateway.MessageV2Of,
which bridges gogo-generated v1alpha1 types to grpc-gateway v2's
proto.Message while preserving their encoding/json wire format
- Vendor patch (hack/vendor-patches.sh) for K8s types losing
ProtoMessage() in k8s 1.36+: changes panic to return nil in
protoMessageV2Of (anchored to that one function, fails loudly if it
no longer applies), letting aberrantLoadMessageDesc handle them; the
kubernetes_protomessage_one_more_release build tag stays exported for
builds that do not use the vendor tree
- Add `make vendor` target (go mod vendor + vendor patches) wired as
prerequisite to all proto/build/test targets
- Wrap WatchEvents RPC in EventWatchEvent (matching the *WatchEvent
naming of the other streams) and update the UI events panel for the
new shape
- HTTP request contexts carry the server logger; the gateway stream
forwarder falls back to a default logger rather than panicking from
its keepalive goroutine when one is missing
- pkg/apiclient probes at startup that Kubernetes types can be
marshalled, turning the unprotected-module-consumer panic into an
immediate, actionable error (pkg/apiclient/protocompat.go)
- HTTP round-trip test (bufconn gRPC + gateway mux + httptest, sharing
the production mux configuration) pinning unary JSON bodies, unary and
in-stream google.rpc.Status error shapes, SSE streaming/flush, the
{"result": ...} envelope, and ?fields filtering
- Update swaggify.sh for protoc-gen-openapiv2 naming conventions
- Artifact endpoints in _.primary.swagger.json moved to the
google.rpc.Status error model used everywhere else
- Migrate the nix dev env (dev/nix/flake.nix, devenv.nix) to the new
toolchain
- Renovate managers for the codegen tool pins, including the nix copies
(annotated, never automerged)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Alan Clucas <alan@clucas.org>
Claude-Session: https://claude.ai/code/session_01HDe5nzNL4WzD4CTAWZT5Et
Joibel
force-pushed
the
feat/protoc-gen-go-migration
branch
from
August 24, 2026 09:57
98eef1d to
751b632
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
make pre-commit -Bmake feature-new)Fixes #7400
Related: #16595 (Kubernetes 1.36 removes the
kubernetes_protomessage_one_more_releasebuild tag this relies on; the vendored-protobuf patch in this PR is the forward path).Motivation
gogo/protobuf is unmaintained and increasingly incompatible with the protobuf ecosystem — most immediately with Kubernetes 1.35+, which is dropping
ProtoMessage()from its generated types. This migrates thepkg/apiclientcodegen to the officially maintainedprotoc-gen-go+protoc-gen-go-grpc, and the HTTP gateway from grpc-gateway v1 (also EOL) to v2, droppinggo-grpc-middlewarev1 along the way.Modifications
protoc-gen-gogenerates.pb.go(messages),protoc-gen-go-grpcgenerates_grpc.pb.go(service stubs),protoc-gen-openapiv2replacesprotoc-gen-swagger; grpc-gateway v2 runtime in the server,grpc.ChainUnaryInterceptor/ChainStreamInterceptorreplacego-grpc-middleware.pkg/apis/workflow/v1alpha1types remain gogo-generated (they predate protoreflect). A new leaf packageutil/grpc/gatewaybridges them into grpc-gateway v2:gateway.MessageV2Of(injected into generated.pb.gw.goby the Makefile's protoc rule, with guards that fail the build if the injection stops applying) satisfies the v2proto.Messagereturn type while preserving theencoding/jsonwire format, and an SSE/?fields-aware stream forwarder (reusingutil/fields.Cleaner) replacesargoproj/pkg's grpc-gateway v1 forwarder.-tags=kubernetes_protomessage_one_more_releasefor make-driven builds, andhack/vendor-patches.sh(idempotent, anchored, fails loudly) patches vendoredgoogle.golang.org/protobuffor tag-less builds — the forward path once k8s 1.36 drops the tag.pkg/apiclientprobes at startup so unprotected module consumers get an immediate, actionable error instead of a deep runtime panic.docs/upgrading.md):WatchEventsreturns aEventWatchEvent{type, object}envelope (matching the other watch streams; the UI events panel is updated); OpenAPI request-body definitions renamed (WorkflowCreateRequest→CreateWorkflowBody, argo-events definitions toio.argoproj.events.v1alpha1.*), renaming generated SDK classes; HTTP error bodies usegoogle.rpc.Status.pkg/apis/workflow/v1alpha1island. Those types are Go-first Kubernetes CRD types, so they are still generated bygo-to-protobuf(which requiresprotoc-gen-gogoat codegen time) and still link the archived gogo runtime, pinned at v1.3.2. Full removal is gated on upstream Kubernetes shipping protoreflect-compatible types (see Update Kubernetes dependencies to 1.36 #16595) and is deliberately out of scope here.dev/nix/flake.nix,devenv.nix) is migrated to the new toolchain, and Renovate managers cover the codegen tool pins in both the Makefile and the nix files (nix bumps are never automerged since their hashes need manual updates).Verification
server/apiserver/gateway_roundtrip_test.go): real gRPC server on bufconn behind the production gateway mux configuration, pinning unary JSON bodies of gogo types (not{}), unary and in-streamgoogle.rpc.Statuserror shapes, SSE streaming/flush behaviour, the{"result": ...}envelope, event-type passthrough, and?fieldsfiltering.http.ResponseController), run clean under-race.make codegen -B,make lint,features-validate, and the unit test suite all pass; the nix packages for the new toolchain build (nix build ./dev/nix#protoc-gen-goetc.).Documentation
docs/upgrading.mdgains an "Upgrading to v4.2" section covering every API-visible change (HTTP, gRPC, and Go consumers)..features/pending/protoc-gen-go-migration.md.AGENTS.mddocuments themake vendorrequirement.AI
Code, tests, documentation, and commit message were written with Claude (Opus 4.6 and Fable 5) under human direction, including two multi-agent review passes whose findings were fixed and re-verified; all changes were human-reviewed.
🤖 Generated with Claude Code
https://claude.ai/code/session_01HDe5nzNL4WzD4CTAWZT5Et