Skip to content

wrong behavior with patch custom object #157

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

Closed
caffeinism opened this issue Sep 3, 2021 · 1 comment
Closed

wrong behavior with patch custom object #157

caffeinism opened this issue Sep 3, 2021 · 1 comment

Comments

@caffeinism
Copy link

kubernetes version: 1.18.5
kubernetes_asyncio version: lastest

in kubernetes_asyncio

    async with ApiClient() as api_client:
        custom_object = CustomObjectsApi(api_client)
        return await custom_object.patch_namespaced_custom_object(
            group=API_GROUP,
            version=VERSION,
            plural=RESOURCE,
            name=name,
            namespace=namespace,
            body=patch,
        )

in kubernetes official python library

    with ApiClient() as api_client:
        custom_object = CustomObjectsApi(api_client)
        return custom_object.patch_namespaced_custom_object(
            group=API_GROUP,
            version=VERSION,
            plural=RESOURCE,
            name=name,
            namespace=namespace,
            body=patch,
        )

expect the same behavior, but get an error on kubernetes_asyncio.

error

  File "/opt/conda/lib/python3.8/site-packages/kubernetes_asyncio/client/api_client.py", line 189, in __call_api
    raise e
  File "/opt/conda/lib/python3.8/site-packages/kubernetes_asyncio/client/api_client.py", line 182, in __call_api
    response_data = await self.request(
  File "/opt/conda/lib/python3.8/site-packages/kubernetes_asyncio/client/rest.py", line 258, in PATCH
    return (await self.request("PATCH", url,
  File "/opt/conda/lib/python3.8/site-packages/kubernetes_asyncio/client/rest.py", line 194, in request
    raise ApiException(http_resp=r)
kubernetes_asyncio.client.exceptions.ApiException: (415)
Reason: Unsupported Media Type
HTTP response headers: <CIMultiDictProxy('Cache-Control': 'no-cache, private', 'Content-Type': 'application/json', 'Date': 'Fri, 03 Sep 2021 11:16:55 GMT', 'Content-Length': '293')>
HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"the body of the request was in an unknown format - accepted media types include: application/json-patch+json, application/merge-patch+json, application/apply-patch+yaml","reason":"UnsupportedMediaType","code":415}

Is this a version compatibility issue with kubernetes?

@tomplus
Copy link
Owner

tomplus commented Sep 3, 2021

No, it's a known issue - openapi-generator doesn't support some type of patch which are used by K8s. Libraries work differently as you noticed.

I close this issue, please watch #68

@tomplus tomplus closed this as completed Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants