anmolxlight opened a new pull request, #68557: URL: https://github.com/apache/airflow/pull/68557
<!-- Thank you for contributing! Please provide a description of the change and include the issue number closes below. --> ## Description The `kubernetes_executor.enable_tcp_keepalive` config option was relying on monkey-patching urllib3's `default_socket_options` after module import. In urllib3 v2.x, the `socket_options` parameter of `HTTPConnection.__init__` is evaluated as a default argument at import time, so changing the class attribute afterwards has no effect on newly created connections. This meant the TCP keepalive configuration was silently a no-op. This PR fixes the issue by passing socket options through the Kubernetes client's `Configuration.socket_options` field, which is properly threaded through: `ApiClient` -> `RESTClientObject.__init__` -> `urllib3.PoolManager` -> `HTTPConnectionPool` -> `HTTPConnection.__init__` The `kubernetes-client/python` library already supports this: `Configuration` has a `socket_options` attribute that is checked in `RESTClientObject.__init__` and forwarded to `urllib3.PoolManager` as a keyword argument. ### Changes - **kube_client.py**: `_enable_tcp_keepalive()` now accepts a `Configuration` object and sets `configuration.socket_options` directly instead of monkey-patching urllib3. `get_kube_client()` calls it after obtaining the configuration object. - **kubernetes_engine.py**: Passes configuration through to `_enable_tcp_keepalive` - **tests**: Updated `test_enable_tcp_keepalive` to verify `configuration.socket_options` is set correctly ### Notes - Includes `TCP_NODELAY` in the socket options to preserve the default urllib3 behavior of disabling Nagle's algorithm ## Related issue Closes: #68396 ## Reproduction See https://github.com/jonminter-dojo/airflow-k8s-tcp-keepalive-repro for a minimal reproduction demonstrating the bug with the old approach. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
