Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client-go: Scale() constructor for ScaleApplyConfiguration missing WithKind, WithAPIVersion #107795

Closed
mgabeler-lee-6rs opened this issue Jan 26, 2022 · 3 comments · Fixed by #107834
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@mgabeler-lee-6rs
Copy link

What happened?

Most of the FooApplyConfiguration constructors pre-fill the Kind and APIVersion fields to make using them smooth.

But k8s.io/client-go/applyconfigurations/autoscaling/v1.Scale() is missing this, making patterns like this fail:

	_, err = deployments.ApplyScale(
		ctx, deploymentName,
		scaleV1.Scale().
			WithSpec(
				scaleV1.ScaleSpec().WithReplicas(0),
			),
		opts,
	)

Currently this code fails with (server-side) error Incorrect version specified in apply patch. Specified patch version: , expected: autoscaling/v1.

What did you expect to happen?

The Scale() constructor should set the minimum required fields for the resulting object to be usable with ApplyScale() calls, similar to how e.g. the `D

How can we reproduce it (as minimally and precisely as possible)?

  • Create a deployment (however)
  • Create a clientset, and get the Deployments client from it
  • Try to call deployments.ApplyScale using a ScaleApplyConfiguration created by the Scale() constructor

Anything else we need to know?

I can see that the presence or absence of these metadata fields is driven by some code generation, but I wasn't able to follow through to what configures that code generation. I assume it's something in the schemas somewhere, but that wasn't clear to me.

Kubernetes version

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.2", GitCommit:"9d142434e3af351a628bffee3939e64c681afa4d", GitTreeState:"clean", BuildDate:"2022-01-19T17:35:46Z", GoVersion:"go1.17.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.1", GitCommit:"86ec240af8cbd1b60bcc4c03c20da9b98005b92e", GitTreeState:"clean", BuildDate:"2021-12-16T11:34:54Z", GoVersion:"go1.17.5", Compiler:"gc", Platform:"linux/amd64"}

Cloud provider

minikube v1.25.1

OS version

N/A

Install tools

N/A

Container runtime (CRI) and and version (if applicable)

N/A

Related plugins (CNI, CSI, ...) and versions (if applicable)

N/A

@mgabeler-lee-6rs mgabeler-lee-6rs added the kind/bug Categorizes issue or PR as related to a bug. label Jan 26, 2022
@k8s-ci-robot k8s-ci-robot added needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jan 26, 2022
@mgabeler-lee-6rs
Copy link
Author

/sig api-machinery

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 26, 2022
@fedebongio
Copy link
Contributor

/assign @jpbetz
/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jan 27, 2022
@jpbetz
Copy link
Contributor

jpbetz commented Feb 7, 2022

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
4 participants