Spaces:
Running
Running
Include Studio identity secret readiness status
Browse files- app/api/health.py +17 -1
app/api/health.py
CHANGED
|
@@ -42,12 +42,14 @@ async def _readiness(request: Request) -> JSONResponse:
|
|
| 42 |
"""Report database/schema readiness without disclosing credentials or DSNs."""
|
| 43 |
container = request.app.state.container
|
| 44 |
database = container.security_database
|
|
|
|
|
|
|
| 45 |
try:
|
| 46 |
missing = await database.missing_schema_objects()
|
| 47 |
except Exception:
|
| 48 |
return JSONResponse(
|
| 49 |
status_code=503,
|
| 50 |
-
content={"status": "not_ready", "database": "unavailable", "schema_ready": False},
|
| 51 |
)
|
| 52 |
if missing:
|
| 53 |
return JSONResponse(
|
|
@@ -57,6 +59,7 @@ async def _readiness(request: Request) -> JSONResponse:
|
|
| 57 |
"database": "connected",
|
| 58 |
"schema_ready": False,
|
| 59 |
"missing_schema_objects": missing,
|
|
|
|
| 60 |
},
|
| 61 |
)
|
| 62 |
try:
|
|
@@ -72,6 +75,18 @@ async def _readiness(request: Request) -> JSONResponse:
|
|
| 72 |
"database": "connected",
|
| 73 |
"schema_ready": True,
|
| 74 |
"execution_role_ready": False,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
},
|
| 76 |
)
|
| 77 |
return JSONResponse(
|
|
@@ -81,6 +96,7 @@ async def _readiness(request: Request) -> JSONResponse:
|
|
| 81 |
"database": "connected",
|
| 82 |
"schema_ready": True,
|
| 83 |
"execution_role_ready": True,
|
|
|
|
| 84 |
},
|
| 85 |
)
|
| 86 |
|
|
|
|
| 42 |
"""Report database/schema readiness without disclosing credentials or DSNs."""
|
| 43 |
container = request.app.state.container
|
| 44 |
database = container.security_database
|
| 45 |
+
identity_secret = container.settings.studio_identity_secret
|
| 46 |
+
identity_configured = bool(identity_secret and len(identity_secret.get_secret_value()) >= 32)
|
| 47 |
try:
|
| 48 |
missing = await database.missing_schema_objects()
|
| 49 |
except Exception:
|
| 50 |
return JSONResponse(
|
| 51 |
status_code=503,
|
| 52 |
+
content={"status": "not_ready", "database": "unavailable", "schema_ready": False, "studio_identity_configured": identity_configured},
|
| 53 |
)
|
| 54 |
if missing:
|
| 55 |
return JSONResponse(
|
|
|
|
| 59 |
"database": "connected",
|
| 60 |
"schema_ready": False,
|
| 61 |
"missing_schema_objects": missing,
|
| 62 |
+
"studio_identity_configured": identity_configured,
|
| 63 |
},
|
| 64 |
)
|
| 65 |
try:
|
|
|
|
| 75 |
"database": "connected",
|
| 76 |
"schema_ready": True,
|
| 77 |
"execution_role_ready": False,
|
| 78 |
+
"studio_identity_configured": identity_configured,
|
| 79 |
+
},
|
| 80 |
+
)
|
| 81 |
+
if not identity_configured:
|
| 82 |
+
return JSONResponse(
|
| 83 |
+
status_code=503,
|
| 84 |
+
content={
|
| 85 |
+
"status": "not_ready",
|
| 86 |
+
"database": "connected",
|
| 87 |
+
"schema_ready": True,
|
| 88 |
+
"execution_role_ready": True,
|
| 89 |
+
"studio_identity_configured": False,
|
| 90 |
},
|
| 91 |
)
|
| 92 |
return JSONResponse(
|
|
|
|
| 96 |
"database": "connected",
|
| 97 |
"schema_ready": True,
|
| 98 |
"execution_role_ready": True,
|
| 99 |
+
"studio_identity_configured": True,
|
| 100 |
},
|
| 101 |
)
|
| 102 |
|