Skip to content

Commit 8da0f7b

Browse files
committed
feat: cleanup stale task containers at validator startup
When the validator worker starts, it now cleans up any orphaned task containers from previous runs. This prevents container accumulation after crashes or restarts. Uses the container backend's cleanup() method which filters containers by the challenge_id label.
1 parent ca40138 commit 8da0f7b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/validator_worker.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,23 @@ impl ValidatorWorker {
8989
.await
9090
.context("Failed to create container backend")?;
9191

92+
// Cleanup stale task containers from previous runs
93+
// This prevents orphaned containers from accumulating after crashes/restarts
94+
match container_backend.cleanup(&challenge_id).await {
95+
Ok(count) => {
96+
if count > 0 {
97+
info!(
98+
"Cleaned up {} stale task containers from previous runs",
99+
count
100+
);
101+
}
102+
}
103+
Err(e) => {
104+
warn!("Failed to cleanup stale containers at startup: {}", e);
105+
// Continue anyway - stale containers are not fatal
106+
}
107+
}
108+
92109
Ok(Self {
93110
platform_url,
94111
challenge_id,

0 commit comments

Comments
 (0)