Repository navigation
Description
Steps to reproduce
-
Create an AWS volume named
ownedwithregion: eu-west-1,size: 1GBandauto_cleanup_duration: 1h. -
Run a short task with
volumes: [owned:/data]to initialize its filesystem. Wait for the volume to detach. -
In the same project, register the same EBS volume under a second name. Use the ID from
dstack volume get owned --json.type: volume name: registered backend: aws region: eu-west-1 volume_id: <EBS volume ID>
-
Run a task with
volumes: [registered:/data]and keep it running past the one-hour idle interval forowned.
Actual behaviour
The server emits Volume marked for deletion due to exceeding auto_cleanup_duration for owned while the same EBS volume is attached through registered. The volume worker then calls EC2 DeleteVolume for that EBS ID.
The idle check reads attachments and the last job timestamp from the individual dstack volume record. Activity through registered is invisible to owned.
dstack/src/dstack/_internal/server/background/scheduled_tasks/idle_volumes.py
Lines 66 to 85 in 61eb0f1
| def _should_delete_volume(volume: VolumeModel) -> bool: | |
| if volume.attachments: | |
| return False | |
| config = get_volume_configuration(volume) | |
| if not config.auto_cleanup_duration: | |
| return False | |
| duration_seconds = parse_duration(config.auto_cleanup_duration) | |
| if not duration_seconds or duration_seconds <= 0: | |
| return False | |
| idle_time = _get_idle_time(volume) | |
| threshold = datetime.timedelta(seconds=duration_seconds) | |
| return idle_time > threshold | |
| def _get_idle_time(volume: VolumeModel) -> datetime.timedelta: | |
| last_used = volume.last_job_processed_at or volume.created_at | |
| idle_time = get_current_datetime() - last_used |
Expected behaviour
A job using either registration keeps the underlying volume active. The idle interval starts after its last use through either name.
dstack version
master (61eb0f1dd). Reproduced with SQLite, the dstack volume service and workers, and a mocked EC2 client.
Activity