Add credential-free cloud build diagnostic
This commit is contained in:
24
app.py
Normal file
24
app.py
Normal file
@@ -0,0 +1,24 @@
|
||||
"""Credential-free probe for the owner's ModelHub cloud deployment."""
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
import json
|
||||
import os
|
||||
|
||||
metadata = {"name": "xc-cloud-build-probe", "version": "probe-20261026-01",
|
||||
"strategyIdPresent": bool(os.environ.get("STRATEGY_ID")),
|
||||
"credentialEnvironmentNames": sorted(name for name in os.environ
|
||||
if any(marker in name for marker in ("TOKEN", "AUTH", "CREDENTIAL", "SECRET", "API_KEY")))}
|
||||
print(json.dumps(metadata), flush=True)
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
data = {"status": "ok"} if self.path.split("?", 1)[0] == "/health" else metadata
|
||||
payload = json.dumps(data).encode()
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.send_header("Content-Length", str(len(payload)))
|
||||
self.end_headers()
|
||||
self.wfile.write(payload)
|
||||
|
||||
|
||||
ThreadingHTTPServer(("0.0.0.0", 8080), Handler).serve_forever()
|
||||
Reference in New Issue
Block a user