-
Notifications
You must be signed in to change notification settings - Fork 175
fix(BA-2788): Missing session type check #6354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||
| """Validator rules for session creation.""" | ||||||
|
|
||||||
| from typing import Mapping | ||||||
| from typing import Mapping, override | ||||||
|
|
||||||
| from ai.backend.common.exception import BackendAIError | ||||||
| from ai.backend.common.service_ports import parse_service_ports | ||||||
|
|
@@ -20,9 +20,11 @@ | |||||
| class ContainerLimitRule(SessionValidatorRule): | ||||||
| """Validates cluster size against resource policy limits.""" | ||||||
|
|
||||||
| @override | ||||||
| def name(self) -> str: | ||||||
| return "container_limit" | ||||||
|
|
||||||
| @override | ||||||
| def validate( | ||||||
| self, | ||||||
| spec: SessionCreationSpec, | ||||||
|
|
@@ -39,9 +41,11 @@ def validate( | |||||
| class ScalingGroupAccessRule(SessionValidatorRule): | ||||||
| """Validates that the scaling group is accessible.""" | ||||||
|
|
||||||
| @override | ||||||
| def name(self) -> str: | ||||||
| return "scaling_group_access" | ||||||
|
|
||||||
| @override | ||||||
| def validate( | ||||||
| self, | ||||||
| spec: SessionCreationSpec, | ||||||
|
|
@@ -66,12 +70,37 @@ def validate( | |||||
| raise InvalidAPIParameters(f"Scaling group {spec.scaling_group} is not accessible") | ||||||
|
|
||||||
|
|
||||||
| class SessionTypeRule(SessionValidatorRule): | ||||||
| """Validates session type compatibility with scaling group.""" | ||||||
|
|
||||||
| @override | ||||||
| def name(self) -> str: | ||||||
| return "session_type" | ||||||
|
|
||||||
| @override | ||||||
| def validate( | ||||||
| self, | ||||||
| spec: SessionCreationSpec, | ||||||
| context: SessionCreationContext, | ||||||
| allowed_groups: list[AllowedScalingGroup], | ||||||
| ) -> None: | ||||||
| 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}" | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
|
Comment on lines
+101
to
+102
|
||||||
| return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the spec's scaling group does not exist in allow list, an error should be raised.