Skip to content

Commit

Permalink
sync: add a 5 second timeout to gemato's openpgp refresh
Browse files Browse the repository at this point in the history
If it takes more than 5 seconds to download a miniscule file from
https://gentoo.org/.well-known/openpgpkey/ then something has gone
dreadfully wrong. Most commonly, what went wrong is that the user has
broken ipv6 connectivity and requests simply hangs forever (no joke --
it doesn't implement Happy Eyeballs and closed the multiple bug reports
as "please use stackoverflow to ask questions about how to use requests,
we are not a support forum").

Pass a timeout so that we eventually give up and try ipv4 instead. This
is a crude hack and the proper solution is to make gemato handle this
better, but until gemato is fixed to use a better download library we do
the best we can.

Bug: psf/requests#6788
Bug: projg2/gemato#35
Bug: https://bugs.gentoo.org/779766
Signed-off-by: Eli Schwartz <[email protected]>
  • Loading branch information
eli-schwartz committed Aug 27, 2024
1 parent 747b2d2 commit 47ad402
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/portage/sync/syncbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,21 +330,23 @@ def noisy_refresh_keys():

def _get_openpgp_env(self, openpgp_key_path=None, debug=False):
if gemato is not None:
timeout = 15
# Override global proxy setting with one provided in emerge configuration
if "http_proxy" in self.spawn_kwargs["env"]:
proxy = self.spawn_kwargs["env"]["http_proxy"]
elif "https_proxy" in self.spawn_kwargs["env"]:
proxy = self.spawn_kwargs["env"]["https_proxy"]
else:
proxy = None
timeout = 5

if openpgp_key_path:
openpgp_env = gemato.openpgp.OpenPGPEnvironment(
proxy=proxy, debug=debug
proxy=proxy, debug=debug, timeout=timeout
)
else:
openpgp_env = gemato.openpgp.OpenPGPSystemEnvironment(
proxy=proxy, debug=debug
proxy=proxy, debug=debug, timeout=timeout
)

return openpgp_env
Expand Down

0 comments on commit 47ad402

Please sign in to comment.