kubernetes-client / kubernetes-client/java
It's not possible to create a Pod, because of the default overhead value (empty map) in v20.0.0
- Langage dominant
- Java
- Étoiles
- 4k
- Forks
- 2.1k
- Merge moyen
- 2 j 9 h
- PR mergées (30 j)
- 16
Description
**Describe the bug**
The default `overhead` value of Pod spec in version 20.0.0 is empty map which is causing the following error:
```java
java.lang.RuntimeException: io.kubernetes.client.openapi.ApiException: Message:
HTTP response code: 403
HTTP response body: {"kind":"Status","apiVersion":"((redacted))","metadata":{},"status":"Failure","message":"pods \"foo\" is forbidden: pod rejected: Pod Overhead set without corresponding RuntimeClass defined Overhead","reason":"Forbidden","details":{"name":"foo","kind":"pods"},"code":403}
```
As a workaround, one can set the `overhead` explicitly to null:
```java
V1Pod pod = new V1Pod()
.metadata(new V1ObjectMeta().name("foo"))
.spec(new V1PodSpec()
.overhead(null) // HERE: setting the overhead value to null, to avoid above error.
.addContainersItem(new V1ContainerBuilder()
// omitted
```
**Client Version**
e.g. `20.0.0`
**Kubernetes Version**
any version
**Java Version**
any version
**To Reproduce**
Create a simple Pod, without specifying anything for `overhead`:
```java
V1Pod pod = new V1Pod()
.metadata(new V1ObjectMeta().name("foo"))
.spec(new V1PodSpec()
.addContainersItem(new V1ContainerBuilder()
.withImage("any-image")
.withName("foo-image").build()));
coreV1Api.createNamespacedPod("default", pod).execute();
```
**Expected behavior**
Pod creation should be successful but it fails due to `overhead: {}` being present in the request payload.
I think, either the default value of `overhead` should be `null` or when serialising the request, the empty values should be omitted.
**KubeConfig**
N/A
**Server (please complete the following information):**
Any
**Additional context**
N/A
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par V1PodSpec et le chemin de requête utilisé par CoreV1Api.createNamespacedPod ; reproduisez l’exemple et examinez comment un overhead non défini est sérialisé. Comparez la payload générée avec la requête attendue, puis vérifiez que la création d’un Pod sans spécifier overhead n’envoie plus de map vide et réussit.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- java, kubernetes
- Domaine
- api, backend
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- Calme
- Clarté
- Plutôt claire
- Accessibilité débutants
- 48/100