Add instances option to target specific fleet instances#3925
Open
fededagos wants to merge 5 commits into
Open
Conversation
Introduce an `instances` run profile option that pins a run to specific existing fleet instances (nodes). Each value matches an instance by its name (e.g. `my-fleet-0`) or by its hostname/IP address. When set, `filter_instances` keeps only matching instances and the job assignment phase never provisions new capacity to satisfy a node selector, terminating with a no-capacity error instead.
Reject runs that target fewer instances than the number of nodes they require, surfaced during planning via `validate_run_spec_and_set_defaults`. Exclude new-capacity backend offers from the run plan when `instances` is set, since they are never provisioned and would otherwise mislead the `dstack apply`/`dstack offer` output.
Add a 'Targeting specific instances' section to the shared fleets snippet (dev environments, tasks, services) and a corresponding tip in the protips guide.
Handle an explicit empty `instances` list consistently across the assignment gate, plan output, and instance filtering by checking `is not None` instead of truthiness, so an empty list targets existing instances only (rather than silently allowing new-capacity provisioning and showing unusable offers). Add regression tests ensuring the instance selector is applied on the multinode and shared-instances filter paths.
instances option to target specific fleet nodes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an
instancesoption to run configurations (dev environments, tasks, services) that restricts a run to specific existing fleet instances.Syntax
Long forms:
Short form for matching by instance name:
The
fleetform also supports<project name>/<fleet name>for fleets from another project.Behavior
instanceshas allow-list semantics: a run is placed only on a matching existing instance.instancesis set,dstacknever provisions new instances to satisfy the run.retrycan be used to wait for a selected busy instance to free up.instancesis set because they cannot satisfy the selector.Implementation
ProfileParams:name,hostname, andfleet+instance, while preserving the string shorthand as an instance-name selector.instancesfor older client/server compatibility paths.Docs
Updated the shared fleet-management snippet and protips guide. The docs promote the explicit syntax first and keep the short instance-name syntax in a collapsible section.
Testing
uv run ruff check .uv run pyright -p .uv run pytest—2607 passed, 1055 skippeddstack server:fleetsplus all fourinstancessyntaxes completed successfully.instancessyntaxes completed successfully.AI Assistance
This PR includes AI-assisted changes. The original PR noted Claude Code assistance; follow-up schema, implementation review, tests, docs, and E2E verification were assisted by Codex.