kelproject / pykube

Python client library for Kubernetes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTTPError: Job in version "v1" cannot be handled as a Job: [pos 264]: json: expect char '"' but got char '{'

cleverlzc opened this issue · comments

Traceback (most recent call last):
  File "/opt/xxx/RestApi.py", line 155, in createFunctionsJob
    k8shandle.createJob(imageName, imageName, request.json)
  File "/opt/xxx/k8shandle.py", line 298, in createJob
    pykube.Job(API, jobObj).create()
  File "/usr/local/lib/python2.7/dist-packages/pykube/objects.py", line 97, in create
    self.api.raise_for_status(r)
  File "/usr/local/lib/python2.7/dist-packages/pykube/http.py", line 106, in raise_for_status
    raise HTTPError(resp.status_code, payload["message"])
HTTPError: Job in version "v1" cannot be handled as a Job: [pos 264]: json: expect char '"' but got char '{'

I found this Exception raise position in the file of pykube/http.py:

    def raise_for_status(self, resp):
        try:
            resp.raise_for_status()
        except Exception:
            # attempt to provide a more specific exception based around what
            # Kubernetes returned as the error.
            if resp.headers["content-type"] == "application/json":
                payload = resp.json()
                if payload["kind"] == "Status":
                    raise HTTPError(resp.status_code, payload["message"])
            raise

But, I can not find why this error happened?

Anyone know why? Thanks!