fix(#5): write sandbox meta.json before creating the disk
Until meta existed the sandbox's image looked unreferenced, so a concurrent `wsbx gc` deleted it mid-create; a crashed create was also invisible to ps and refused by rm.
This commit is contained in:
@@ -76,9 +76,10 @@ pub fn run(h: &Path, o: Opts, image: &str, cmd: Vec<String>, extra: &[String], g
|
|||||||
}
|
}
|
||||||
if !disk.exists() {
|
if !disk.exists() {
|
||||||
eprintln!("wsbx: creating sandbox {name}");
|
eprintln!("wsbx: creating sandbox {name}");
|
||||||
create_disk(h, &disk, o.disk)?;
|
// meta first: it marks the image as in use for `wsbx gc` and makes a crashed create visible to ps/rm
|
||||||
meta = json!({"image": image, "digest": img.digest, "workspace": ws, "created": now(), "provisioned": false});
|
meta = json!({"image": image, "digest": img.digest, "workspace": ws, "created": now(), "provisioned": false});
|
||||||
fs::write(&meta_path, serde_json::to_vec_pretty(&meta)?)?;
|
fs::write(&meta_path, serde_json::to_vec_pretty(&meta)?)?;
|
||||||
|
create_disk(h, &disk, o.disk)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the guest-side run script (executed as root by init, then drops to the image user).
|
// Build the guest-side run script (executed as root by init, then drops to the image user).
|
||||||
|
|||||||
Reference in New Issue
Block a user