Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(proxy): let Retry recover drifted live managed proxies (#67729)

Yasenda157c6a4b38
diff --git a/frontend/src/scenes/settings/environment/ManagedReverseProxy.tsx b/frontend/src/scenes/settings/environment/ManagedReverseProxy.tsx
index 7236b74c8707..948205a6c2e7 100644
--- a/frontend/src/scenes/settings/environment/ManagedReverseProxy.tsx
+++ b/frontend/src/scenes/settings/environment/ManagedReverseProxy.tsx
@@ -346,7 +346,7 @@ const ExpandedRow = ({ record }: { record: ProxyRecord }): JSX.Element => {
{
label: 'Diagnosis',
key: 'diagnosis',
- content: <DiagnosticReportContent report={report} />,
+ content: <DiagnosticReportContent report={report} record={record} />,
},
]
: []),
@@ -487,20 +487,27 @@ const checkStatusIcon = (status: DiagnosticCheckStatus): JSX.Element => {
}
}
-function DiagnosticReportContent({ report }: { report: DiagnosticReport }): JSX.Element {
+function DiagnosticReportContent({ report, record }: { report: DiagnosticReport; record: ProxyRecord }): JSX.Element {
return (
<div className="flex flex-col gap-3">
<div className="text-xs text-secondary">Ran {new Date(report.ran_at).toLocaleString()}</div>
<div className="flex flex-col gap-2">
{report.checks.map((check) => (
- <DiagnosticCheckRow key={check.id} check={check} />
+ <DiagnosticCheckRow key={check.id} check={check} record={record} />
))}
</div>
</div>
)
}
-function DiagnosticCheckRow({ check }: { check: DiagnosticCheckResult }): JSX.Element {
+// A proxy that's provisioning or being torn down can't be retried — mirror the backend guard so the
+// button can't kick off a workflow that would race the in-flight one.
+const RETRY_BLOCKING_STATUSES: ProxyRecord['status'][] = ['waiting', 'issuing', 'deleting']
+
+function DiagnosticCheckRow({ check, record }: { check: DiagnosticCheckResult; record: ProxyRecord }): JSX.Element {
+ const { retryRecord } = useActions(proxyLogic)
+ const retryBlocked = RETRY_BLOCKING_STATUSES.includes(record.status)
+
return (
<div className="border rounded p-3 flex flex-col gap-2 bg-surface-secondary">
<div className="flex items-center gap-2">
@@ -521,6 +528,19 @@ function DiagnosticCheckRow({ check }: { check: DiagnosticCheckResult }): JSX.El
))}
</div>
)}
+ {check.remediation.type === 'retry' && (
+ <div>
+ <LemonButton
+ type="secondary"
+ size="small"
+ loading={retryBlocked}
+ disabledReason={retryBlocked ? 'A retry is already in progress' : undefined}
+ onClick={() => retryRecord(record.id)}
+ >
+ Retry
+ </LemonButton>
+ </div>
+ )}
</div>
)}
</div>
diff --git a/posthog/api/proxy_record.py b/posthog/api/proxy_record.py
index b18eb7b91d97..1af84763e98e 100644
--- a/posthog/api/proxy_record.py
+++ b/posthog/api/proxy_record.py
@@ -324,9 +324,11 @@ class ProxyRecordViewset(TeamAndOrgViewSetMixin, ModelViewSet):
return Response(serializer.data)
@extend_schema(
- description="Retry provisioning a failed reverse proxy. "
- "Only available for proxies in 'erroring' or 'timed_out' status. "
- "Resets the proxy to 'waiting' status and restarts the provisioning workflow.",
+ description="Retry provisioning of a reverse proxy. "
+ "Available for any proxy that isn't currently being provisioned or deleted "
+ "(i.e. not in 'waiting', 'issuing', or 'deleting' status). This includes 'valid' "
+ "proxies whose diagnostics detected drift (e.g. the Cloudflare custom hostname went "
+ "missing). Resets the proxy to 'waiting' status and restarts the provisioning workflow.",
request=None,
)
@action(methods=["POST"], detail=True)
@@ -336,9 +338,13 @@ class ProxyRecordViewset(TeamAndOrgViewSetMixin, ModelViewSet):
except ProxyRecord.DoesNotExist:
raise NotFound()
- if record.status not in (
- ProxyRecord.Status.ERRORING,
- ProxyRecord.Status.TIMED_OUT,
+ # Retry re-runs the idempotent create-proxy workflow to re-provision. Block only the
+ # transitional states where a re-run would race the in-flight provision/delete; every
+ # settled state (valid/warning/erroring/timed_out) can be re-provisioned to recover drift.
+ if record.status in (
+ ProxyRecord.Status.WAITING,
+ ProxyRecord.Status.ISSUING,
+ ProxyRecord.Status.DELETING,
):
return Response(
{"detail": f"Cannot retry proxy in {record.status} state."},
diff --git a/posthog/api/test/test_proxy_record.py b/posthog/api/test/test_proxy_record.py
index db5ee55c9a17..09038304d52c 100644
--- a/posthog/api/test/test_proxy_record.py
+++ b/posthog/api/test/test_proxy_record.py
@@ -167,6 +167,10 @@ class TestProxyRecordAPI(APIBaseTest):
[
("erroring", ProxyRecord.Status.ERRORING, "Cloudflare API error"),
("timed_out", ProxyRecord.Status.TIMED_OUT, None),
+ # Settled non-error states are retryable too, so diagnostics that detect drift on a
+ # live proxy (e.g. the Cloudflare custom hostname went missing) can recover via Retry.
+ ("valid", ProxyRecord.Status.VALID, None),
+ ("warning", ProxyRecord.Status.WARNING, "Cloudflare custom hostname missing"),
]
)
@patch("posthog.api.proxy_record.sync_connect")
@@ -201,12 +205,10 @@ class TestProxyRecordAPI(APIBaseTest):
[
("waiting", ProxyRecord.Status.WAITING),
("issuing", ProxyRecord.Status.ISSUING),
- ("valid", ProxyRecord.Status.VALID),
- ("warning", ProxyRecord.Status.WARNING),
("deleting", ProxyRecord.Status.DELETING),
]
)
- def test_cannot_retry_proxy_in_non_error_state(self, _name, initial_status):
+ def test_cannot_retry_proxy_in_transitional_state(self, _name, initial_status):
record = ProxyRecord.objects.create(
organization=self.organization,
created_by=self.user,
diff --git a/services/mcp/src/generated/proxy-records/api.ts b/services/mcp/src/generated/proxy-records/api.ts
index 8cfd8c796b10..31b7fdbe1a4a 100644
--- a/services/mcp/src/generated/proxy-records/api.ts
+++ b/services/mcp/src/generated/proxy-records/api.ts
@@ -73,7 +73,7 @@ export const ProxyRecordsDiagnoseCreateParams = /* @__PURE__ */ zod.object({
})
/**
- * Retry provisioning a failed reverse proxy. Only available for proxies in 'erroring' or 'timed_out' status. Resets the proxy to 'waiting' status and restarts the provisioning workflow.
+ * Retry provisioning of a reverse proxy. Available for any proxy that isn't currently being provisioned or deleted (i.e. not in 'waiting', 'issuing', or 'deleting' status). This includes 'valid' proxies whose diagnostics detected drift (e.g. the Cloudflare custom hostname went missing). Resets the proxy to 'waiting' status and restarts the provisioning workflow.
*/
export const ProxyRecordsRetryCreateParams = /* @__PURE__ */ zod.object({
id: zod.string().describe('A UUID string identifying this proxy record.'),