From 9a51eab06fa0b9736702a4433f4a783a79c4cd5b Mon Sep 17 00:00:00 2001 From: Eloy Maillo <14107036+herodes1991@users.noreply.github.com> Date: Wed, 15 May 2024 11:15:45 +0200 Subject: [PATCH] Add retries in session (#245) * Add retries in session * Fix configuration * Fix typo * Add connect option to retry in connection error * Remove extra line --------- Co-authored-by: herodes1991 --- fiaas_deploy_daemon/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fiaas_deploy_daemon/__init__.py b/fiaas_deploy_daemon/__init__.py index a3e4b519..7ac33cb5 100644 --- a/fiaas_deploy_daemon/__init__.py +++ b/fiaas_deploy_daemon/__init__.py @@ -28,6 +28,7 @@ import requests from k8s import config as k8s_config from prometheus_client import Info +from requests.adapters import HTTPAdapter, Retry from .config import Configuration from .crd import CustomResourceDefinitionBindings, DisabledCustomResourceDefinitionBindings @@ -57,6 +58,9 @@ def configure(self, bind): def provide_session(self, config: Configuration): session = requests.Session() + if config.extension_hook_url is not None: + retries = Retry(total=5, backoff_factor=0.1, connect=5) + session.mount(config.extension_hook_url, HTTPAdapter(max_retries=retries)) if config.proxy: session.proxies = {scheme: config.proxy for scheme in ("http", "https")} if config.debug: