@@ -1,5 +1,5 @@
11 //! Moves ready tickets onto free slots, one worker thread per running ticket.
2-use crate::{agent, store};
2+use crate::{agent, paths, store};
33 use std::time::Duration;
44
55 const BUSY: [&str; 1] = ["running"];
@@ -12,7 +12,7 @@ pub fn run() -> ! {
1212 }
1313 }
1414 loop {
15- for p in store::projects() {
15+ for p in store::projects().into_iter().filter(|_| image_ready()) {
1616 let tickets = store::tickets(&p.slug);
1717 let busy = tickets.iter().filter(|t| BUSY.contains(&t.state.as_str())).count();
1818 for t in tickets.iter().filter(|t| t.state == "ready").take(p.slots.saturating_sub(busy)) {
@@ -24,3 +24,10 @@ pub fn run() -> ! {
2424 std::thread::sleep(Duration::from_secs(2));
2525 }
2626 }
27+
28+/// The base image is there and not being baked (the bake writes it last, then removes its
29+/// work file). Until then tickets wait as ready.
30+fn image_ready() -> bool {
31+ let base = paths::base_image();
32+ base.exists() && !base.with_extension("baking.qcow2").exists()
33+}