|
98 | 98 | volume_model_to_volume, |
99 | 99 | ) |
100 | 100 | from dstack._internal.server.utils import sentry_utils |
| 101 | +from dstack._internal.settings import FeatureFlags |
101 | 102 | from dstack._internal.utils import common as common_utils |
102 | 103 | from dstack._internal.utils.logging import get_logger |
103 | 104 |
|
@@ -311,16 +312,27 @@ async def _process_submitted_job(session: AsyncSession, job_model: JobModel): |
311 | 312 | master_job_provisioning_data=master_job_provisioning_data, |
312 | 313 | volumes=volumes, |
313 | 314 | ) |
314 | | - if fleet_model is None and run_spec.merged_profile.fleets is not None: |
315 | | - # Run cannot create new fleets when fleets are specified |
316 | | - logger.debug("%s: failed to use specified fleets", fmt(job_model)) |
317 | | - job_model.status = JobStatus.TERMINATING |
318 | | - job_model.termination_reason = ( |
319 | | - JobTerminationReason.FAILED_TO_START_DUE_TO_NO_CAPACITY |
320 | | - ) |
321 | | - job_model.last_processed_at = common_utils.get_current_datetime() |
322 | | - await session.commit() |
323 | | - return |
| 315 | + if fleet_model is None: |
| 316 | + if run_spec.merged_profile.fleets is not None: |
| 317 | + # Run cannot create new fleets when fleets are specified |
| 318 | + logger.debug("%s: failed to use specified fleets", fmt(job_model)) |
| 319 | + job_model.status = JobStatus.TERMINATING |
| 320 | + job_model.termination_reason = ( |
| 321 | + JobTerminationReason.FAILED_TO_START_DUE_TO_NO_CAPACITY |
| 322 | + ) |
| 323 | + job_model.last_processed_at = common_utils.get_current_datetime() |
| 324 | + await session.commit() |
| 325 | + return |
| 326 | + if FeatureFlags.AUTOCREATED_FLEETS_DISABLED: |
| 327 | + logger.debug("%s: no fleet found", fmt(job_model)) |
| 328 | + job_model.status = JobStatus.TERMINATING |
| 329 | + job_model.termination_reason = ( |
| 330 | + JobTerminationReason.FAILED_TO_START_DUE_TO_NO_CAPACITY |
| 331 | + ) |
| 332 | + job_model.termination_reason_message = "Failed to find fleet" |
| 333 | + job_model.last_processed_at = common_utils.get_current_datetime() |
| 334 | + await session.commit() |
| 335 | + return |
324 | 336 | instance = await _assign_job_to_fleet_instance( |
325 | 337 | session=session, |
326 | 338 | instances_with_offers=fleet_instances_with_offers, |
@@ -647,8 +659,10 @@ async def _find_optimal_fleet_with_offers( |
647 | 659 | ) |
648 | 660 | if len(candidate_fleets_with_offers) == 0: |
649 | 661 | return None, [] |
650 | | - if run_spec.merged_profile.fleets is None and all( |
651 | | - t[2] == 0 and t[3] == 0 for t in candidate_fleets_with_offers |
| 662 | + if ( |
| 663 | + not FeatureFlags.AUTOCREATED_FLEETS_DISABLED |
| 664 | + and run_spec.merged_profile.fleets is None |
| 665 | + and all(t[2] == 0 and t[3] == 0 for t in candidate_fleets_with_offers) |
652 | 666 | ): |
653 | 667 | # If fleets are not specified and no fleets have available pool |
654 | 668 | # or backend offers, create a new fleet. |
|
0 commit comments