java
java copied to clipboard
coreApi.readNode() method exception has no details
Describe the bug
When using the Java client API to fetch node details, the API throws a runtime exception and doesn't provide any details as to why the exception happened. i.e., return value from ex.getMessage()
is empty.
The only stack trace print is:
io.kubernetes.client.openapi.ApiException:
at io.kubernetes.client.openapi.ApiClient.handleResponse(ApiClient.java:973) ~[blob_p-3cd72cadcfba546d41cd13cdb234a4f19801cc6c-384eac9721a9464143f65d3b9a7c59fa:2.1.2]
at io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:885) ~[blob_p-3cd72cadcfba546d41cd13cdb234a4f19801cc6c-384eac9721a9464143f65d3b9a7c59fa:2.1.2]
at io.kubernetes.client.openapi.apis.CoreV1Api.readNodeWithHttpInfo(CoreV1Api.java:53351) ~[blob_p-3cd72cadcfba546d41cd13cdb234a4f19801cc6c-384eac9721a9464143f65d3b9a7c59fa:2.1.2]
at io.kubernetes.client.openapi.apis.CoreV1Api.readNode(CoreV1Api.java:53329) ~[blob_p-3cd72cadcfba546d41cd13cdb234a4f19801cc6c-384eac9721a9464143f65d3b9a7c59fa:2.1.2]
Client Version
18.0.1
Kubernetes Version
1.23
Java Version Java 8
To Reproduce Steps to reproduce the behavior: Try to fetch the AZ details of a specific node using the K8S API given the namespace and pod name:
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
String podName = System.getenv("POD_NAME");
String namespace = System.getenv("POD_NAMESPACE");
CoreV1Api coreApi = new CoreV1Api();
V1Pod pod = coreApi.readNamespacedPod(podName, namespace, null);
String nodeName = pod.getSpec().getNodeName();
V1Node node = coreApi.readNode(nodeName, null);
V1ObjectMeta metadata = node.getMetadata();
Map<String, String> labels = metadata.getLabels();
Expected behavior It should clearly show what the error is.
KubeConfig If applicable, add a KubeConfig file with secrets redacted.
Server (please complete the following information):
- OS: Linux
- Environment : EKS
- Cloud : AWS
Additional context Add any other context about the problem here.