fix(infra): align cold-start limits and retain failure diagnostics

This commit is contained in:
2026-11-20 18:21:37 +03:00
parent 2c7b89bb8e
commit a19e8053a7
4 changed files with 68 additions and 13 deletions
+48 -10
View File
@@ -37,23 +37,32 @@ def save_incomplete():
atexit.register(save_incomplete)
def redact(text, cwd):
directory = cwd / "secrets"
if directory.exists():
for path in directory.iterdir():
if path.is_file():
value = path.read_text().strip()
if len(value) >= 12:
text = text.replace(value, "<secret>")
return (
text.replace(str(cwd), "<clean-clone>")
.replace(str(ROOT), "<repository>")
.replace(str(Path.home()), "<home>")
)
def run(args, *, cwd, env, expected=0):
print("CHECK: " + redact(" ".join(args[:3]), cwd), flush=True)
result = subprocess.run(
args, cwd=cwd, env=env, capture_output=True, text=True
)
def redact(text):
return (
text.replace(str(cwd), "<clean-clone>")
.replace(str(ROOT), "<repository>")
.replace(str(Path.home()), "<home>")
)
if result.returncode != expected:
if "receipt" in PROGRESS:
PROGRESS["receipt"]["failed_action"] = redact(" ".join(args))
raise RuntimeError(redact(result.stdout + result.stderr))
return redact(result.stdout.strip())
PROGRESS["receipt"]["failed_action"] = redact(" ".join(args), cwd)
raise RuntimeError(redact(result.stdout + result.stderr, cwd))
return redact(result.stdout.strip(), cwd)
def main():
@@ -267,6 +276,35 @@ def main():
["git", "fsck", "--full"], cwd=clone, env=env
)
receipt["checks_completed"] = True
except BaseException:
receipt["failure_diagnostics"] = {}
for label, arguments in [
("services", ["ps", "-a", "--format", "json"]),
(
"logs",
[
"logs",
"--no-color",
"--tail",
"60",
"api",
"s3",
"migrate",
"cache",
],
),
]:
diagnostic = subprocess.run(
["docker", "compose", *arguments],
cwd=clone,
env=env,
capture_output=True,
text=True,
)
receipt["failure_diagnostics"][label] = redact(
diagnostic.stdout + diagnostic.stderr, clone
)
raise
finally:
assert project.startswith("mtusi-lab6-clean-")
run(