googleapis / googleapis/google-cloud-python
google-auth: connection leaks in urllib3 transport and metadata helper during mTLS updates
- Ngôn ngữ chính
- Python
- Star
- 5.4k
- Fork
- 1.8k
- Merge trung bình
- 3 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 122
Mô tả
When mTLS is configured or dynamically updated, the SDK creates and mounts new HTTP adapters/transports but leaves the old ones hanging. While PR #17689 addressed this for the `requests` transport, the leak still exists in two other places:
1. **urllib3 transport (`google/auth/transport/urllib3.py`)**
In `configure_mtls_channel`, `self.http = new_http` replaces the old PoolManager. We need to call `.clear()` on the old `PoolManager` instance before overwriting it so that the active connection pool is cleaned up.
2. **Compute Engine metadata (`google/auth/compute_engine/_metadata.py`)**
If mTLS is enabled, `_metadata.py` instantiates and mounts a new `MdsMtlsAdapter` on the session for every single request. Overwriting the mounted adapter without closing the old one leaks sockets. We should either cache and reuse the adapter or close the old one before mounting.
Hướng dẫn đóng góp
Hướng nghiên cứu
Read google/auth/transport/urllib3.py and google/auth/compute_engine/_metadata.py, starting with configure_mtls_channel and the per-request MdsMtlsAdapter mounting path. Confirm the old PoolManager is cleaned up and the metadata adapter is reused or closed rather than accumulating sockets, then add or run focused regression tests for both paths.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- gcp, python
- Lĩnh vực
- backend, cloud
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 72/100