-
Notifications
You must be signed in to change notification settings - Fork 95
Fix platform subshell evaluating more than once for tasks triggered in paused workflow #7035
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
base: 8.6.x
Are you sure you want to change the base?
Changes from 3 commits
8cc913a
23749b4
1d0fa35
57e5931
7ebd02b
dfcdcab
9401a1a
a3ddfc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1341,7 +1341,7 @@ def release_tasks_to_run(self) -> bool: | |
| """ | ||
| pre_prep_tasks: Set['TaskProxy'] = set() | ||
| if ( | ||
| self.stop_mode is None | ||
| not self.stop_mode | ||
| and self.auto_restart_time is None | ||
| and self.reload_pending is False | ||
| ): | ||
|
|
@@ -1350,36 +1350,30 @@ def release_tasks_to_run(self) -> bool: | |
| pre_prep_tasks.update(self.pool.tasks_to_trigger_now) | ||
| self.pool.tasks_to_trigger_now = set() | ||
|
|
||
| if self.is_paused: | ||
| # finish processing preparing tasks | ||
| pre_prep_tasks.update({ | ||
| itask for itask in self.pool.get_tasks() | ||
| if itask.state(TASK_STATUS_PREPARING) | ||
| }) | ||
| else: | ||
| if not self.is_paused: | ||
MetRonnie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # release queued tasks | ||
| pre_prep_tasks.update(self.pool.release_queued_tasks()) | ||
|
|
||
| elif ( | ||
| ( | ||
| # Need to get preparing tasks to submit before auto restart | ||
| self.should_auto_restart_now() | ||
| and self.auto_restart_mode == AutoRestartMode.RESTART_NORMAL | ||
| ) or ( | ||
| # Need to get preparing tasks to submit before reload | ||
| self.reload_pending | ||
| ) | ||
| if ( | ||
| # Manually triggered tasks will be in preparing state and should | ||
| # be submitted even if paused (unless stopping). | ||
| self.is_paused and not self.stop_mode | ||
| ) or ( | ||
| # Need to get preparing tasks to submit before auto restart | ||
| self.should_auto_restart_now() | ||
| and self.auto_restart_mode == AutoRestartMode.RESTART_NORMAL | ||
| ) or ( | ||
| # Need to get preparing tasks to submit before reload | ||
| self.reload_pending | ||
| ): | ||
| # finish processing preparing tasks first | ||
| pre_prep_tasks = { | ||
| itask for itask in self.pool.get_tasks() | ||
| pre_prep_tasks.update({ | ||
| itask | ||
| for itask in self.pool.get_tasks() | ||
| if itask.state(TASK_STATUS_PREPARING) | ||
| } | ||
| and itask.waiting_on_job_prep | ||
| }) | ||
|
Comment on lines
1369
to
1373
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @oliver-sanders This PR pre-dated #7054 and had basically the same fix. However #7054 missed L1376 - I have consolidated the two in this PR. One difference here is that I did not delete the check for
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK now waiting on @oliver-sanders to check that.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there's any need to have |
||
|
|
||
| # Return, if no tasks to submit. | ||
| else: | ||
| return False | ||
|
|
||
| if not pre_prep_tasks: | ||
| return False | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #!/usr/bin/env bash | ||
| # THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. | ||
| # Copyright (C) NIWA & British Crown (Met Office) & Contributors. | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| # Triggering a task with a subshell platform setting while the workflow is | ||
| # paused should only evaluate the subshell once. | ||
| # Here we have a subshell command that alternates between two platforms on each | ||
| # call, to check the platform does not change during a manual trigger. | ||
| # https://github.com/cylc/cylc-flow/issues/6994 | ||
|
|
||
| export REQUIRE_PLATFORM='loc:remote' | ||
|
|
||
| . "$(dirname "$0")/test_header" | ||
| set_test_number 11 | ||
|
|
||
| install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" | ||
|
|
||
| local_host_name=$(hostname) | ||
| remote_host_name=$(cylc config -i "[platforms][${CYLC_TEST_PLATFORM}]hosts") | ||
| workflow_log="${WORKFLOW_RUN_DIR}/log/scheduler/log" | ||
|
|
||
| run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" | ||
| cylc play "${WORKFLOW_NAME}" --pause | ||
| poll_grep_workflow_log "1/foo:waiting" | ||
|
|
||
| cylc trigger "${WORKFLOW_NAME}//1/foo" | ||
|
|
||
| log_scan "log-grep-01" "$workflow_log" 10 2 \ | ||
| "\[1/foo/01:preparing\] submitted to localhost" \ | ||
| "\[1/foo/01:.*\] (received)${local_host_name}" \ | ||
| "\[1/foo/01:.*\] => succeeded" | ||
|
|
||
| cylc trigger "${WORKFLOW_NAME}//1/foo" | ||
|
|
||
| log_scan "log-grep-02" "$workflow_log" 10 2 \ | ||
| "\[1/foo/02:preparing\] submitted to ${CYLC_TEST_PLATFORM}" \ | ||
| "\[1/foo/02:.*\] (received)${remote_host_name}" \ | ||
| "\[1/foo/02:.*\] => succeeded" | ||
|
|
||
| cylc trigger "${WORKFLOW_NAME}//1/foo" | ||
|
|
||
| log_scan "log-grep-03" "$workflow_log" 10 2 \ | ||
| "\[1/foo/03:preparing\] submitted to localhost" \ | ||
| "\[1/foo/03:.*\] (received)${local_host_name}" \ | ||
| "\[1/foo/03:.*\] => succeeded" | ||
|
|
||
| cylc stop "${WORKFLOW_NAME}" --now --now | ||
|
|
||
| # Check DB as well: | ||
| sqlite3 "${WORKFLOW_RUN_DIR}/.service/db" \ | ||
| "SELECT submit_num, platform_name FROM task_jobs" > task_jobs.out | ||
| cmp_ok task_jobs.out <<__EOF__ | ||
| 1|localhost | ||
| 2|${CYLC_TEST_PLATFORM} | ||
| 3|localhost | ||
| __EOF__ | ||
|
|
||
| poll_workflow_stopped | ||
| purge |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #!jinja2 | ||
| [scheduling] | ||
| [[graph]] | ||
| R1 = foo:never # Allows triggering repeatedly without workflow shutting down | ||
|
|
||
| [runtime] | ||
| [[foo]] | ||
| platform = $("${CYLC_WORKFLOW_RUN_DIR}/toggle_platform.sh" {{ CYLC_TEST_PLATFORM }}) | ||
| # Check what host we have truly run on: | ||
| script = cylc message -- "$(hostname)" | ||
|
|
||
| [[[outputs]]] | ||
| never = gonna_give_u_up |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env bash | ||
| # THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. | ||
| # Copyright (C) NIWA & British Crown (Met Office) & Contributors. | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| # Script that outputs the current platform written in the hall file and changes | ||
| # it to the other one. This ensures the platform subshell result will alternate | ||
| # each time it is called. | ||
|
|
||
| remote_platform=$1 | ||
| hall_file="${CYLC_WORKFLOW_RUN_DIR}/pretend_hall_info" | ||
|
|
||
| if [[ ! -f "${hall_file}" ]]; then | ||
| current=localhost | ||
| else | ||
| current=$(cat "$hall_file") | ||
| fi | ||
|
|
||
| echo "$current" | ||
|
|
||
| if [[ "$current" == localhost ]]; then | ||
| echo "$remote_platform" > "$hall_file" | ||
| else | ||
| echo localhost > "$hall_file" | ||
| fi |
Uh oh!
There was an error while loading. Please reload this page.