-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Describe the bug
In the GenericKubernetesApi.java
file, the private method makeClusterCreateCallBuilder
incorrectly builds the API call for creating a cluster-scoped resource.
It mistakenly calls the .dryRun()
method twice, with the second call incorrectly passing the fieldManager
value from CreateOptions
. This overwrites the actual dryRun
value and fails to set the fieldManager
parameter.
Here is the problematic code snippet:
// in /util/src/main/java/io/kubernetes/client/util/generic/GenericKubernetesApi.java
private CallBuilder makeClusterCreateCallBuilder(
ApiType object, final CreateOptions createOptions) {
return () ->
customObjectsApi.createClusterCustomObject(
this.apiGroup,
this.apiVersion,
this.resourcePlural,
object)
.dryRun(createOptions.getDryRun())
.dryRun(createOptions.getFieldManager())
.buildCall(null);
}
The second .dryRun() call should be .fieldManager().
Client Version
e.g. 24.0.0
Kubernetes Version
e.g. 1.30.13
Java Version
e.g. Java 21
To Reproduce
Steps to reproduce the behavior:
- Instantiate
GenericKubernetesApi
for a cluster-scoped custom resource. - Create an instance of
CreateOptions
with a specificfieldManager
value (e.g., "my-app-controller
"). - Call the
api.create(customObject, createOptions)
method. - Observe the HTTP request sent to the Kubernetes API server.
- You will see that the request includes a
dryRun=my-app-controller
parameter, and thefieldManager
parameter is missing.
Expected behavior
The API call builder should correctly map the options. The dryRun
value from CreateOptions
should be used for the dryRun
parameter, and the fieldManager
value should be used for the fieldManager
parameter.
Server (please complete the following information):
- OS: MacOS 15.2
- Environment : Docker Desktop & IDE
Additional context
Add any other context about the problem here.