Skip to content

Commit f1b33b4

Browse files
committed
fix 3471 - only scale in blocks that are in _status and non-terminal
block ID and job ID mappings contain the full historical list of blocks, but prior to this PR, the mapping was used as source of current jobs that should be scaled in
1 parent b96a2dd commit f1b33b4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

parsl/executors/status_handling.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from parsl.executors.base import ParslExecutor
1313
from parsl.executors.errors import BadStateException, ScalingFailed
1414
from parsl.jobs.error_handlers import noop_error_handler, simple_error_handler
15-
from parsl.jobs.states import JobState, JobStatus
15+
from parsl.jobs.states import TERMINAL_STATES, JobState, JobStatus
1616
from parsl.monitoring.message_type import MessageType
1717
from parsl.providers.base import ExecutionProvider
1818
from parsl.utils import AtomicIDCounter
@@ -205,16 +205,20 @@ def scale_in(self, blocks: int) -> List[str]:
205205
206206
:return: A list of block ids corresponding to the blocks that were removed.
207207
"""
208-
# Obtain list of blocks to kill
209-
to_kill = list(self.blocks_to_job_id.keys())[:blocks]
210-
kill_ids = [self.blocks_to_job_id[block] for block in to_kill]
208+
209+
active_blocks = [block_id for block_id, status in self._status.items()
210+
if status.state not in TERMINAL_STATES]
211+
212+
block_ids_to_kill = active_blocks[:blocks]
213+
214+
job_ids_to_kill = [self.blocks_to_job_id[block] for block in block_ids_to_kill]
211215

212216
# Cancel the blocks provisioned
213217
if self.provider:
214-
logger.info(f"Scaling in jobs: {kill_ids}")
215-
r = self.provider.cancel(kill_ids)
216-
job_ids = self._filter_scale_in_ids(kill_ids, r)
217-
block_ids_killed = [self.job_ids_to_block[jid] for jid in job_ids]
218+
logger.info(f"Scaling in jobs: {job_ids_to_kill}")
219+
r = self.provider.cancel(job_ids_to_kill)
220+
job_ids = self._filter_scale_in_ids(job_ids_to_kill, r)
221+
block_ids_killed = [self.job_ids_to_block[job_id] for job_id in job_ids]
218222
return block_ids_killed
219223
else:
220224
logger.error("No execution provider available to scale in")

0 commit comments

Comments
 (0)