|
34 | 34 | from parsl.dataflow.taskrecord import TaskRecord |
35 | 35 | from parsl.errors import ConfigurationError, InternalConsistencyError, NoDataFlowKernelError |
36 | 36 | from parsl.jobs.job_status_poller import JobStatusPoller |
37 | | -from parsl.jobs.states import JobStatus, JobState |
38 | 37 | from parsl.usage_tracking.usage import UsageTracker |
39 | 38 | from parsl.executors.base import ParslExecutor |
40 | 39 | from parsl.executors.status_handling import BlockProviderExecutor |
@@ -1216,22 +1215,21 @@ def cleanup(self) -> None: |
1216 | 1215 |
|
1217 | 1216 | logger.info("Scaling in and shutting down executors") |
1218 | 1217 |
|
| 1218 | + for pi in self.job_status_poller._poll_items: |
| 1219 | + if not pi.executor.bad_state_is_set: |
| 1220 | + logger.info(f"Scaling in executor {pi.executor.label}") |
| 1221 | + |
| 1222 | + # this code needs to be at least as many blocks as need |
| 1223 | + # cancelling, but it is safe to be more, as the scaling |
| 1224 | + # code will cope with being asked to cancel more blocks |
| 1225 | + # than exist. |
| 1226 | + block_count = len(pi.status) |
| 1227 | + pi.scale_in(block_count) |
| 1228 | + |
| 1229 | + else: # and bad_state_is_set |
| 1230 | + logger.warning(f"Not scaling in executor {pi.executor.label} because it is in bad state") |
| 1231 | + |
1219 | 1232 | for executor in self.executors.values(): |
1220 | | - if isinstance(executor, BlockProviderExecutor): |
1221 | | - if not executor.bad_state_is_set: |
1222 | | - logger.info(f"Scaling in executor {executor.label}") |
1223 | | - if executor.provider: |
1224 | | - job_ids = executor.provider.resources.keys() |
1225 | | - block_ids = executor.scale_in(len(job_ids)) |
1226 | | - if self.monitoring and block_ids: |
1227 | | - new_status = {} |
1228 | | - for bid in block_ids: |
1229 | | - new_status[bid] = JobStatus(JobState.CANCELLED) |
1230 | | - msg = executor.create_monitoring_info(new_status) |
1231 | | - logger.debug("Sending message {} to hub from DFK".format(msg)) |
1232 | | - self.monitoring.send(MessageType.BLOCK_INFO, msg) |
1233 | | - else: # and bad_state_is_set |
1234 | | - logger.warning(f"Not scaling in executor {executor.label} because it is in bad state") |
1235 | 1233 | logger.info(f"Shutting down executor {executor.label}") |
1236 | 1234 | executor.shutdown() |
1237 | 1235 | logger.info(f"Shut down executor {executor.label}") |
|
0 commit comments