Skip to content

Commit ef79345

Browse files
Fix formatting issues
1 parent 84ecf66 commit ef79345

3 files changed

Lines changed: 0 additions & 14 deletions

File tree

src/dstack/_internal/server/background/tasks/process_idle_volumes.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@ async def process_idle_volumes(batch_size: int = 10):
3535
.with_for_update(skip_locked=True)
3636
)
3737
volume_models = list(res.unique().scalars().all())
38-
# Manually load relationships to avoid outer join in the locked query
3938
for volume_model in volume_models:
4039
await session.refresh(volume_model, ["project", "attachments"])
4140
if not volume_models:
4241
return
4342

44-
# Add to lockset
4543
for volume_model in volume_models:
4644
lockset.add(volume_model.id)
4745

@@ -55,7 +53,6 @@ async def process_idle_volumes(batch_size: int = 10):
5553
await _delete_idle_volumes(session, volumes_to_delete)
5654

5755
finally:
58-
# Remove from lockset
5956
for volume_model in volume_models:
6057
lockset.difference_update([volume_model.id])
6158

@@ -64,28 +61,22 @@ async def _should_delete_idle_volume(volume_model: VolumeModel) -> bool:
6461
"""
6562
Check if a volume should be deleted based on its idle duration.
6663
"""
67-
# Get volume configuration
6864
configuration = get_volume_configuration(volume_model)
6965

70-
# If no idle_duration is configured, don't delete
7166
if configuration.idle_duration is None:
7267
return False
7368

74-
# If idle_duration is disabled (negative value), don't delete
7569
if isinstance(configuration.idle_duration, int) and configuration.idle_duration < 0:
7670
return False
7771

78-
# Parse idle duration
7972
idle_duration_seconds = parse_duration(configuration.idle_duration)
8073
if idle_duration_seconds is None or idle_duration_seconds <= 0:
8174
return False
8275

83-
# Check if volume is currently attached to any instance
8476
if len(volume_model.attachments) > 0:
8577
logger.debug("Volume %s is still attached to instances, not deleting", volume_model.name)
8678
return False
8779

88-
# Calculate how long the volume has been idle
8980
idle_duration = _get_volume_idle_duration(volume_model)
9081
idle_threshold = datetime.timedelta(seconds=idle_duration_seconds)
9182

@@ -117,15 +108,13 @@ async def _delete_idle_volumes(session: AsyncSession, volume_models: List[Volume
117108
"""
118109
Delete volumes that have exceeded their idle duration.
119110
"""
120-
# Group volumes by project
121111
volumes_by_project = {}
122112
for volume_model in volume_models:
123113
project = volume_model.project
124114
if project not in volumes_by_project:
125115
volumes_by_project[project] = []
126116
volumes_by_project[project].append(volume_model.name)
127117

128-
# Delete volumes by project
129118
for project, volume_names in volumes_by_project.items():
130119
logger.info("Deleting idle volumes for project %s: %s", project.name, volume_names)
131120
try:

src/dstack/_internal/server/background/tasks/process_submitted_jobs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,5 +705,4 @@ async def _attach_volume(
705705
)
706706
instance.volume_attachments.append(volume_attachment_model)
707707

708-
# Update volume last_job_processed_at when it's attached to a job
709708
volume_model.last_job_processed_at = common_utils.get_current_datetime()

src/dstack/_internal/server/services/jobs/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,9 @@ async def process_terminating_job(
281281
job_model.instance_id = None
282282
instance_model.last_job_processed_at = common.get_current_datetime()
283283

284-
# Update volume last_job_processed_at when job is done using them
285284
if jrd is not None and jrd.volume_names is not None:
286285
volume_names = jrd.volume_names
287286
else:
288-
# Legacy jobs before job_runtime_data/blocks were introduced
289287
volume_names = [va.volume.name for va in instance_model.volume_attachments]
290288
volume_models = await list_project_volume_models(
291289
session=session, project=instance_model.project, names=volume_names

0 commit comments

Comments
 (0)