exec command is parsing output if output looks like json
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
调研方向
从与 connect_get_namespaced_pod_exec 一起使用的流入口点开始,然后检查报告中提到的 WSResponse 类和 _preload_content 路径。重现两个 echo 命令并比较返回的值;完成的标准是命令输出能够一致地返回,从而无需特殊处理即可将 JSON 输出传递给 json.loads。
由索引模型根据 Issue 内容生成。
描述
What happened (please include outputs or screenshots):
Working on creating a scale test where the test orchestrator will exec in each pod and run a curl command to verify the pod is in the expected state. The output of the curl is JSON.
The problem seems to be that the stream client will parse the json as a python dictionary if the output is only json, but return it to the caller as a stringified dictionary. Expecting json, json.loads is failing.
To verify I ran
In [5]: cmd=["echo", '{"example":"json", "with":null, "and":true}']
In [6]: kstream.stream(api_instance.connect_get_namespaced_pod_exec,
...: name=pod,
...: namespace=ns,
...: container=container,
...: command=cmd,
...: stderr=True,
...: stdin=False,
...: tty=False,
...: stdout=True)
Out[6]: "{'example': 'json', 'with': None, 'and': True}"
In [7]: cmd=["echo", 'but not actually json {"example":"json", "with":null, "and":true}']
In [8]: kstream.stream(api_instance.connect_get_namespaced_pod_exec,
...: name=pod,
...: namespace=ns,
...: container=container,
...: command=cmd,
...: stderr=True,
...: stdin=False,
...: tty=False,
...: stdout=True)
Out[8]: 'but not actually json {"example":"json", "with":null, "and":true}\n'
What you expected to happen:
I really did not expect the response to be different depending on the output of the command being run.
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
We are able to get around the issue by adding _preload_content=False to the stream function call and handling waiting for the response and reading stdout/stderr ourselves.
I wasn't sure where the rogue json parsing is happening, maybe in WSResponse class?
Environment:
- Kubernetes version (
kubectl version):
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.6", GitCommit:"7015f71e75f670eb9e7ebd4b5749639d42e20079", GitTreeState:"clean", BuildDate:"2019-11-19T15:41:24Z", GoVersion:"go1.12.13", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"14+", GitVersion:"v1.14.8-eks-b8860f", GitCommit:"b8860f6c40640897e52c143f1b9f011a503d6e46", GitTreeState:"clean", BuildDate:"2019-11-25T00:55:38Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}
- OS (e.g., MacOS 10.13.6):
Ubuntu 19.10 - Python version (
python --version)
python 3.7.5
- Python client version (
pip list | grep kubernetes)
kubernetes==10.0.1
- 主要语言
- Python
- 星标
- 7.7k
- 派生
- 3.5k
- 平均合并
- 3 天 4 小时
- 30 天内合并 PR
- 9
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
kubernetes-client/python 的其他 Issue
-
getheaders is deprecated in urllib3 >= 2.0.0可能重新可做 关联的 PR 已关闭且未合并。 未关闭kind/bug
难度 1/5 1 小时以内 新手友好度 68/100
kubernetes-client/python#2280 · 16 条评论 · 9 个 reaction ·
维护者通常 3 天内回复
-
Security: pin oauthlib>=4.0.0 (CVE-2026-49264, CVE-2026-49265)可能已有人在做 @friedrichwilken 于 4 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 30/100
kubernetes-client/python#2720 ·
维护者通常 3 天内回复
-
Release 1.37可能重新可做 @yliaog 于 38 天前认领,目前没有进行中的 PR。 未关闭
kubernetes-client/python#2691 · 1 条评论 · 1 个 reaction · 已指派 1 人 ·
维护者通常 3 天内回复
-
help wanted
难度 5/5 一周以上 新手友好度 35/100
kubernetes-client/python#2677 · 14 条评论 · 1 个 reaction ·
维护者通常 3 天内回复
-
Add option to disable strict x509 verifcation in sync client可能已有人在做 @Vishwa0223 于 42 天前认领。 未关闭help wanted kind/feature
kubernetes-client/python#2602 · 6 条评论 · 已指派 1 人 ·
维护者通常 3 天内回复
查看 kubernetes-client/python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
LearningCircuit/local-deep-research#7206 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
chingu-voyages/V62-tier3-team-33#285 ·
维护者通常 1 天内回复
-
Proxy drops log notifications from backends that don't send FastMCP's msg/extra dict可能已有人在做 @asasemahmed 今天认领。 未关闭bug server
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
[Bug]: Bedrock request metadata forwarding does not work for /embeddings可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug llm translation
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复