Repository navigation
fix(stream): handle tuple _request_timeout format in stream websocket calls - #2786
YuvrajLamba01 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: YuvrajLamba01 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @YuvrajLamba01! |
Support (connect, read) tuple format for _request_timeout in WSClient and create_websocket, matching the urllib3 Timeout contract used across REST API calls. Unpack read timeout for run_forever and pass connect timeout to WebSocket.connect(). Signed-off-by: Yuvraj Lamba <yuvrajlamba5151@gmail.com>
5860d9b to
aab793c
Compare
What type of PR is this?
/kind bug
What this PR does / why we need it:
According to the API client documentation and
kubernetes/client/rest.py:211-246,_request_timeoutcan be passed either as a single numeric value (total timeout) or as a pair (tuple) of(connection, read)timeouts.When using
kubernetes.stream(e.g.connect_get_namespaced_pod_exec), passing a tuple previously caused a crash inWSClient.run_forever:In addition,
create_websocket()was not forwarding the connect timeout component toWebSocket.connect(), causing websocket handshakes to fall back to the default 30-second socket timeout even if a lower timeout was specified.This PR addresses both issues:
WSClient.run_forever, unpackstimeout = timeout[1]iftimeoutis a 2-tuple, avoiding theTypeErrorand correctly bounding execution by the read timeout.create_websocket, forwards_request_timeout[0](or scalar_request_timeout) toconnect_opt['timeout']forWebSocket.connect()._request_timeoutthroughWSClient.__init__,websocket_call, andportforward_call.create_websocket,run_forever,websocket_call, and_websocket_request.Which issue(s) this PR fixes:
Fixes #2292
Special notes for your reviewer:
cc: @roycaihw @yliaog
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: