Skip to content

Commit d872088

Browse files
authored
Always submit preparing tasks. (#6768)
Remote platform init was thwarting the trigger-if-paused logic.
1 parent 2740c44 commit d872088

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

changes.d/6768.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug causing remote tasks to stay in the preparing state if triggered when the workflow is paused.

cylc/flow/scheduler.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,13 @@ def release_tasks_to_run(self) -> bool:
13541354
pre_prep_tasks.update(self.pool.tasks_to_trigger_now)
13551355
self.pool.tasks_to_trigger_now = set()
13561356

1357-
if not self.is_paused:
1357+
if self.is_paused:
1358+
# finish processing preparing tasks
1359+
pre_prep_tasks.update({
1360+
itask for itask in self.pool.get_tasks()
1361+
if itask.state(TASK_STATUS_PREPARING)
1362+
})
1363+
else:
13581364
# release queued tasks
13591365
pre_prep_tasks.update(self.pool.release_queued_tasks())
13601366
if self.pool.tasks_to_trigger_on_resume:

tests/integration/test_force_trigger.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
)
3939
from cylc.flow.cycling.integer import IntegerPoint
4040
from cylc.flow.task_state import (
41+
TASK_STATUS_PREPARING,
4142
TASK_STATUS_WAITING,
4243
TASK_STATUS_RUNNING
4344
)
@@ -752,3 +753,30 @@ async def test_trigger_with_sequential_task(flow, scheduler, run, log_filter):
752753
if log_filter(contains='[2/foo/02:running] (received)failed'):
753754
break
754755
await asyncio.sleep(0)
756+
757+
758+
async def test_trigger_whilst_paused_preparing(flow, scheduler, run, complete):
759+
"""It should run "preparing" tasks even if the workflow is paused.
760+
761+
Remote init leaves tasks as preparing for a while. These must still be
762+
pushed through to running, even if triggered while the workflow is paused.
763+
764+
See https://github.com/cylc/cylc-flow/pull/6768
765+
766+
"""
767+
id_ = flow(
768+
{
769+
'scheduling': {
770+
'graph': {'R1': 'a'},
771+
},
772+
}
773+
)
774+
schd = scheduler(id_)
775+
async with run(schd):
776+
777+
# Instead of triggering, artificially set it as preparing.
778+
a = schd.pool.get_tasks()[0]
779+
a.state_reset(TASK_STATUS_PREPARING)
780+
781+
# 1/a should run even though the workflow is paused.
782+
await complete(schd, '1/a', allow_paused=True, timeout=1)

0 commit comments

Comments
 (0)