Migrate from NewSimpleClientset to NewClientset #4748
Open
mboersma wants to merge 6 commits intoray-project:masterfrom
Open
Migrate from NewSimpleClientset to NewClientset #4748mboersma wants to merge 6 commits intoray-project:masterfrom
mboersma wants to merge 6 commits intoray-project:masterfrom
Conversation
This marker tells openapi-gen to generate OpenAPI v2 definitions for all kuberay API types in the ray/v1 package. These definitions are required by applyconfiguration-gen to produce complete structured-merge-diff (SMD) type schemas, which in turn enable the use of NewClientset (the non-deprecated replacement for NewSimpleClientset). Part of ray-project#4627.
Add k8s.io/kube-openapi/cmd/openapi-gen as a tool dependency so it is available for code generation. This tool generates OpenAPI v2 type definitions from Go types annotated with +k8s:openapi-gen=true. Part of ray-project#4627.
Add cmd/modelschema utility that reads OpenAPI v2 type definitions generated by openapi-gen and serializes them to Swagger v2 JSON on stdout. The output is consumed by applyconfiguration-gen via --openapi-schema to produce complete structured-merge-diff type schemas. Update hack/update-codegen.sh to: 1. Call gen_openapi to generate OpenAPI v2 definitions for kuberay types into pkg/generated/openapi/zz_generated.openapi.go 2. Pass --applyconfig-openapi-schema to gen_client, using the output of cmd/modelschema to provide Swagger v2 JSON Pattern from sigs.k8s.io/gateway-api/cmd/modelschema and k8s.io/kubernetes/pkg/generated/openapi/cmd/models-schema. Part of ray-project#4627.
Run hack/update-codegen.sh with the new openapi-gen + modelschema pipeline. This produces: - pkg/generated/openapi/zz_generated.openapi.go (18,978 lines) OpenAPI v2 definitions for all kuberay types plus referenced apimachinery types. - pkg/client/applyconfiguration/internal/internal.go (3,291 lines) Complete structured-merge-diff type schemas, up from the previous 46-line stub that only contained __untyped_atomic_ and __untyped_deduced_ schemas. - hack/openapi-violations.report (52 entries) Baseline API rule violations report for kuberay and inherited k8s.io/api/core/v1 types. The apply configuration files are also regenerated with minor updates from the schema-aware generation pass. This enables the use of NewClientset (which requires complete SMD schemas via FieldManagedObjectTracker) as a replacement for the deprecated NewSimpleClientset. Part of ray-project#4627.
Set the namespace field in TestRayClusterCreateClusterRun options so the test correctly checks for the pre-existing RayCluster in the same namespace where it was created. Also check the error return from os.Stdout.Write in cmd/modelschema to avoid silently discarding write failures.
Replace all remaining NewSimpleClientset call sites with NewClientset, which uses the complete structured-merge-diff type schemas generated by the codegen pipeline added in earlier commits. - kubectl-plugin/pkg/cmd/scale: Ray fake client - kubectl-plugin/pkg/cmd/log: k8s fake client - apiserver/pkg/server: Ray fake client - Remove SA1019 NewSimpleClientset lint suppression from .golangci.yml - Fix update-codegen.sh process substitution for macOS compatibility - Regenerate OpenAPI definitions to sync with rebased master - Add modelschema binary to .gitignore
f790c1b to
fa8a825
Compare
marosset
reviewed
Apr 29, 2026
marosset
reviewed
Apr 29, 2026
| --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ | ||
| "${SCRIPT_ROOT}/apis" | ||
|
|
||
| # Generate OpenAPI definitions for kuberay types. The output is used by |
Contributor
There was a problem hiding this comment.
Do we have a way to catch when a PR author would need to regenerate the openpi spec?
It might be nice to add a make target to verify this add this to add a call to that in one of the CI pipelines
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.
Why are these changes needed?
NewSimpleClientsetis deprecated and should be replaced byNewClientset.Related issue number
Fixes #4627
Closes #4634
Checks