Skip to content

Bad return for json response #2196

Description

@dyens

Hi 👋,

I have a valid json log messages in my container.
I would like to get a last log message:

from kubernetes import client, config

config.load_kube_config()

v1 = client.CoreV1Api()

namespace = "namespacename"
pod = "podname"

ret = v1.read_namespaced_pod_log(
            name=pod,
            namespace=namespace,
            tail_lines=1,
)

print(ret)

It returns:

{'time': '2024-02-19T13:32:53.08943787Z', 'level': 'INFO', 'msg': 'some msg'}

This is incorrect. There is single quotes in return. It should be:

{"time": "2024-02-19T13:32:53.08943787Z", "level": "INFO", "msg": "some msg"}

I think, that the reason for this in https://github.com/kubernetes-client/python/blob/master/kubernetes/client/api_client.py#L260.

Eventually, for valid json we have this transformation (after deserialization):

str(json.loads(response))

Environment:

  • Kubernetes version (kubectl version): 1.23
  • OS (e.g., MacOS 10.13.6): linux (fedora)
  • Python version (python --version): 3.11.7
  • Python client version (pip list | grep kubernetes): 29.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions