fix(BA-2788): Missing session type check#6354
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements validation for session types against scaling group configurations. The change ensures that sessions can only be created with session types that are explicitly allowed by the target scaling group's configuration.
- Adds a new
SessionTypeRulevalidator to check if the requested session type is permitted by the scaling group - Integrates the new validation rule into the scheduling controller's validation pipeline
- Includes comprehensive test coverage for both allowed and disallowed session type scenarios
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/ai/backend/manager/sokovan/scheduling_controller/validators/rules.py |
Implements SessionTypeRule validator and adds @override decorators to existing rules |
src/ai/backend/manager/sokovan/scheduling_controller/validators/__init__.py |
Exports the new SessionTypeRule class |
src/ai/backend/manager/sokovan/scheduling_controller/scheduling_controller.py |
Registers SessionTypeRule in the validator pipeline |
tests/manager/sokovan/scheduling_controller/validators/test_rules.py |
Adds test cases for SessionTypeRule and a session spec factory fixture |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
|
|
There was a problem hiding this comment.
The validation doesn't return after finding a matching scaling group. If the session type is allowed, the loop continues unnecessarily and the method doesn't explicitly return. Add an explicit return after line 93, or add a break after line 93 and a return after the loop completes successfully.
| return |
| for sg in allowed_groups: | ||
| if sg.name == spec.scaling_group: | ||
| allowed_session_types = sg.scheduler_opts.allowed_session_types | ||
| if spec.session_type not in allowed_session_types: | ||
| raise InvalidAPIParameters( | ||
| f"Session type {spec.session_type} is not allowed in scaling group {sg.name}" | ||
| ) | ||
|
|
There was a problem hiding this comment.
If the spec's scaling group does not exist in allow list, an error should be raised.
resolves #6352 (BA-2788)
Checklist: (if applicable)
ai.backend.testdocsdirectory