diff --git a/posthog/models/remote_config.py b/posthog/models/remote_config.py index fd6d9cdda14d1..e525fb80d28f1 100644 --- a/posthog/models/remote_config.py +++ b/posthog/models/remote_config.py @@ -386,8 +386,6 @@ def _purge_cdn(self): ): return - logger.info(f"Purging CDN for team {self.team_id}") - data: dict[str, Any] = {"files": []} for domain in settings.REMOTE_CONFIG_CDN_PURGE_DOMAINS: @@ -397,12 +395,18 @@ def _purge_cdn(self): data["files"].append({"url": f"{full_domain}/array/{self.team.api_token}/config.js"}) data["files"].append({"url": f"{full_domain}/array/{self.team.api_token}/array.js"}) + logger.info(f"Purging CDN for team {self.team_id}", {"data": data}) + try: - requests.post( + res = requests.post( settings.REMOTE_CONFIG_CDN_PURGE_ENDPOINT, headers={"Authorization": f"Bearer {settings.REMOTE_CONFIG_CDN_PURGE_TOKEN}"}, data=data, ) + + if res.status_code != 200: + raise Exception(f"Failed to purge CDN for team {self.team_id}: {res.status_code} {res.text}") + except Exception: logger.exception(f"Failed to purge CDN for team {self.team_id}") REMOTE_CONFIG_CDN_PURGE_COUNTER.labels(result="failure").inc()