@@ -173,41 +173,43 @@ async def _process_running_job(session: AsyncSession, job_model: JobModel):
173173 await session .commit ()
174174 return
175175
176- cluster_info = _get_cluster_info (
177- jobs = run .jobs ,
178- replica_num = job .job_spec .replica_num ,
179- job_provisioning_data = job_provisioning_data ,
180- job_runtime_data = job_submission .job_runtime_data ,
181- )
182-
183- volumes = await get_job_attached_volumes (
184- session = session ,
185- project = project ,
186- run_spec = run .run_spec ,
187- job_num = job .job_spec .job_num ,
188- job_provisioning_data = job_provisioning_data ,
189- )
190-
191176 server_ssh_private_keys = get_instance_ssh_private_keys (
192177 common_utils .get_or_error (job_model .instance )
193178 )
194179
195- secrets = await get_project_secrets_mapping (session = session , project = project )
180+ initial_status = job_model .status
181+ if initial_status in [JobStatus .PROVISIONING , JobStatus .PULLING ]:
182+ cluster_info = _get_cluster_info (
183+ jobs = run .jobs ,
184+ replica_num = job .job_spec .replica_num ,
185+ job_provisioning_data = job_provisioning_data ,
186+ job_runtime_data = job_submission .job_runtime_data ,
187+ )
196188
197- try :
198- _interpolate_secrets (secrets , job .job_spec )
199- except InterpolatorError as e :
200- logger .info ("%s: terminating due to secrets interpolation error" , fmt (job_model ))
201- job_model .status = JobStatus .TERMINATING
202- job_model .termination_reason = JobTerminationReason .TERMINATED_BY_SERVER
203- job_model .termination_reason_message = e .args [0 ]
204- job_model .last_processed_at = common_utils .get_current_datetime ()
205- return
189+ volumes = await get_job_attached_volumes (
190+ session = session ,
191+ project = project ,
192+ run_spec = run .run_spec ,
193+ job_num = job .job_spec .job_num ,
194+ job_provisioning_data = job_provisioning_data ,
195+ )
206196
207- repo_creds_model = await get_repo_creds (session = session , repo = repo_model , user = run_model .user )
208- repo_creds = repo_model_to_repo_head_with_creds (repo_model , repo_creds_model ).repo_creds
197+ repo_creds_model = await get_repo_creds (
198+ session = session , repo = repo_model , user = run_model .user
199+ )
200+ repo_creds = repo_model_to_repo_head_with_creds (repo_model , repo_creds_model ).repo_creds
201+
202+ secrets = await get_project_secrets_mapping (session = session , project = project )
203+ try :
204+ _interpolate_secrets (secrets , job .job_spec )
205+ except InterpolatorError as e :
206+ logger .info ("%s: terminating due to secrets interpolation error" , fmt (job_model ))
207+ job_model .status = JobStatus .TERMINATING
208+ job_model .termination_reason = JobTerminationReason .TERMINATED_BY_SERVER
209+ job_model .termination_reason_message = e .args [0 ]
210+ job_model .last_processed_at = common_utils .get_current_datetime ()
211+ return
209212
210- initial_status = job_model .status
211213 if initial_status == JobStatus .PROVISIONING :
212214 if job_provisioning_data .hostname is None :
213215 await _wait_for_instance_provisioning_data (job_model = job_model )
0 commit comments