From 6e62f5c408453f2c4990f0b8cb708995adb35bf5 Mon Sep 17 00:00:00 2001 From: Vasyl Saienko Date: Thu, 16 Jan 2025 08:34:35 +0200 Subject: [PATCH] Apply networking timeout to aiohttp session globally Closes: #377 Signed-off-by: Vasyl Saienko --- kopf/_cogs/clients/auth.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kopf/_cogs/clients/auth.py b/kopf/_cogs/clients/auth.py index e5c13a44..d8672bd1 100644 --- a/kopf/_cogs/clients/auth.py +++ b/kopf/_cogs/clients/auth.py @@ -9,6 +9,7 @@ import aiohttp from kopf._cogs.clients import errors +from kopf._cogs.configs import configuration from kopf._cogs.helpers import versions from kopf._cogs.structs import credentials @@ -101,6 +102,8 @@ def __init__( certificate_path: Optional[str] private_key_path: Optional[str] + settings = configuration.OperatorSettings() + if info.ca_path and info.ca_data: raise credentials.LoginError("Both CA path & data are set. Need only one.") elif info.ca_path: @@ -172,6 +175,11 @@ def __init__( ), headers=headers, auth=auth, + timeout=aiohttp.ClientTimeout( + total=settings.networking.request_timeout, + sock_connect=settings.networking.connect_timeout, + ), + ) # Add the extra payload information. We avoid overriding the constructor.