You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The following example Java class results in an exception when run:
import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.Configuration;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import io.kubernetes.client.openapi.models.V1Container;
import io.kubernetes.client.openapi.models.V1ObjectMeta;
import io.kubernetes.client.openapi.models.V1Pod;
import io.kubernetes.client.openapi.models.V1PodSpec;
import io.kubernetes.client.util.Config;
import java.io.IOException;
import java.util.Arrays;
public class PodExample {
public static void main(String[] args) throws IOException, ApiException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
CoreV1Api api = new CoreV1Api();
api.createNamespacedPod("test-namespace",
new V1Pod().metadata(new V1ObjectMeta().name("test-pod").namespace("test-namespace"))
.spec(new V1PodSpec().addContainersItem(
new V1Container().name("test-container").image("busybox:1.28")
.command(Arrays.asList("sh", "-c", "echo \"Hello, Kubernetes\""))))).execute();
}
}
Assuming that you've created the "test-namespace" namespace, the output is:
Exception in thread "main" io.kubernetes.client.openapi.ApiException: Message:
HTTP response code: 403
HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"pods \"test-pod\" is forbidden: pod rejected: Pod Overhead set without corresponding RuntimeClass defined Overhead","reason":"Forbidden","details":{"name":"test-pod","kind":"pods"},"code":403}
HTTP response headers: {audit-id=[db4aab6c-a8c6-43c4-955d-bc49625c2548], cache-control=[no-cache, private], content-length=[272], content-type=[application/json], date=[Thu, 25 Apr 2024 19:24:02 GMT], x-kubernetes-pf-flowschema-uid=[190a5b0e-20ba-45d3-a8d8-5fdb90717772], x-kubernetes-pf-prioritylevel-uid=[655b2c69-cb8a-4115-a2b1-885c91d769a7]}
at io.kubernetes.client.openapi.ApiClient.handleResponse(ApiClient.java:1116)
at io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:1029)
at io.kubernetes.client.openapi.apis.CoreV1Api.createNamespacedPodWithHttpInfo(CoreV1Api.java:10876)
at io.kubernetes.client.openapi.apis.CoreV1Api.access$22100(CoreV1Api.java:77)
at io.kubernetes.client.openapi.apis.CoreV1Api$APIcreateNamespacedPodRequest.execute(CoreV1Api.java:10972)
at PodExample.main(PodExample.java:23)
Process finished with exit code 1
I believe the reason is that classes like V1PodSpec set non-required Map-typed fields to a new HashMap rather than leaving them as null.
We see similar unexpected behavior with Yaml.dump(). For instance, if you create a V1CustomResourceDefinition and populate a schema then Yaml.dump() will output fields like "definitions" and "dependencies" that are not legal to specify.
Client Version
e.g. 20.0.1
Kubernetes Version
e.g. 1.28.2
Java Version
e.g. Java 8
To Reproduce
Run the reproducer after creating the namespace.
Expected behavior
I'm hoping that these fields can be null by default as they were in 19.0.1.
KubeConfig
If applicable, add a KubeConfig file with secrets redacted.
Server (please complete the following information):
OS: [e.g. MacOS]
Environment [e.g. container]
Cloud [e.g. Oracle OKE]
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
rjeberhard
changed the title
Client 20.0.1 changes to non-required Map fields breaks basic use cases
Client 20.0.1 changes to non-required Map fields break basic use cases
Apr 25, 2024
Thanks, @brendandburns. I'll put my thoughts over there. I'm going to argue in favor of not treating this as a bug in the upstream server and pushing for a fix in the template generation.
Describe the bug
The following example Java class results in an exception when run:
Assuming that you've created the "test-namespace" namespace, the output is:
I believe the reason is that classes like V1PodSpec set non-required Map-typed fields to a new HashMap rather than leaving them as null.
We see similar unexpected behavior with Yaml.dump(). For instance, if you create a V1CustomResourceDefinition and populate a schema then Yaml.dump() will output fields like "definitions" and "dependencies" that are not legal to specify.
Client Version
e.g.
20.0.1
Kubernetes Version
e.g.
1.28.2
Java Version
e.g. Java 8
To Reproduce
Run the reproducer after creating the namespace.
Expected behavior
I'm hoping that these fields can be null by default as they were in 19.0.1.
KubeConfig
If applicable, add a KubeConfig file with secrets redacted.
Server (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: