Repair OpenAPI definition names for the identity group - #765
Open
yahyafakhroji wants to merge 1 commit into
Open
yahyafakhroji wants to merge 1 commit into
yahyafakhroji wants to merge 1 commit into
Conversation
The identity types are generated by a pinned openapi-gen (v0.23.0) that predates the Kubernetes 1.35 convention of emitting REST-friendly model names. Through 1.34 the serving layer applied that conversion itself; 1.35 moved it into the generator and turned GetDefinitionName into a pass-through, so the raw Go import path now reaches the published spec. Its slashes are JSON-Pointer escaped to "~1" inside every $ref while the definitions key keeps the literal "/", leaving all 9 intra-group references dangling. That poisons the whole /openapi/v2 document, so any client doing client-side schema validation fails on resources that have nothing to do with identity: SchemaError(go.miloapis.com/milo/pkg/apis/identity/v1alpha1.Passkey.status): unknown model in reference: "go.miloapis.com~1milo~1...~1PasskeyStatus" Passkey is only the alphabetically first casualty; ServiceAccountKey, Session and UserIdentity are equally affected. Convert slash-bearing names before handing them to the generic namer. Doing it first rather than last also lets the namer's lookup hit, which restores the x-kubernetes-group-version-kind extension the identity kinds were silently losing. Only slash-bearing names are converted: ToRESTFriendlyName is not idempotent and would otherwise mangle "io.k8s.api.core.v1.Pod" into "Pod.v1.core.api.k8s.io". This is a stopgap. The real fix is regenerating with a 1.35-era openapi-gen, which emits the same names, making that follow-up a no-op on the wire. Claude-Session: https://claude.ai/code/session_01GJXyxySyTN3vmkeFs1HMoL
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.
What
Convert slash-bearing OpenAPI definition names before handing them to the generic
namer, on both the v2 and v3 configs. Adds guard tests.
Why
The identity types are generated by a pinned
openapi-gen(v0.23.0,Taskfile.yaml:346)that predates the Kubernetes 1.35 convention of emitting REST-friendly model names, so
it emits raw Go import paths as definition keys. Through 1.34 the serving layer applied
that conversion itself; 1.35 moved it into the generator and turned
DefinitionNamer.GetDefinitionNameinto a pass-through, so the import path now reachesthe published spec verbatim.
Its slashes are JSON-Pointer escaped to
~1inside every$refwhile the definitionskey keeps the literal
/, leaving all 9 intra-group references dangling. That poisonsthe whole
/openapi/v2document, so any client doing client-side schema validationfails on resources with nothing to do with identity — this surfaced as
network-services-operator's Federated E2E failing to apply an IPAM fixture:
Passkey is only the alphabetically first casualty — all 13 identity definitions are
affected,
ServiceAccountKey,SessionandUserIdentityincluded. It has hit NSOmaintwice (32896926505,32959526255);
it only looks flaky because kubectl does not always take the client-side validation path.
Two details worth review attention:
lookup hit and restores the
x-kubernetes-group-version-kindextension the identitykinds were silently losing.
ToRESTFriendlyNameis not idempotent andwould otherwise mangle
io.k8s.api.core.v1.PodintoPod.v1.core.api.k8s.io.This is a stopgap so the shared e2e stops breaking. The real fix is regenerating with a
1.35-era
openapi-gen(now atk8s.io/kube-openapi/cmd/openapi-gen, needs+k8s:openapi-model-packageand--output-model-name-file). I trial-ran it: it producesbyte-identical names, so that follow-up is a no-op on the wire and the override can be
deleted in the same change.
Test plan
go build ./...go test ./cmd/milo/apiserver/milo-kustomizepin in NSO (config/dependencies/milo/,currently
v0.32.5) to confirm Federated E2E goes greenhttps://claude.ai/code/session_01GJXyxySyTN3vmkeFs1HMoL