Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preparing vs active #4668

Merged
merged 2 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cylc/flow/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,8 @@ def restart_remote_init(self):
itask.platform['install target'] = (
get_install_target_from_platform(itask.platform))
if (
# we don't need to remote-init for preparing tasks because
# they will be reset to waiting on restart
itask.state(*TASK_STATUSES_ACTIVE)
and not (
is_platform_with_target_in_list(
Expand Down
4 changes: 3 additions & 1 deletion cylc/flow/task_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ def reload_taskdefs(self) -> None:
itask.copy_to_reload_successor(new_task)
self._swap_out(new_task)
LOG.info(f"[{itask}] reloaded task definition")
if itask.state(*TASK_STATUSES_ACTIVE):
if itask.state(*TASK_STATUSES_ACTIVE, TASK_STATUS_PREPARING):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should warn for preparing tasks as pre-reload settings may have been baked into the filesystem?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

LOG.warning(
f"[{itask}] active with pre-reload settings"
)
Expand Down Expand Up @@ -898,6 +898,8 @@ def can_stop(self, stop_mode):
and itask.state(*TASK_STATUSES_ACTIVE)
and not itask.state.kill_failed
)
# we don't need to check for preparing tasks because they will be
# reset to waiting on restart
for itask in self.get_tasks()
)

Expand Down
31 changes: 31 additions & 0 deletions tests/integration/test_task_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,34 @@ async def test_trigger_states(status, should_trigger, one, run):

# check whether the task triggered
assert task.is_manual_submit == should_trigger


async def test_preparing_tasks_on_restart(one_conf, flow, scheduler, run):
"""Preparing tasks should be reset to waiting on restart.

This forces preparation to be re-done on restart so that it uses the
new configuration.

See discussion on: https://github.com/cylc/cylc-flow/pull/4668

"""
id_ = flow(one_conf)

# start the workflow, reset a task to preparing
one = scheduler(id_)
async with run(one):
task = one.pool.filter_task_proxies(['*'])[0][0]
task.state.reset(TASK_STATUS_PREPARING)

# when we restart the task should have been reset to waiting
one = scheduler(id_)
async with run(one):
task = one.pool.filter_task_proxies(['*'])[0][0]
assert task.state(TASK_STATUS_WAITING)
task.state.reset(TASK_STATUS_SUCCEEDED)

# whereas if we reset the task to succeeded the state is not reset
one = scheduler(id_)
async with run(one):
task = one.pool.filter_task_proxies(['*'])[0][0]
assert task.state(TASK_STATUS_SUCCEEDED)