mirror of
https://github.com/cozystack/cozystack.git
synced 2026-10-28 23:57:08 +09:00
The aggregated apiserver publishes the core.cozystack.io and sdn.cozystack.io models under their Go import path, so a $ref to any of them does not resolve and client-side validation fails on every resource of those groups, not only the one named in the error: error validating data: SchemaError(…core/v1alpha1.Option.spec): unknown model in reference: "github.com~1cozystack~1…v1alpha1.OptionSpec" Since Kubernetes 0.35 the apiserver's DefinitionNamer.GetDefinitionName returns the model name it is handed verbatim; it no longer converts the Go import-path form into the "friendly" reversed-path form. Whatever name the generated openapi map uses therefore becomes both the published definition key and, JSON pointer escaped, the $ref pointing at it. A name containing "/" ships as a definition keyed on the raw path while every reference to it spells each slash "~1", and clients resolve a $ref by trimming "#/definitions/" without unescaping (kube-openapi pkg/util/proto/document.go). The two spellings never meet, the reference dangles, and validation of the whole document fails. Mirrorb916d7475, which fixed the same disagreement for apps: add the +k8s:openapi-model-package marker to each doc.go and declare OpenAPIModelName for all 11 core and 9 sdn types, so GetCanonicalTypeName, Scheme.ToOpenAPIDefinitionName and the generated map key all agree on a slash-free dotted name. That takes the number of slash-bearing definition names in the published document from 20 to 0. The methods are hand-written rather than emitted by openapi-gen's --output-model-name-file because that flag also rewrites zz_generated.model_name.go inside the read-only apimachinery and apiextensions module-cache packages the shared gen_openapi helper always passes as inputs, which fails on any consumer including CI that vendors deps from the cache. With the marker in place openapi-gen emits Type{}.OpenAPIModelName() for every type it references, so a future type without a method fails the build instead of silently reintroducing a Go-path name. The generated openapi is the output of the root `make generate`; nothing else in the generated tree moved. kubectl apply --validate has been broken against any cozystack-api built after 2026-07-21 on every resource, and this shipped in v1.6.0 and v1.6.1. In e2e it surfaces as the platform install hanging on cozy-backup-controller/backupstrategy-controller, which takes tenant-root and everything behind cozystack-basics with it. Refs: https://github.com/cozystack/cozystack/issues/3806 Assisted-By: Claude <noreply@anthropic.com> Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com> (cherry picked from commit5f3ad9cd58)