swagger-api / swagger-api/swagger-codegen

Unable to use Patch using patchNamespacedDeployment client-java-1.0.0-beta3-SNAPSHOT.jar of Kubernetes

Open
#7,944 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Patch operation fails when passing this structure as body:
static String PatchStr = "{\"spec\":{\"template\":{\"spec\":{\"containers\":[{\"name\":\"containername\",\"image\":\"xxx/xxx/xxx-xxx:3.0.1.45\"}]}}}}"; .My requirement is to update the container based on its image value.

Getting this error:
PATCH https://xx.xx.xx.xxx/apis/extensions/v1beta1/namespaces/default/deployments/xxx?pretty=false HTTP/1.1
Content-Type: application/json-patch+json; charset=utf-8
Content-Length: 124
authorization: Token xxxxxxxxxxxxxxxxxxxxxxxxxxx
Accept: application/json
User-Agent: Swagger-Codegen/1.0-SNAPSHOT/java

[{"spec":{"template":{"spec":{"containers":[{"name":"containername","image":"xxx/xxxxxxx/xxx-app:3.0.1.45"}]}}}}]
--> END PATCH (124-byte body)
<-- HTTP/1.1 500 Internal Server Error (1257ms)
Content-Type: application/json
Date: Fri, 30 Mar 2018 08:12:57 GMT
Content-Length: 117
OkHttp-Sent-Millis: 1522397577354
OkHttp-Received-Millis: 1522397577559

{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Unexpected kind: unknown","code":500}

<-- END HTTP (117-byte body)
Exception in thread "main" io.kubernetes.client.ApiException: Internal Server Error
at io.kubernetes.client.ApiClient.handleResponse(ApiClient.java:882)
at io.kubernetes.client.ApiClient.execute(ApiClient.java:798)
at io.kubernetes.client.apis.ExtensionsV1beta1Api.patchNamespacedDeploymentWithHttpInfo(ExtensionsV1beta1Api.java:5617)
at io.kubernetes.client.apis.ExtensionsV1beta1Api.patchNamespacedDeployment(ExtensionsV1beta1Api.java:5600)
at io.kubernetes.client.examples.UpdateExample.main(UpdateExample.java:76)

Swagger-codegen version
Swagger declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with UpdateExample.java at line 76, then trace the call through ExtensionsV1beta1Api.patchNamespacedDeployment and ApiClient.handleResponse. Reproduce the request using the shown patch body and inspect why the Kubernetes API returns "Unexpected kind: unknown"; done means the generated client sends a valid patch and the deployment update succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kubernetes
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.