Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #4453/cbf160de backport][3.22] Removed force_close from all downloaders #4796

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES/4452.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removed a workaround to force close all tcp connections in sync leading to an exhaustion of port
numbers and their reuse while in time_wait state.
22 changes: 9 additions & 13 deletions pulpcore/download/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ class DownloaderFactory:
http://aiohttp.readthedocs.io/en/stable/client_quickstart.html#timeouts Behaviorally, it should
allow for an active download to be arbitrarily long, while still detecting dead or closed
sessions even when TCPKeepAlive is disabled.

Also for http and https urls, even though HTTP 1.1 is used, the TCP connection is setup and
closed with each request. This is done for compatibility reasons due to various issues related
to session continuation implementation in various servers.
"""

def __init__(self, remote, downloader_overrides=None):
Expand Down Expand Up @@ -102,7 +98,7 @@ def _make_aiohttp_session_from_remote(self):
Returns:
:class:`aiohttp.ClientSession`
"""
tcp_conn_opts = {"force_close": True}
tcp_conn_opts = {}

sslcontext = None
if self._remote.ca_cert:
Expand Down Expand Up @@ -133,17 +129,17 @@ def _make_aiohttp_session_from_remote(self):
headers["User-Agent"] = f"{headers['User-Agent']}, {user_agent_header}"
headers.extend(header_dict)

conn = aiohttp.TCPConnector(**tcp_conn_opts)
total = self._remote.total_timeout
sock_connect = self._remote.sock_connect_timeout
sock_read = self._remote.sock_read_timeout
connect = self._remote.connect_timeout

timeout = aiohttp.ClientTimeout(
total=total, sock_connect=sock_connect, sock_read=sock_read, connect=connect
total=self._remote.total_timeout,
sock_connect=self._remote.sock_connect_timeout,
sock_read=self._remote.sock_read_timeout,
connect=self._remote.connect_timeout,
)
return aiohttp.ClientSession(
connector=conn, timeout=timeout, headers=headers, requote_redirect_url=False
connector=aiohttp.TCPConnector(**tcp_conn_opts),
timeout=timeout,
headers=headers,
requote_redirect_url=False,
)

def build(self, url, **kwargs):
Expand Down
6 changes: 1 addition & 5 deletions pulpcore/download/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ class HttpDownloader(BaseDownloader):
allow for an active download to be arbitrarily long, while still detecting dead or closed
sessions even when TCPKeepAlive is disabled.

If a session is not provided, the one created will force TCP connection closure after each
request. This is done for compatibility reasons due to various issues related to session
continuation implementation in various servers.

`aiohttp.ClientSession` objects allows you to configure options that will apply to all
downloaders using that session such as auth, timeouts, headers, etc. For more info on these
options see the `aiohttp.ClientSession` docs for more information:
Expand Down Expand Up @@ -165,7 +161,7 @@ def __init__(
self._close_session_on_finalize = False
else:
timeout = aiohttp.ClientTimeout(total=None, sock_connect=600, sock_read=600)
conn = aiohttp.TCPConnector({"force_close": True})
conn = aiohttp.TCPConnector()
self.session = aiohttp.ClientSession(
connector=conn, timeout=timeout, headers=headers, requote_redirect_url=False
)
Expand Down
Loading