Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ingest): add retries for tableau #9437

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading