record building partitions to enable more accurate want state setting
Some checks failed
/ setup (push) Has been cancelled
Some checks failed
/ setup (push) Has been cancelled
This commit is contained in:
parent
b978be53f5
commit
7846cd6b86
1 changed files with 23 additions and 3 deletions
|
|
@ -1151,10 +1151,10 @@ impl BuildState {
|
|||
}
|
||||
|
||||
/**
|
||||
Wants are schedulable when their partition is live and not tainted
|
||||
Wants are schedulable when their upstreams are ready and target partitions are not already building
|
||||
*/
|
||||
pub fn want_schedulability(&self, want: &WantDetail) -> WantSchedulability {
|
||||
// Use type-safe partition checks from partitions
|
||||
// Check upstream partition statuses (dependencies)
|
||||
let mut live: Vec<LivePartitionRef> = Vec::new();
|
||||
let mut tainted: Vec<TaintedPartitionRef> = Vec::new();
|
||||
let mut missing: Vec<MissingPartitionRef> = Vec::new();
|
||||
|
|
@ -1178,12 +1178,24 @@ impl BuildState {
|
|||
}
|
||||
}
|
||||
|
||||
// Check target partition statuses (what this want is trying to build)
|
||||
// If any target partition is already Building, this want should wait
|
||||
let mut building: Vec<BuildingPartitionRef> = Vec::new();
|
||||
for target_ref in &want.partitions {
|
||||
if let Some(partition) = self.partitions.get(&target_ref.r#ref) {
|
||||
if let Partition::Building(p) = partition {
|
||||
building.push(p.get_ref());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WantSchedulability {
|
||||
want: want.clone(),
|
||||
status: WantUpstreamStatus {
|
||||
live,
|
||||
tainted,
|
||||
missing,
|
||||
building,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -1206,6 +1218,8 @@ pub struct WantUpstreamStatus {
|
|||
pub live: Vec<LivePartitionRef>,
|
||||
pub tainted: Vec<TaintedPartitionRef>,
|
||||
pub missing: Vec<MissingPartitionRef>,
|
||||
/// Target partitions that are currently being built by another job
|
||||
pub building: Vec<BuildingPartitionRef>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
|
|
@ -1231,7 +1245,13 @@ impl WantsSchedulability {
|
|||
|
||||
impl WantSchedulability {
|
||||
pub fn is_schedulable(&self) -> bool {
|
||||
self.status.missing.is_empty() && self.status.tainted.is_empty()
|
||||
// Want is schedulable if:
|
||||
// - No missing upstream dependencies
|
||||
// - No tainted upstream dependencies
|
||||
// - No target partitions currently being built by another job
|
||||
self.status.missing.is_empty()
|
||||
&& self.status.tainted.is_empty()
|
||||
&& self.status.building.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue