File tree Expand file tree Collapse file tree
src/dstack/_internal/server/services Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -400,23 +400,19 @@ def _validate_volume_configuration(configuration: VolumeConfiguration):
400400 )
401401 if configuration .name is not None :
402402 validate_dstack_resource_name (configuration .name )
403- # External volumes (with volume_id) cannot have auto_cleanup_duration
403+
404404 if configuration .volume_id is not None and configuration .auto_cleanup_duration is not None :
405405 if (
406406 isinstance (configuration .auto_cleanup_duration , int )
407- and configuration .auto_cleanup_duration >= 0
407+ and configuration .auto_cleanup_duration > 0
408+ ) or (
409+ isinstance (configuration .auto_cleanup_duration , str )
410+ and configuration .auto_cleanup_duration not in ("off" , "-1" )
408411 ):
409412 raise ServerClientError (
410413 "External volumes (with volume_id) do not support auto_cleanup_duration. "
411414 "Auto-cleanup only works for volumes created and managed by dstack."
412415 )
413- elif isinstance (
414- configuration .auto_cleanup_duration , str
415- ) and configuration .auto_cleanup_duration not in ("off" , "-1" ):
416- raise ServerClientError (
417- "External volumes (with volume_id) do not support auto_cleanup_duration. "
418- "Auto-cleanup only works for volumes created and managed by dstack."
419- )
420416
421417
422418async def _delete_volume (session : AsyncSession , project : ProjectModel , volume_model : VolumeModel ):
You can’t perform that action at this time.
0 commit comments