Skip to content

Support targeting specific instances#3958

Open
peterschmidt85 wants to merge 1 commit into
masterfrom
codex/target-instances-clean
Open

Support targeting specific instances#3958
peterschmidt85 wants to merge 1 commit into
masterfrom
codex/target-instances-clean

Conversation

@peterschmidt85

Copy link
Copy Markdown
Contributor

Summary

Adds a strict instances schema for runs so users can target existing fleet instances explicitly:

  • short form: instances: [my-fleet-1]
  • by name: instances: [{name: my-fleet-1}]
  • by hostname: instances: [{hostname: worker-1}]
  • by fleet instance number: instances: [{fleet: my-fleet, instance: 1}], including project/fleet

Compared to #3925, this PR keeps the normal fleet selection path mostly unchanged. The new selector resolution and targeted reusable-instance assignment path is used only when instances is set; missing targets fail without provisioning new capacity.

Testing

Automated:

  • uv run --no-sync pytest src/tests/_internal/core/models/test_profiles.py src/tests/_internal/server/services/test_instances.py src/tests/_internal/server/services/runs/test_plan.py src/tests/_internal/server/background/pipeline_tasks/test_submitted_jobs.py -q (100 passed, 77 skipped)
  • uv run --no-sync ruff check ...
  • uv run --no-sync pyright -p .
  • git diff --check

E2E:

  • Backend AWS fleet with two t2.small instances:
    • normal run without instances
    • short-form targeted instance
    • missing target leaves the fleet at two idle instances and does not provision
  • SSH fleet backed by two EC2 instances in one VPC/security group using the dstack AMI:
    • normal run
    • target by name
    • target by hostname using a service
    • target by {fleet, instance}
    • missing target fails without occupying instances
    • multinode negative: one selected physical instance is not enough
    • multinode positive: two selected physical instances both run one node

All E2E AWS resources were cleaned up after verification.

AI Assistance: implemented and tested with Codex.

@peterschmidt85 peterschmidt85 requested a review from jvstme June 11, 2026 16:05
@peterschmidt85 peterschmidt85 force-pushed the codex/target-instances-clean branch 2 times, most recently from cc1de31 to b6c0de7 Compare June 12, 2026 07:46
Comment thread src/dstack/_internal/core/models/profiles.py
Comment thread src/dstack/_internal/core/models/profiles.py Outdated
Comment thread src/dstack/_internal/server/services/runs/plan.py Outdated
Comment thread src/dstack/_internal/server/services/instances.py Outdated
Comment thread src/dstack/_internal/server/services/instances.py Outdated
Comment thread src/dstack/_internal/server/services/instances.py
Comment thread src/dstack/_internal/server/services/instances.py Outdated
Comment thread src/dstack/_internal/server/services/runs/plan.py Outdated
@peterschmidt85 peterschmidt85 force-pushed the codex/target-instances-clean branch from b6c0de7 to 3258c39 Compare June 12, 2026 13:29
jvstme

This comment was marked as resolved.

@peterschmidt85 peterschmidt85 force-pushed the codex/target-instances-clean branch from 3258c39 to 556c94e Compare June 12, 2026 13:58
Co-authored-by: Federico D'Agostino <fede.dagos@gmail.com>
@peterschmidt85 peterschmidt85 force-pushed the codex/target-instances-clean branch from 556c94e to c1d9fa9 Compare June 12, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants