Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/sentry/net/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class SafeSession(Session):
def __init__(
self,
is_ipaddress_permitted: IsIpAddressPermitted = None,
max_retries: Retry | None = None,
max_retries: Retry | int | None = None,
) -> None:
Session.__init__(self)
self.headers.update({"User-Agent": USER_AGENT})
Expand Down
7 changes: 7 additions & 0 deletions src/sentry/options/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -4665,3 +4665,10 @@
default=30,
flags=FLAG_AUTOMATOR_MODIFIABLE,
)

register(
"integrations.client.disable_retries",
default=False,
type=Bool,
flags=FLAG_AUTOMATOR_MODIFIABLE,
)
4 changes: 3 additions & 1 deletion src/sentry/shared_integrations/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from requests.adapters import RetryError
from requests.exceptions import ConnectionError, HTTPError, Timeout

from sentry import options
from sentry.exceptions import RestrictedIPAddress
from sentry.http import build_session
from sentry.net.http import SafeSession
Expand Down Expand Up @@ -186,7 +187,8 @@
"""
Generates a safe Requests session for the API client to use.
"""
return build_session()
max_retries = 0 if options.get("integrations.client.disable_retries") else None
return build_session(max_retries=max_retries)

Check warning on line 191 in src/sentry/shared_integrations/client/base.py

View check run for this annotation

@sentry/warden / warden: sentry-backend-bugs

disable_retries is bypassed for control-silo IntegrationProxyClient requests

When `integrations.client.disable_retries` is enabled, `BaseApiClient.build_session` sets retries to zero, but `IntegrationProxyClient` overrides that method. In CONTROL mode, its override calls `build_session()` without a retry value, so provider requests still get the default `Retry(total=3)` and can hold the control-silo worker through repeated attempts. In the non-CELL branch, apply the option when building the session, e.g. `max_retries = 0 if options.get("integrations.client.disable_retries") else None; return build_session(max_retries=max_retries)`.
Comment thread
cmanallen marked this conversation as resolved.
Resolved
Comment thread
cmanallen marked this conversation as resolved.
Resolved

@staticmethod
def _normalize_cert_setting(cert_setting: object) -> str | tuple[str, str] | None:
Expand Down
4 changes: 4 additions & 0 deletions tests/sentry/integrations/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
ApiTimeoutError,
)
from sentry.shared_integrations.response.base import BaseApiResponse
from sentry.testutils.helpers.options import override_options


class ApiClientTest(TestCase):
def setUp(self) -> None:
self.enterContext(override_options({"integrations.client.disable_retries": False}))

@responses.activate
def test_get(self) -> None:
responses.add(responses.GET, "http://example.com", json={})
Expand Down
Loading