Skip to content

Commit e428da5

Browse files
Andrey Cheptsovclaude
andcommitted
Reject dstack access combined with inactivity_duration
The persistent server connection counts as SSH activity, so a dev environment with both dstack access and inactivity_duration would never be detected as inactive. Reject the combination at configuration time instead of silently breaking inactivity_duration. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent e45abbf commit e428da5

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,13 @@ def validate_entrypoint(cls, v: Optional[str]) -> Optional[str]:
786786
raise ValueError("entrypoint is not supported for dev-environment")
787787
return v
788788

789+
@root_validator
790+
def validate_dstack_and_inactivity_duration(cls, values):
791+
if values.get("dstack") and values.get("inactivity_duration") is not None:
792+
# The persistent server connection counts as activity, so inactivity is never detected
793+
raise ValueError("`dstack` is not supported together with `inactivity_duration`")
794+
return values
795+
789796

790797
class TaskConfigurationParams(CoreModel):
791798
nodes: Annotated[int, Field(description="Number of nodes", ge=1)] = 1

src/tests/_internal/core/models/test_configurations.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ def test_server_access_not_supported_for_service(self):
3737
}
3838
)
3939

40+
def test_server_access_not_supported_with_inactivity_duration(self):
41+
with pytest.raises(ConfigurationError, match="inactivity_duration"):
42+
parse_run_configuration(
43+
{
44+
"type": "dev-environment",
45+
"dstack": True,
46+
"inactivity_duration": "1h",
47+
}
48+
)
49+
50+
def test_server_access_and_inactivity_duration_allowed_separately(self):
51+
parse_run_configuration({"type": "dev-environment", "dstack": True})
52+
parse_run_configuration({"type": "dev-environment", "inactivity_duration": "1h"})
53+
4054
def test_server_access_allows_unresolved_passthrough_env(self):
4155
parsed = parse_run_configuration(
4256
{

0 commit comments

Comments
 (0)