Skip to content

Commit

Permalink
feat(ingest): add retries for tableau (datahub-project#9437)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsheth2 authored and Salman-Apptware committed Dec 15, 2023
1 parent caae16c commit beac881
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion metadata-ingestion/src/datahub/ingestion/source/tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
import tableauserverclient as TSC
from pydantic import root_validator, validator
from pydantic.fields import Field
from requests.adapters import ConnectionError
from requests.adapters import ConnectionError, HTTPAdapter
from tableauserverclient import (
PersonalAccessTokenAuth,
Server,
ServerResponseError,
TableauAuth,
)
from tableauserverclient.server.endpoint.exceptions import NonXMLResponseError
from urllib3 import Retry

import datahub.emitter.mce_builder as builder
import datahub.utilities.sqlglot_lineage as sqlglot_l
Expand Down Expand Up @@ -174,6 +175,7 @@ class TableauConnectionConfig(ConfigModel):
description="Unique relationship between the Tableau Server and site",
)

max_retries: int = Field(3, description="Number of retries for failed requests.")
ssl_verify: Union[bool, str] = Field(
default=True,
description="Whether to verify SSL certificates. If using self-signed certificates, set to false or provide the path to the .pem certificate bundle.",
Expand Down Expand Up @@ -224,6 +226,17 @@ def make_tableau_client(self) -> Server:
# From https://stackoverflow.com/a/50159273/5004662.
server._session.trust_env = False

# Setup request retries.
adapter = HTTPAdapter(
max_retries=Retry(
total=self.max_retries,
backoff_factor=1,
status_forcelist=[429, 500, 502, 503, 504],
)
)
server._session.mount("http://", adapter)
server._session.mount("https://", adapter)

server.auth.sign_in(authentication)
return server
except ServerResponseError as e:
Expand Down

0 comments on commit beac881

Please sign in to comment.