From 165a426b0e674136cb8cfbe28e2dae40a0085c20 Mon Sep 17 00:00:00 2001 From: Pawel Walat <91884251+pawalat@users.noreply.github.com> Date: Thu, 13 Apr 2023 17:58:06 +0200 Subject: [PATCH] Added retry on vault request failure --- .../hashicorp/_internal_client/vault_client.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/airflow/providers/hashicorp/_internal_client/vault_client.py b/airflow/providers/hashicorp/_internal_client/vault_client.py index ea8aaf0071230..084b4927ed2db 100644 --- a/airflow/providers/hashicorp/_internal_client/vault_client.py +++ b/airflow/providers/hashicorp/_internal_client/vault_client.py @@ -190,7 +190,16 @@ def _client(self) -> hvac.Client: :return: Vault Client """ - _client = hvac.Client(url=self.url, **self.kwargs) + adapter = HTTPAdapter(max_retries=Retry( + total=3, + backoff_factor=1, + status_forcelist=[412, 500, 502, 503], + raise_on_status=False, + )) + session = Session() + session.mount("http://", adapter) + session.mount("https://", adapter) + _client = hvac.Client(url=self.url, session=session, **self.kwargs) if self.auth_type == "approle": self._auth_approle(_client) elif self.auth_type == "aws_iam":