Skip to content

Migrate from NewSimpleClientset to NewClientset #4748

Open
mboersma wants to merge 6 commits intoray-project:masterfrom
mboersma:smd-migrate-newsimpleclientset
Open

Migrate from NewSimpleClientset to NewClientset #4748
mboersma wants to merge 6 commits intoray-project:masterfrom
mboersma:smd-migrate-newsimpleclientset

Conversation

@mboersma
Copy link
Copy Markdown
Contributor

Why are these changes needed?

NewSimpleClientset is deprecated and should be replaced by NewClientset.

Related issue number

Fixes #4627
Closes #4634

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

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
@mboersma mboersma force-pushed the smd-migrate-newsimpleclientset branch from f790c1b to fa8a825 Compare April 21, 2026 22:08
Copy link
Copy Markdown
Contributor

@marosset marosset left a comment

Choose a reason for hiding this comment

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

(disregard - posted in error)

--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
"${SCRIPT_ROOT}/apis"

# Generate OpenAPI definitions for kuberay types. The output is used by
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] generate SMD schemas for all kuberay types

2 participants