Move CI runners to Droplet and enable application HTTPS
vpn-dns-gateway/pipeline/pr-main This commit looks good
vpn-dns-gateway/pipeline/pr-main This commit looks good
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
"""Read-only, non-secret runtime checks; run as root on The-Ocean."""
|
||||
import json
|
||||
import subprocess
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def run(*args):
|
||||
return subprocess.check_output(args, text=True).strip()
|
||||
|
||||
|
||||
report = {"observed_at": datetime.now(timezone.utc).isoformat(), "containers": []}
|
||||
names = ["ssw590-delivery-agent-1", "buildx_buildkit_ssw590-delivery-limited0"]
|
||||
for name in names:
|
||||
info = json.loads(run("docker", "inspect", name))[0]
|
||||
config, state = info["HostConfig"], info["State"]
|
||||
events = Path("/sys/fs/cgroup/system.slice", "docker-" + info["Id"] + ".scope", "memory.events")
|
||||
report["containers"].append({
|
||||
"name": name, "running": state["Running"], "oom_killed": state["OOMKilled"],
|
||||
"restart_count": info["RestartCount"], "restart_policy": config["RestartPolicy"]["Name"],
|
||||
"memory_bytes": config["Memory"], "memory_swap_bytes": config["MemorySwap"],
|
||||
"nano_cpus": config["NanoCpus"], "cpu_quota": config["CpuQuota"],
|
||||
"cpu_period": config["CpuPeriod"], "port_bindings": config["PortBindings"],
|
||||
"memory_events": events.read_text().strip() if events.exists() else "unavailable",
|
||||
})
|
||||
assert state["Running"] and not state["OOMKilled"], name
|
||||
report["private_http"] = {}
|
||||
for url in ["http://jenkins:8080/login", "http://gitea:3000/", "http://monitoring-grafana-1:3000/login"]:
|
||||
code = run("docker", "exec", names[0], "curl", "--silent", "--show-error", "--max-time", "15",
|
||||
"-o", "/dev/null", "-w", "%{http_code}", url)
|
||||
report["private_http"][url] = code
|
||||
assert code == "200", (url, code)
|
||||
ssh = run("docker", "exec", names[0], "ssh", "-G", "147.182.178.136")
|
||||
report["deployment_ssh_route"] = [line for line in ssh.splitlines() if line.startswith(("hostname ", "hostkeyalias "))]
|
||||
assert "hostname host.docker.internal" in ssh.splitlines()
|
||||
assert "hostkeyalias 147.182.178.136" in ssh.splitlines()
|
||||
report["memory"] = run("free", "-m")
|
||||
report["disk"] = run("df", "-h", "/")
|
||||
report["running_containers"] = run("docker", "ps", "--format", "{{.Names}} {{.Status}}")
|
||||
report["result"] = "passed"
|
||||
print(json.dumps(report, indent=2))
|
||||
Reference in New Issue
Block a user