Skip to content

Commit d92c4c7

Browse files
committed
Add missing job status change event for scaling
Emit the job status change event when a job transitions to `terminating` due to scaling. This case was previously missed because the `job` variable was not inferred as `JobModel`.
1 parent a36577f commit d92c4c7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/dstack/_internal/server/services/runs/replicas.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ async def scale_run_replicas(session: AsyncSession, run_model: RunModel, replica
7575
)
7676

7777
# lists of (importance, is_out_of_date, replica_num, jobs)
78-
active_replicas = []
79-
inactive_replicas = []
78+
active_replicas: list[tuple[int, bool, int, list[JobModel]]] = []
79+
inactive_replicas: list[tuple[int, bool, int, list[JobModel]]] = []
8080

8181
for replica_num, replica_jobs in group_jobs_by_replica_latest(run_model.jobs):
8282
statuses = set(job.status for job in replica_jobs)
@@ -108,8 +108,8 @@ async def scale_run_replicas(session: AsyncSession, run_model: RunModel, replica
108108
for job in replica_jobs:
109109
if job.status.is_finished() or job.status == JobStatus.TERMINATING:
110110
continue
111-
job.status = JobStatus.TERMINATING
112111
job.termination_reason = JobTerminationReason.SCALED_DOWN
112+
switch_job_status(session, job, JobStatus.TERMINATING, events.SystemActor())
113113
# background task will process the job later
114114
else:
115115
scheduled_replicas = 0

0 commit comments

Comments
 (0)