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

Fix failures property in /keys/query #17499

Merged
merged 4 commits into from
Jul 30, 2024
Merged
Changes from 1 commit
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
Next Next commit
Fix failures key in /keys/query response
richvdh committed Jul 29, 2024
commit 11b03c06a7c60eaba642799f4b0672848b19e6ee
26 changes: 18 additions & 8 deletions synapse/handlers/e2e_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,21 @@ async def _query(destination: str) -> None:

# Only try and fetch keys for destinations that are not marked as
# down.
filtered_destinations = await filter_destinations_by_retry_limiter(
remote_queries_not_in_cache.keys(),
self.clock,
self.store,
# Let's give an arbitrary grace period for those hosts that are
# only recently down
retry_due_within_ms=60 * 1000,
unfiltered_destinations = remote_queries_not_in_cache.keys()
filtered_destinations = set(
await filter_destinations_by_retry_limiter(
unfiltered_destinations,
self.clock,
self.store,
# Let's give an arbitrary grace period for those hosts that are
# only recently down
retry_due_within_ms=60 * 1000,
)
)
failures |= {
dest: _NOT_READY_FOR_RETRY_FAILURE
for dest in (unfiltered_destinations - filtered_destinations)
}

await concurrently_execute(
_query,
Expand Down Expand Up @@ -1641,6 +1648,9 @@ def _check_device_signature(
raise SynapseError(400, "Invalid signature", Codes.INVALID_SIGNATURE)


_NOT_READY_FOR_RETRY_FAILURE = {"status": 503, "message": "Not ready for retry"}


def _exception_to_failure(e: Exception) -> JsonDict:
if isinstance(e, SynapseError):
return {"status": e.code, "errcode": e.errcode, "message": str(e)}
Expand All @@ -1649,7 +1659,7 @@ def _exception_to_failure(e: Exception) -> JsonDict:
return {"status": e.code, "message": str(e)}

if isinstance(e, NotRetryingDestination):
return {"status": 503, "message": "Not ready for retry"}
return _NOT_READY_FOR_RETRY_FAILURE

# include ConnectionRefused and other errors
#
Expand Down