Kubernetes client exception with connection refused error
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- kubernetes, python
- Lĩnh vực
- devops, infrastructure
Hướng nghiên cứu
Bắt đầu với hàm k8s_exec và đường dẫn websocket_call trong kubernetes/stream/ws_client.py, đặc biệt là lỗi được báo cáo ở dòng 525. Tái hiện lỗi kết nối bị từ chối xảy ra không liên tục trên các môi trường Kubernetes đã nêu và so sánh lỗi đó với issue 1841. Công việc được xem là hoàn tất khi xác định và xử lý được nguyên nhân để các kết nối websocket vẫn khả dụng trong khi thực hiện các lệnh gọi pod exec.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Our tests had been running fine till we started running into the following issue where the kubernetes client websocket call will terminate with an exception:
channel = stream(api.connect_get_namespaced_pod_exec,
/usr/lib/python3.8/site-packages/kubernetes/stream/stream.py:35: in _websocket_request
return api_method(*args, **kwargs)
/usr/lib/python3.8/site-packages/kubernetes/client/api/core_v1_api.py:994: in connect_get_namespaced_pod_exec
return self.connect_get_namespaced_pod_exec_with_http_info(name, namespace, **kwargs) # noqa: E501
/usr/lib/python3.8/site-packages/kubernetes/client/api/core_v1_api.py:1101: in connect_get_namespaced_pod_exec_with_http_info
return self.api_client.call_api(
/usr/lib/python3.8/site-packages/kubernetes/client/api_client.py:348: in call_api
return self.__call_api(resource_path, method,
/usr/lib/python3.8/site-packages/kubernetes/client/api_client.py:180: in __call_api
response_data = self.request(
configuration = <kubernetes.client.configuration.Configuration object at 0x7f192844cb20>
_method = 'GET'
url = 'wss://api.ndal-ocp2.ve.pd.f5net.com:6443/api/v1/namespaces/spk-test-automation/pods/ans-client-ci6492742-127/exec?com...command=2001%3A0db8%3A0%3A127%3A%3A100&command=-t&command=10&command=-P8&stderr=True&stdin=False&stdout=True&tty=False'
kwargs = {'_preload_content': False, '_request_timeout': None, 'body': None, 'headers': {'Accept': '/', 'User-Agent': 'OpenAPI-Generator/25.3.0/python', 'authorization': 'Bearer sha256bgMewSf5E2EdW_h4EYLI4Ju-I21kPKVzK5tRTvqFgtg'}, ...}bgMewSf5E2EdW_h4EYLI4Ju-I21kPKVzK5tRTvqFgtg'}
headers = {'Accept': '/', 'User-Agent': 'OpenAPI-Generator/25.3.0/python', 'authorization': 'Bearer sha256
_request_timeout = None, _preload_content = False, capture_all = True
def websocket_call(configuration, _method, url, **kwargs):
"""An internal function to be called in api-client when a websocket
connection is required. method, url, and kwargs are the parameters of
apiClient.request method."""
url = get_websocket_url(url, kwargs.get("query_params"))
headers = kwargs.get("headers")
_request_timeout = kwargs.get("_request_timeout", 60)
_preload_content = kwargs.get("_preload_content", True)
capture_all = kwargs.get("capture_all", True)
try:
client = WSClient(configuration, url, headers, capture_all)
if not _preload_content:
return client
client.run_forever(timeout=_request_timeout)
return WSResponse('%s' % ''.join(client.read_all()))
except (Exception, KeyboardInterrupt, SystemExit) as e:
raise ApiException(status=0, reason=str(e))
E kubernetes.client.exceptions.ApiException: (0)
E Reason: [Errno 111] Connection refused
/usr/lib/python3.8/site-packages/kubernetes/stream/ws_client.py:525: ApiException
These exceptions happen at random (not for any specific or every test) and across different kubernetes environment/clusters. They started happening somewhere around early Feb, 2023. (not sure if its related to any fixes/changes).
Below is what we use in our code:
`def k8s_exec(command, pod, namespace, api):
channel = stream(api.connect_get_namespaced_pod_exec,
pod,
namespace,
command=command,
stderr=True, stdin=False,
stdout=True, tty=False,
_preload_content=False)
channel.run_forever(timeout=60)
err = yaml.safe_load(channel.read_channel(ERROR_CHANNEL))
if err is None:
raise AssertionError(f'The command "{command}" was timeouted')
rc = 0 if err['status'] == 'Success' else 1
stdout = channel.read_stdout()
stderr = channel.read_stderr()
return rc, stdout, stderr`
Not sure if this is similar to: 1841
What you expected to happen:
Connection is retained.
Environment:
- Kubernetes version (
kubectl version):
Client Version: version.Info{Major:"1", Minor:"20"
Server Version: version.Info{Major:"1", Minor:"23" - OS (e.g., MacOS 10.13.6): Linux
- Python version (
python --version): 2.7.5
- 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
-
getheaders is deprecated in urllib3 >= 2.0.0Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở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
-
Security: pin oauthlib>=4.0.0 (CVE-2026-49264, CVE-2026-49265)Có thể đã có người làm @friedrichwilken đã nhận 5 ngày trước. Đang mở
Độ 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 39 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ể đã có người làm @Vishwa0223 đã nhận 43 ngày trước. Đ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ự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
RailtownAI/railtracks#1633 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
review-panel severity:low
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
kristovatlas/coin-accounting#152 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation :blue_book:
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
PennyLaneAI/pennylane#10280 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
`pipx reinstall` prints a Python traceback when the reinstall failsCó thể đã có người làm @ParamTanna đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày