exec command is parsing output if output looks like json
維護者通常 1 天內回覆
還沒有人認領這個 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
- 平均合併
- 1 天 5 小時
- 30 天內合併 PR
- 23
環境準備
- 沒有 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 lifecycle/stale
難度 1/5 1 小時以內 新手友好度 68/100
kubernetes-client/python#2280 · 17 則留言 · 9 個 reaction ·
維護者通常 1 天內回覆
-
kind/feature
難度 2/5 1-3 小時 新手友好度 55/100
kubernetes-client/python#2739 · 1 則留言 ·
維護者通常 1 天內回覆
-
help wanted
難度 5/5 一週以上 新手友好度 35/100
kubernetes-client/python#2677 · 15 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
Add option to disable strict x509 verifcation in sync client可能已有人在做 @Vishwa0223 於 56 天前認領。 未關閉help wanted kind/feature
kubernetes-client/python#2602 · 6 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
v36.0.0 regression fetching container logs可能重新可做 @yliaog 於 95 天前認領,目前沒有進行中的 PR。 未關閉kind/bug
kubernetes-client/python#2596 · 19 則留言 · 2 個 reaction · 已指派 1 人 ·
維護者通常 1 天內回覆
查看 kubernetes-client/python 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
docling-project/docling-mcp#147 ·
-
難度 2/5 1-3 小時 新手友好度 80/100
維護者通常 1 天內回覆
-
enhancement
難度 2/5 1-3 小時 新手友好度 76/100
autowarefoundation/autoware_carla_scenario#405 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 79/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
mohitmishra786/readprism#322 ·
維護者通常 1 天內回覆