fix(ops): classify hostedtoolcache ci load [metadata-only]
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Failing after 1m56s
CD Pipeline / build-and-deploy (push) Has been skipped
CD Pipeline / post-deploy-checks (push) Has been skipped

This commit is contained in:
Your Name
2026-07-02 00:33:42 +08:00
parent 695e887e68
commit c7241365eb
6 changed files with 91 additions and 5 deletions

View File

@@ -83,7 +83,8 @@ DEFAULT_RULES = (
GITEA_ACTION_PROCESS_RE = re.compile(
r"(/\.cache/act/|/home/wooo/\.cache/act/|\bdocker build\b|\bdocker-buildx\b|"
r"\bbuildx build\b|\bpnpm turbo build\b|\bturbo build\b|\bnext build\b)"
r"/opt/hostedtoolcache/|\bbuildx build\b|\bpnpm turbo build\b|\bturbo build\b|"
r"\bnext build\b|\bpnpm install\b|\bnpm ci\b|\byarn install\b)"
)
HOST_PRESSURE_GATE_RE = re.compile(r"wait-host-web-build-pressure\.sh|awoooi-wait-host-web-build-pressure\.sh")

View File

@@ -175,7 +175,15 @@ def parse_ps_text(text: str) -> list[dict[str, Any]]:
def classify_process_family(comm: str, args: str) -> str:
text = f"{comm} {args}".lower()
if "act_runner" in text or "gitea-actions-task" in text or "/.cache/act/" in text:
if (
"act_runner" in text
or "gitea-actions-task" in text
or "/.cache/act/" in text
or "/opt/hostedtoolcache/" in text
or "pnpm install" in text
or "npm ci" in text
or "yarn install" in text
):
return "gitea_actions_runner"
if "docker build" in text or "buildx" in text or "buildkit" in text:
return "docker_build"

View File

@@ -135,6 +135,7 @@ def test_counts_buildkit_runner_process_load() -> None:
102 101 100 100 239 2.0 S docker-buildx /home/wooo/.docker/cli-plugins/docker-buildx buildx build -f apps/web/Dockerfile .
200 150 200 200 210 12.5 S turbo turbo build --filter=@awoooi/web --concurrency=1
201 200 200 200 200 145.0 S node node /app/apps/web/node_modules/.bin/../next/dist/bin/next build
250 150 250 250 30 269.0 R node node /opt/hostedtoolcache/node/20.20.2/x64/bin/pnpm install --frozen-lockfile
300 1 300 300 9999 0.1 S act_runner act_runner daemon --config /config.yaml
400 1 400 400 120 30.0 S node node apps/web/server.js
"""
@@ -142,12 +143,41 @@ def test_counts_buildkit_runner_process_load() -> None:
load = exporter.active_gitea_action_process_load(rows)
assert load.group_count == 2
assert load.process_count == 5
assert load.cpu_percent == 160.5
assert load.group_count == 3
assert load.process_count == 6
assert load.cpu_percent == 429.5
assert load.oldest_age_seconds == 240
def test_sustained_load_evidence_classifies_hostedtoolcache_pnpm_as_ci(tmp_path: Path) -> None:
ps_file = tmp_path / "ps.txt"
ps_file.write_text(
"250 150 250 30 269.0 0.7 node node /opt/hostedtoolcache/node/20.20.2/x64/bin/pnpm install --frozen-lockfile\n",
encoding="utf-8",
)
result = subprocess.run(
[
sys.executable,
str(EVIDENCE_PATH),
"--host",
"110",
"--ps-file",
str(ps_file),
"--json",
],
check=True,
capture_output=True,
text=True,
)
payload = json.loads(result.stdout)
assert payload["top_process_families"][0]["family"] == "gitea_actions_runner"
assert payload["top_processes_sanitized"][0]["family"] == "gitea_actions_runner"
assert "/opt/hostedtoolcache" not in result.stdout
assert "pnpm install" not in result.stdout
def test_ignores_the_host_pressure_gate_process_group() -> None:
exporter = load_exporter()
rows = exporter.parse_ps_rows(