Skip to content

Commit c1db0ed

Browse files
committed
feat(orchestrator): use Docker named volume for persistent challenge data
- Replace /tmp host path with named Docker volume - Volume name: {container_name}-data (includes validator suffix) - Data persists across container restarts/recreations - Each validator has isolated data
1 parent 52fb82b commit c1db0ed

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

crates/challenge-orchestrator/src/docker.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,19 @@ impl DockerClient {
301301
}]),
302302
);
303303

304-
// Create persistent data directory for challenge state (survives restarts)
305-
let challenge_data_dir = format!("/tmp/platform-challenges/{}/data", container_name);
306-
if let Err(e) = std::fs::create_dir_all(&challenge_data_dir) {
307-
warn!(
308-
"Failed to create challenge data dir {}: {}",
309-
challenge_data_dir, e
310-
);
304+
// Create named Docker volume for persistent challenge data (survives container recreation)
305+
// Use container_name (includes validator suffix) so each validator has its own data
306+
let volume_name = format!("{}-data", container_name);
307+
308+
// Create volume if it doesn't exist (Docker will auto-create on mount, but explicit is clearer)
309+
let volume_opts = bollard::volume::CreateVolumeOptions {
310+
name: volume_name.as_str(),
311+
driver: "local",
312+
..Default::default()
313+
};
314+
if let Err(e) = self.docker.create_volume(volume_opts).await {
315+
// Volume might already exist, which is fine
316+
debug!("Volume creation result for {}: {:?}", volume_name, e);
311317
}
312318

313319
// Build host config with resource limits
@@ -318,12 +324,12 @@ impl DockerClient {
318324
memory: Some((config.memory_mb * 1024 * 1024) as i64),
319325
// Mount Docker socket for challenge containers to run agent evaluations
320326
// Mount tasks directory both to internal path AND to host path for Docker-in-Docker
321-
// Mount persistent data directory for challenge state (evaluation progress, etc.)
327+
// Mount persistent Docker volume for challenge state (evaluation progress, etc.)
322328
binds: Some(vec![
323329
"/var/run/docker.sock:/var/run/docker.sock:rw".to_string(),
324330
"/tmp/platform-tasks:/app/data/tasks:rw".to_string(), // Override internal tasks
325331
"/tmp/platform-tasks:/tmp/platform-tasks:rw".to_string(), // For DinD path mapping
326-
format!("{}:/data:rw", challenge_data_dir), // Persistent challenge state
332+
format!("{}:/data:rw", volume_name), // Named volume for persistent state
327333
]),
328334
..Default::default()
329335
};

0 commit comments

Comments
 (0)