google-auth: connection leaks in urllib3 transport and metadata helper during mTLS updates

Open
#17,755 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@nbayati is already working on this.

Since Oct 9, 2026.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
gcp, python
Domain
backend, cloud

Research direction

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.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Python
Stars
5.4k
Forks
1.8k
Avg merge
2d 7h
Merged PRs (30d)
173

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from googleapis/google-cloud-python

All issues in googleapis/google-cloud-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.