Skip to content

Commit f81ac0e

Browse files
committed
Treat simulation gateway probe as public
1 parent 45e4d7d commit f81ac0e

5 files changed

Lines changed: 5 additions & 29 deletions

File tree

.github/scripts/deploy_cloud_run_candidate.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ env_vars=(
2222
"GATEWAY_AUTH_AUDIENCE=${GATEWAY_AUTH_AUDIENCE}"
2323
"GATEWAY_AUTH_CLIENT_ID=${GATEWAY_AUTH_CLIENT_ID}"
2424
"GATEWAY_AUTH_CLIENT_SECRET_RESOURCE=${GATEWAY_AUTH_CLIENT_SECRET_RESOURCE}"
25-
"CLOUD_RUN_INTERNAL_PROBES=1"
2625
"API_HOST_BACKEND=cloud_run"
2726
"SIM_FRONT_DOOR=old_gateway_direct"
2827
"SIM_COMPUTE_ECONOMY=old_gateway"

docs/migration-pr3-cloud-run-candidate-runbook.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ does not migrate the public App Engine/custom API URL.
1515
service account used to run `gcloud`.
1616
- The same live staging integration suite against both the App Engine staging
1717
URL and the tagged Cloud Run staging URL.
18-
- Production smoke tests against the tagged Cloud Run URL, including an
19-
internal simulation-gateway health probe.
18+
- Production smoke tests against the tagged Cloud Run URL, including the public
19+
simulation-gateway health probe.
2020
- Tier 1 Cloud Run startup supervision: the container still runs local Redis,
2121
but the bash startup script tracks Redis and Uvicorn child PIDs explicitly and
2222
exits if either process dies.

policyengine_api/asgi_factory.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations
44

5-
import os
65
import time
76
import uuid
87
from typing import Literal
@@ -32,14 +31,6 @@ class SimulationGatewayHealthResponse(BaseModel):
3231
simulation_gateway: Literal["healthy"]
3332

3433

35-
def _internal_probes_enabled() -> bool:
36-
return os.environ.get("CLOUD_RUN_INTERNAL_PROBES", "").lower() in {
37-
"1",
38-
"true",
39-
"yes",
40-
}
41-
42-
4334
def _add_vary_origin(response) -> None:
4435
vary = response.headers.get("Vary")
4536
if vary is None:
@@ -92,9 +83,6 @@ def health() -> HealthResponse:
9283
include_in_schema=False,
9384
)
9485
def simulation_gateway_health() -> SimulationGatewayHealthResponse:
95-
if not _internal_probes_enabled():
96-
raise HTTPException(status_code=404, detail="Not found")
97-
9886
from policyengine_api.libs.simulation_api_modal import SimulationAPIModal
9987

10088
try:

tests/unit/test_asgi_factory.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,7 @@ def test_health_route_uses_same_reflected_cors_policy():
162162
assert response.headers["vary"] == "Origin"
163163

164164

165-
def test_simulation_gateway_health_probe_is_disabled_by_default(monkeypatch):
166-
monkeypatch.delenv("CLOUD_RUN_INTERNAL_PROBES", raising=False)
167-
client = TestClient(create_asgi_app(create_test_wsgi_app()))
168-
169-
response = client.get("/health/simulation-gateway")
170-
171-
assert response.status_code == 404
172-
173-
174-
def test_simulation_gateway_health_probe_checks_gateway(monkeypatch):
175-
monkeypatch.setenv("CLOUD_RUN_INTERNAL_PROBES", "1")
165+
def test_public_simulation_gateway_health_probe_checks_gateway():
176166
client = TestClient(create_asgi_app(create_test_wsgi_app()))
177167

178168
with patch(
@@ -191,8 +181,7 @@ def test_simulation_gateway_health_probe_checks_gateway(monkeypatch):
191181
simulation_api.return_value.health_check.assert_called_once_with()
192182

193183

194-
def test_simulation_gateway_health_probe_reports_failure(monkeypatch):
195-
monkeypatch.setenv("CLOUD_RUN_INTERNAL_PROBES", "1")
184+
def test_public_simulation_gateway_health_probe_reports_failure():
196185
client = TestClient(create_asgi_app(create_test_wsgi_app()))
197186

198187
with patch(

tests/unit/test_cloud_run_deploy_scripts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def test_deploy_cloud_run_candidate_dry_run_never_shifts_traffic():
168168
f"POLICYENGINE_DB_INSTANCE_CONNECTION_NAME={PRODUCTION_CLOUD_SQL_INSTANCE}"
169169
in result.stdout
170170
)
171-
assert "CLOUD_RUN_INTERNAL_PROBES=1" in result.stdout
171+
assert "CLOUD_RUN_INTERNAL_PROBES" not in result.stdout
172172
assert "--to-latest" not in result.stdout
173173
assert "update-traffic" not in result.stdout
174174

0 commit comments

Comments
 (0)