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

Empty kube config(root/.kube/config) file cause NPE #5221

Closed
tinystorm opened this issue Jun 8, 2023 · 0 comments · Fixed by #5283
Closed

Empty kube config(root/.kube/config) file cause NPE #5221

tinystorm opened this issue Jun 8, 2023 · 0 comments · Fixed by #5283
Assignees
Labels
Milestone

Comments

@tinystorm
Copy link

tinystorm commented Jun 8, 2023

Describe the bug

When I haven't manually disabled AutoConfig and there is an empty kubeconfig file present in the system, it leads to a NullPointerException in the loadFromKubeConfig method.

Fabric8 Kubernetes Client version

other (please specify in additional context)

Steps to reproduce

1 echo '' > root/.kube/config
2 new ConfigBuilder()
3 will get a NPE

Expected behavior

no NPE

Runtime

Kubernetes (vanilla)

Kubernetes API Server version

1.25.3@latest

Environment

Linux

Fabric8 Kubernetes Client Logs

`Caused by: java.lang.NullPointerException
	at io.fabric8.kubernetes.client.Config.loadFromKubeconfig(Config.java:703)
	at io.fabric8.kubernetes.client.Config.tryKubeConfig(Config.java:666)
	at io.fabric8.kubernetes.client.Config.autoConfigure(Config.java:286)
	at io.fabric8.kubernetes.client.Config.<init>(Config.java:251)
	at io.fabric8.kubernetes.client.Config.<init>(Config.java:242)
	at io.fabric8.kubernetes.client.ConfigBuilder.<init>(ConfigBuilder.java:10)
	at io.fabric8.kubernetes.client.ConfigBuilder.<init>(ConfigBuilder.java:7)
	at `

Additional context

version is 6.6.0
Based on the following code, it seems that you are consciously trying to prevent empty kubeconfig files. However, you are currently only checking for null and not checking for an empty string "".
if (kubeconfigContents == null) { return false; }

@manusa manusa added the bug label Jun 13, 2023
@rohanKanojia rohanKanojia self-assigned this Jun 26, 2023
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Jun 26, 2023
…empty before deserialization (fabric8io#5221)

Rather than directly deserializing `.kube/config` file content in `io.fabric8.kubernetes.api.model.Config`, do it only when
`.kube/config` file content is non blank.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Jun 26, 2023
…empty before deserialization (fabric8io#5221)

Rather than directly deserializing `.kube/config` file content in `io.fabric8.kubernetes.api.model.Config`, do it only when
`.kube/config` file content is non blank.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
manusa pushed a commit to rohanKanojia/kubernetes-client that referenced this issue Jul 5, 2023
…empty before deserialization (fabric8io#5221)

Rather than directly deserializing `.kube/config` file content in `io.fabric8.kubernetes.api.model.Config`, do it only when
`.kube/config` file content is non blank.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@manusa manusa added this to the 6.8.0 milestone Jul 5, 2023
manusa pushed a commit that referenced this issue Jul 6, 2023
…empty before deserialization (#5221)

Rather than directly deserializing `.kube/config` file content in `io.fabric8.kubernetes.api.model.Config`, do it only when
`.kube/config` file content is non blank.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
dongjoon-hyun pushed a commit to apache/spark that referenced this issue Jul 26, 2023
### What changes were proposed in this pull request?
The pr aims to upgrade kubernetes-client from 6.7.2 to 6.8.0.

### Why are the changes needed?
- The newest version brings some bug fixed & improvment, eg:
Fix fabric8io/kubernetes-client#5221: Empty kube config file causes NPE
Fix fabric8io/kubernetes-client#5281: Ensure the KubernetesCrudDispatcher's backing map is accessed w/lock
Fix fabric8io/kubernetes-client#5298: Prevent requests needing authentication from causing a 403 response
Fix fabric8io/kubernetes-client#5233: Generalized SchemaSwap to allow for cycle expansion
Fix fabric8io/kubernetes-client#5262: all built-in collections will omit empty in their serialized form.

- The full release notes:
https://github.com/fabric8io/kubernetes-client/releases/

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
Pass GA.

Closes #42142 from panbingkun/SPARK-44537.

Authored-by: panbingkun <pbk1982@gmail.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
ragnarok56 pushed a commit to ragnarok56/spark that referenced this issue Mar 2, 2024
### What changes were proposed in this pull request?
The pr aims to upgrade kubernetes-client from 6.7.2 to 6.8.0.

### Why are the changes needed?
- The newest version brings some bug fixed & improvment, eg:
Fix fabric8io/kubernetes-client#5221: Empty kube config file causes NPE
Fix fabric8io/kubernetes-client#5281: Ensure the KubernetesCrudDispatcher's backing map is accessed w/lock
Fix fabric8io/kubernetes-client#5298: Prevent requests needing authentication from causing a 403 response
Fix fabric8io/kubernetes-client#5233: Generalized SchemaSwap to allow for cycle expansion
Fix fabric8io/kubernetes-client#5262: all built-in collections will omit empty in their serialized form.

- The full release notes:
https://github.com/fabric8io/kubernetes-client/releases/

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
Pass GA.

Closes apache#42142 from panbingkun/SPARK-44537.

Authored-by: panbingkun <pbk1982@gmail.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment