[scheduler] Allow jobs without an OS constraint to dispatch#2246
Conversation
|
|
📝 WalkthroughWalkthroughThis change fixes a bug where layer OS became unintentionally mandatory. A new helper method Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
rust/crates/scheduler/src/pipeline/matcher.rs (1)
517-557: Add host-OS-Noneedge-case coverage for completeness.Current tests validate the regression well, but adding explicit checks for
host.str_os == Nonewould harden this matcher against incomplete host metadata.Proposed test additions
#[test] fn host_matches_when_layer_os_is_not_set() { let host = host_with_os(Some("Linux")); assert!(MatchingService::host_matches_layer_os(&host, None)); } +#[test] +fn host_matches_when_both_layer_and_host_os_are_not_set() { + let host = host_with_os(None); + + assert!(MatchingService::host_matches_layer_os(&host, None)); +} + #[test] fn host_matches_when_layer_os_matches_host_os() { let host = host_with_os(Some("Linux")); assert!(MatchingService::host_matches_layer_os(&host, Some("Linux"))); } #[test] fn host_does_not_match_when_layer_os_differs_from_host_os() { let host = host_with_os(Some("Linux")); assert!(!MatchingService::host_matches_layer_os( &host, Some("Windows") )); } + +#[test] +fn host_does_not_match_when_layer_os_is_set_but_host_os_is_not_set() { + let host = host_with_os(None); + + assert!(!MatchingService::host_matches_layer_os(&host, Some("Linux"))); +}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@rust/crates/scheduler/src/pipeline/matcher.rs` around lines 517 - 557, Add tests that cover the host.str_os == None case: use the existing helper host_with_os (call with None) and assert MatchingService::host_matches_layer_os(&host, None) returns true and assert MatchingService::host_matches_layer_os(&host, Some("Linux")) and Some("Windows") behave as expected (true/false) to ensure the matcher handles missing host OS metadata; add these new test functions alongside the existing tests to harden the matcher against incomplete host metadata.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@rust/crates/scheduler/src/pipeline/matcher.rs`:
- Around line 517-557: Add tests that cover the host.str_os == None case: use
the existing helper host_with_os (call with None) and assert
MatchingService::host_matches_layer_os(&host, None) returns true and assert
MatchingService::host_matches_layer_os(&host, Some("Linux")) and Some("Windows")
behave as expected (true/false) to ensure the matcher handles missing host OS
metadata; add these new test functions alongside the existing tests to harden
the matcher against incomplete host metadata.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ee4e844c-829c-43d5-b373-e4cdf43ee599
📒 Files selected for processing (1)
rust/crates/scheduler/src/pipeline/matcher.rs
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
Noneliterally. This change only applies the OS filter when an OS constraint is present, so jobs launched withoutOL_OSor an explicitoscontinue to dispatch normally.It also adds matcher regression tests covering unset, matching, and mismatched OS constraints.
Validation
cargo test -p scheduler pipeline::matcher::tests -- --nocaptureSummary by CodeRabbit