Skip to content

[scheduler] Allow jobs without an OS constraint to dispatch#2246

Open
officialasishkumar wants to merge 1 commit intoAcademySoftwareFoundation:masterfrom
officialasishkumar:fix/scheduler-optional-layer-os
Open

[scheduler] Allow jobs without an OS constraint to dispatch#2246
officialasishkumar wants to merge 1 commit intoAcademySoftwareFoundation:masterfrom
officialasishkumar:fix/scheduler-optional-layer-os

Conversation

@officialasishkumar
Copy link
Copy Markdown

@officialasishkumar officialasishkumar commented Apr 4, 2026

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

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.

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Apr 4, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: officialasishkumar / name: Asish Kumar (9f741d6)

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 4, 2026

📝 Walkthrough

Walkthrough

This change fixes a bug where layer OS became unintentionally mandatory. A new helper method host_matches_layer_os() was introduced to properly handle unset OS filters, allowing jobs without explicit OS specification to match any host. The existing validation logic was refactored to use this helper while preserving behavior for explicitly set OS values.

Changes

Cohort / File(s) Summary
OS Matching Logic
rust/crates/scheduler/src/pipeline/matcher.rs
Extracted OS compatibility check into host_matches_layer_os() helper that treats unset OS (is_none()) as matching any host, fixing bug where OS was incorrectly treated as mandatory. Added three unit tests covering unset, matching, and mismatched OS cases.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 When OS is left unset, a rabbit knows—
No need to match if filters don't propose!
With host_matches_layer_os() so neat,
Any host will do, the task complete! 🌱

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: allowing jobs without OS constraints to dispatch, which directly addresses the core issue fixed in this PR.
Linked Issues check ✅ Passed The PR fully addresses issue #2172 by implementing the exact fix suggested: using host_matches_layer_os() helper to check os.is_some() before applying OS compatibility filtering.
Out of Scope Changes check ✅ Passed All changes are within scope: the helper method, updated validation logic, and regression tests directly address the OS constraint bug without introducing unrelated modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@officialasishkumar officialasishkumar marked this pull request as ready for review April 4, 2026 10:14
Copilot AI review requested due to automatic review settings April 4, 2026 10:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
rust/crates/scheduler/src/pipeline/matcher.rs (1)

517-557: Add host-OS-None edge-case coverage for completeness.

Current tests validate the regression well, but adding explicit checks for host.str_os == None would 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

📥 Commits

Reviewing files that changed from the base of the PR and between 487a92b and 9f741d6.

📒 Files selected for processing (1)
  • rust/crates/scheduler/src/pipeline/matcher.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scheduler] Layer os became mandatory

2 participants