exec command is parsing output if output looks like json
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu từ điểm vào của stream được sử dụng với connect_get_namespaced_pod_exec, sau đó kiểm tra lớp WSResponse và đường dẫn _preload_content được đề cập trong báo cáo. Tái hiện cả hai lệnh echo và so sánh các giá trị được trả về; hoàn tất có nghĩa là đầu ra của lệnh được trả về một cách nhất quán để đầu ra JSON có thể được truyền vào json.loads mà không cần xử lý đặc biệt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 7.7k
- Fork
- 3.5k
- Merge trung bình
- 3 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của kubernetes-client/python
-
kind/bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
kubernetes-client/python#2280 · 16 bình luận · 9 reaction ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 30/100
kubernetes-client/python#2720 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Release 1.37Có thể làm lại được @yliaog đã nhận 34 ngày trước và không có pull request nào đang mở. Đang mở
kubernetes-client/python#2691 · 1 bình luận · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Growing library sizeĐang mởhelp wanted
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
kubernetes-client/python#2677 · 14 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Add option to disable strict x509 verifcation in sync clientCó thể làm lại được @Vishwa0223 đã nhận 39 ngày trước và không có pull request nào đang mở. Đang mởhelp wanted kind/feature
kubernetes-client/python#2602 · 6 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của kubernetes-client/python
Issue tương tự
-
adr
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
kristofdegrave/homeassistant-smart-charging#1607 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
namespace operations
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
EclipseFdn/open-vsx.org#13665 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
doc good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
collective/icalendar#1865 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
canonical/opentelemetry-collector-operator#409 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
mozilla/addons-release-tests#1243 ·
Maintainer thường phản hồi trong vòng 1 ngày