Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

management: Don't silence send_server_data_to_push_bouncer exceptions.

Mateusz Mandera517538a296f9
diff --git a/analytics/management/commands/update_analytics_counts.py b/analytics/management/commands/update_analytics_counts.py
index 541ebf07b5d..01efeac32e0 100644
--- a/analytics/management/commands/update_analytics_counts.py
+++ b/analytics/management/commands/update_analytics_counts.py
@@ -95,4 +95,4 @@ class Command(ZulipBaseCommand):
logger.info("Sleeping %d seconds before reporting...", delay)
time.sleep(delay)
- send_server_data_to_push_bouncer(consider_usage_statistics=True)
+ send_server_data_to_push_bouncer(consider_usage_statistics=True, raise_on_error=True)
diff --git a/zerver/lib/remote_server.py b/zerver/lib/remote_server.py
index 7b5b4d62b72..e2a224e7fa6 100644
--- a/zerver/lib/remote_server.py
+++ b/zerver/lib/remote_server.py
@@ -387,13 +387,17 @@ def should_send_analytics_data() -> bool: # nocoverage
return settings.ANALYTICS_DATA_UPLOAD_LEVEL > AnalyticsDataUploadLevel.NONE
-def send_server_data_to_push_bouncer(consider_usage_statistics: bool = True) -> None:
+def send_server_data_to_push_bouncer(
+ consider_usage_statistics: bool = True, raise_on_error: bool = False
+) -> None:
logger = logging.getLogger("zulip.analytics")
# first, check what's latest
try:
result = send_to_push_bouncer("GET", "server/analytics/status", {})
except (JsonableError, orjson.JSONDecodeError) as e:
maybe_mark_pushes_disabled(e, logger)
+ if raise_on_error: # nocoverage
+ raise
return
# Gather only entries with IDs greater than the last ID received by the push bouncer.
@@ -452,6 +456,8 @@ def send_server_data_to_push_bouncer(consider_usage_statistics: bool = True) ->
"POST", "server/analytics", request.model_dump(round_trip=True)
)
except (JsonableError, orjson.JSONDecodeError) as e:
+ if raise_on_error: # nocoverage
+ raise
maybe_mark_pushes_disabled(e, logger)
return
diff --git a/zerver/management/commands/register_server.py b/zerver/management/commands/register_server.py
index 6d93868b276..5822c07a4dd 100644
--- a/zerver/management/commands/register_server.py
+++ b/zerver/management/commands/register_server.py
@@ -134,7 +134,7 @@ that registration and saving the updated secret in
"/api/v1/remotes/server/register", request
)
- send_server_data_to_push_bouncer(consider_usage_statistics=False)
+ send_server_data_to_push_bouncer(consider_usage_statistics=False, raise_on_error=True)
if response.json()["created"]:
print(