Skip to content

Use unique names for cloud resources #2341

@r4victor

Description

@r4victor

Currently, dstack uses names for cloud resource that are deterministically inferred from dstack resource names. For example, a job my-run-0 in project my-project creates instance named my-project-my-run-0. This is a major problem for backends where names must be unique (e.g. Azure, GCP). It can lead to a dstack resource failing to re-submit/re-create if the previous version of the resource is not yet deleted in the cloud (bugs like #1774). The proposal is to introduce a new approach to naming cloud resources to mitigate this class of problems.

For backends with tags support, every time dstack creates a cloud resource for a dstack resource (e.g. an instance or a volume), it generates a unique random name like dstack-{random_suffix} and uses it as the cloud resource name. The dstack resource name is added as a tag dstack_name to be able to associate the dstack resource from the cloud.

For backends without tags support, use the current naming approach when possible. Currently, a case is not handled when the dstack name cannot be used in the cloud due to name limitations. In this case, fallback to randomly generated names.

The new approach will solve conflicts problems and also allow us to lift current dstack restriction on resource names (at most 40 chars).

Metadata

Metadata

Assignees

Labels

enhancementA non-feature improvement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions