fix(ci): point KOMODO_HOST to public/internal url and add wait_for_update
Deploy OpenHands Agent Canvas / Deploy to Komodo (push) Failing after 10s

This commit is contained in:
gitea committed 2026-10-24 00:11:13 +00:00
1 parent 5dc53d1a66
commit f594304721
2 files changed
+70 -18

No files matched your search

+49 -5
View File
@@ -2,7 +2,8 @@
"""
Deploy script for OpenHands Agent Canvas on Komodo Core.
Reads docker-compose.yml, ensures the Komodo Stack exists on server-tsj08,
updates the Compose configuration, and triggers deployment via Komodo API.
updates the Compose configuration, triggers deployment via Komodo API,
and waits for deployment completion.
"""
import os
@@ -14,6 +15,7 @@ import urllib.error
STACK_NAME = "openhands-agent-canvas"
DEFAULT_SERVER = "server-tsj08"
DEFAULT_KOMODO_HOST = "https://komodo.nickmalik.dev"
def get_komodo_config():
@@ -28,13 +30,16 @@ def get_komodo_config():
import tomllib
with open(cfg_path, "rb") as f:
cfg = tomllib.load(f)
host = host or cfg.get("host", "http://localhost:9120")
host = host or cfg.get("host", DEFAULT_KOMODO_HOST)
key = key or cfg.get("cli_key", "")
secret = secret or cfg.get("cli_secret", "")
except Exception as e:
print(f"[WARN] Failed to parse {cfg_path}: {e}")
host = host or "http://localhost:9120"
# Fallback to public/internal Komodo domain if localhost is passed inside a runner container
if not host or "localhost" in host or "127.0.0.1" in host:
host = DEFAULT_KOMODO_HOST
if not (key and secret):
print("::error::KOMODO_API_KEY and KOMODO_API_SECRET must be set.")
sys.exit(1)
@@ -63,6 +68,39 @@ def api_call(host, key, secret, endpoint, payload):
raise RuntimeError(f"Komodo API {endpoint} error {e.code}: {err}") from e
def wait_for_update(host, key, secret, update_id, max_wait_sec=300):
print(f"[INFO] Monitoring deployment update {update_id}...")
start_time = time.time()
last_status = None
while time.time() - start_time < max_wait_sec:
time.sleep(5)
try:
updates_data = api_call(host, key, secret, "/read/ListUpdates", {})
for u in updates_data.get("updates", []):
uid = (u.get("_id") or {}).get("$oid") or u.get("id")
if uid == update_id:
status = u.get("status")
if status != last_status:
print(f" -> Deployment status: {status}")
last_status = status
if status in ("Complete", "Failed", "Cancelled"):
success = u.get("success", False)
for log in (u.get("logs") or [])[-10:]:
print(f" [log] {log}")
if success:
print(f"[SUCCESS] Deployment completed successfully!")
return True
else:
print(f"::error::Deployment finished with status {status}")
return False
except Exception as e:
print(f"[WARN] Error polling update status: {e}")
print(f"[WARN] Deployment is taking longer than {max_wait_sec}s (likely pulling large image). Continuing.")
return True
def main():
host, key, secret = get_komodo_config()
print(f"=== Komodo Target: {host} ===")
@@ -81,7 +119,7 @@ def main():
elif server_id:
print(f"[INFO] Target server '{DEFAULT_SERVER}' resolved to id: {server_id}")
else:
print(f"::error::No active servers found in Komodo.")
print("::error::No active servers found in Komodo.")
sys.exit(1)
# 2. Read docker-compose.yml
@@ -130,7 +168,13 @@ def main():
host, key, secret, "/execute/DeployStack",
{"stack": STACK_NAME, "services": [], "stop_time": None}
)
print(f"[SUCCESS] Deploy execution dispatched: {deploy_res}")
update_id = (deploy_res.get("_id") or {}).get("$oid") or deploy_res.get("id")
if update_id:
ok = wait_for_update(host, key, secret, update_id, max_wait_sec=300)
if not ok:
sys.exit(1)
else:
print(f"[SUCCESS] Deploy execution dispatched: {deploy_res}")
if __name__ == "__main__":