Skip to content

Commit f356dc4

Browse files
Bihan  RanaBihan  Rana
authored andcommitted
Fix 500 server error when re-applying replica groups service
1 parent ff712e0 commit f356dc4

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/dstack/_internal/core/models/configurations.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ def validate_scaling(cls, values):
987987
@root_validator()
988988
def validate_top_level_properties_with_replica_groups(cls, values):
989989
"""
990-
When replicas is a list of ReplicaGroup, forbid top-level scaling, commands, and resources
990+
When replicas is a list of ReplicaGroup, forbid top-level scaling and commands.
991991
"""
992992
replicas = values.get("replicas")
993993

@@ -1008,15 +1008,6 @@ def validate_top_level_properties_with_replica_groups(cls, values):
10081008
"Specify `commands` in each replica group instead."
10091009
)
10101010

1011-
resources = values.get("resources")
1012-
1013-
default_resources = ResourcesSpec()
1014-
if resources and resources.dict() != default_resources.dict():
1015-
raise ValueError(
1016-
"Top-level `resources` is not allowed when `replicas` is a list. "
1017-
"Specify `resources` in each replica group instead."
1018-
)
1019-
10201011
return values
10211012

10221013
@root_validator()

src/dstack/_internal/server/services/runs/spec.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
ServiceConfiguration,
66
)
77
from dstack._internal.core.models.repos.virtual import DEFAULT_VIRTUAL_REPO_ID, VirtualRunRepoData
8+
from dstack._internal.core.models.resources import ResourcesSpec
89
from dstack._internal.core.models.runs import LEGACY_REPO_DIR, AnyRunConfiguration, RunSpec
910
from dstack._internal.core.models.volumes import InstanceMountPoint
1011
from dstack._internal.core.services import validate_dstack_resource_name
@@ -112,6 +113,16 @@ def validate_run_spec_and_set_defaults(
112113
raise ServerClientError(
113114
f"Probe timeout cannot be longer than {settings.MAX_PROBE_TIMEOUT}s"
114115
)
116+
if isinstance(run_spec.configuration.replicas, list):
117+
default_resources = ResourcesSpec()
118+
if (
119+
run_spec.configuration.resources
120+
and run_spec.configuration.resources.dict() != default_resources.dict()
121+
):
122+
raise ServerClientError(
123+
"Top-level `resources` is not allowed when `replicas` is a list. "
124+
"Specify `resources` in each replica group instead."
125+
)
115126
if run_spec.configuration.priority is None:
116127
run_spec.configuration.priority = RUN_PRIORITY_DEFAULT
117128
set_resources_defaults(run_spec.configuration.resources)

0 commit comments

Comments
 (0)