Skip to content

Commit 8d306ac

Browse files
[scheduler] Allow jobs without an OS constraint to dispatch (#2246)
## Related Issues Fixes #2172 ## Summarize your change. Jobs that do not set a layer or job OS were being rejected by the Rust scheduler because the matcher compared every host OS against `None` literally. This change only applies the OS filter when an OS constraint is present, so jobs launched without `OL_OS` or an explicit `os` continue to dispatch normally. It also adds matcher regression tests covering unset, matching, and mismatched OS constraints. ## Validation - `cargo test -p scheduler pipeline::matcher::tests -- --nocapture` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Added unit tests validating OS compatibility matching in the scheduler to ensure hosts are correctly assigned to layers based on their operating system. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Diego Tavares <dtavares@imageworks.com>
1 parent a94e690 commit 8d306ac

1 file changed

Lines changed: 57 additions & 1 deletion

File tree

rust/crates/scheduler/src/pipeline/matcher.rs

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ impl MatchingService {
185185
}
186186
}
187187

188+
fn host_matches_layer_os(host: &Host, os: Option<&str>) -> bool {
189+
os.is_none() || host.str_os.as_deref() == os
190+
}
191+
188192
/// Validates whether a host is suitable for a specific layer.
189193
///
190194
/// Subscriptions: Check whether this hosts' subscription can book at least one frame
@@ -206,7 +210,7 @@ impl MatchingService {
206210
os: Option<&str>,
207211
) -> bool {
208212
// Check OS compatibility
209-
if host.str_os.as_deref() != os {
213+
if !Self::host_matches_layer_os(host, os) {
210214
return false;
211215
}
212216

@@ -500,3 +504,55 @@ impl MatchingService {
500504
}
501505
}
502506
}
507+
508+
#[cfg(test)]
509+
mod tests {
510+
use bytesize::ByteSize;
511+
use opencue_proto::host::ThreadMode;
512+
use uuid::Uuid;
513+
514+
use super::MatchingService;
515+
use crate::models::{CoreSize, Host};
516+
517+
fn host_with_os(str_os: Option<&str>) -> Host {
518+
Host::new_for_test(
519+
Uuid::new_v4(),
520+
"test-host".to_string(),
521+
str_os.map(str::to_string),
522+
CoreSize::from_multiplied(100),
523+
ByteSize::gb(64),
524+
CoreSize::from_multiplied(100),
525+
ByteSize::gb(64),
526+
0,
527+
ByteSize::gb(0),
528+
ThreadMode::Variable,
529+
CoreSize::from_multiplied(100),
530+
Uuid::new_v4(),
531+
"test-alloc".to_string(),
532+
)
533+
}
534+
535+
#[test]
536+
fn host_matches_when_layer_os_is_not_set() {
537+
let host = host_with_os(Some("Linux"));
538+
539+
assert!(MatchingService::host_matches_layer_os(&host, None));
540+
}
541+
542+
#[test]
543+
fn host_matches_when_layer_os_matches_host_os() {
544+
let host = host_with_os(Some("Linux"));
545+
546+
assert!(MatchingService::host_matches_layer_os(&host, Some("Linux")));
547+
}
548+
549+
#[test]
550+
fn host_does_not_match_when_layer_os_differs_from_host_os() {
551+
let host = host_with_os(Some("Linux"));
552+
553+
assert!(!MatchingService::host_matches_layer_os(
554+
&host,
555+
Some("Windows")
556+
));
557+
}
558+
}

0 commit comments

Comments
 (0)