Prune old job executions
All checks were successful
buildbot/nix-eval Build done.
buildbot/nix-build Build done.
buildbot/nix-effects Build done.

This commit is contained in:
Abel Luck 2026-06-02 11:31:39 +02:00
parent 813f19f355
commit 710ac76192
6 changed files with 552 additions and 11 deletions

View file

@ -50,6 +50,16 @@ class JobArtifacts:
stats_path=log_dir / f"{prefix}.jsonl",
)
def existing_paths(self) -> tuple[Path, ...]:
prefix = self.log_path.with_suffix("").name
return tuple(
sorted(
path
for path in self.log_path.parent.glob(f"{prefix}.*")
if path.is_file()
)
)
@dataclass
class RunningWorker:
@ -793,8 +803,12 @@ def clear_completed_executions(*, log_dir: str | Path) -> int:
for execution in completed_executions:
job = cast(Job, execution.job)
prefix = f"job-{_job_id(job)}-execution-{_execution_id(execution)}"
for artifact_path in resolved_log_dir.glob(f"{prefix}.*"):
artifacts = JobArtifacts.for_execution(
log_dir=resolved_log_dir,
job_id=_job_id(job),
execution_id=_execution_id(execution),
)
for artifact_path in artifacts.existing_paths():
artifact_path.unlink(missing_ok=True)
execution_ids = tuple(