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

ref(relay): Only update internal state when it changed #76594

Merged
merged 2 commits into from
Aug 28, 2024
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
4 changes: 3 additions & 1 deletion src/sentry/api/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ def relay_from_id(request: Request, relay_id: str) -> tuple[Relay | None, bool]:
else:
try:
relay = Relay.objects.get(relay_id=relay_id)
relay.is_internal = is_internal_relay(request, relay.public_key)
return relay, False # a Relay from the database
except Relay.DoesNotExist:
return None, False # no Relay found
Expand Down Expand Up @@ -223,6 +222,9 @@ def authenticate_credentials(
if relay is None:
raise AuthenticationFailed("Unknown relay")

if not static:
relay.is_internal = is_internal_relay(request, relay.public_key)

try:
data = relay.public_key_object.unpack(request.body, relay_sig, max_age=60 * 5)
request.relay = relay
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/relay/register_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def post(self, request: Request) -> Response:
relay = Relay.objects.create(
relay_id=relay_id, public_key=public_key, is_internal=is_internal
)
else:
elif relay.is_internal != is_internal:
# update the internal flag in case it is changed
relay.is_internal = is_internal
relay.save()
Expand Down
Loading