Skip to content

Commit

Permalink
Add retries in session (#245)
Browse files Browse the repository at this point in the history
* Add retries in session

* Fix configuration

* Fix typo

* Add connect option to retry in connection error

* Remove extra line

---------

Co-authored-by: herodes1991 <eloy.maillo@Eloys-MacBook-Pro.local>
  • Loading branch information
herodes1991 and herodes1991 authored May 15, 2024
1 parent 52fb5bb commit 9a51eab
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fiaas_deploy_daemon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9a51eab

Please sign in to comment.