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: RemoteConfig CDN purge status #26968

Merged
merged 6 commits into from
Dec 17, 2024
Merged
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
10 changes: 7 additions & 3 deletions posthog/models/remote_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
Expand Down
Loading