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

Set execution polling delays correctly #4844

Merged
merged 5 commits into from
May 5, 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
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ workflow source argument), and rename the `--flow-name` option to

### Fixes

[#4844](https://github.com/cylc/cylc-flow/pull/4844) - Fixes bug where
execution polling intervals used in combination with an execution time limit
resulted in incorrect polling intervals.

[#4829](https://github.com/cylc/cylc-flow/pull/4829) -
Suppress deprecated configuration warnings in Cylc 7 compatibility mode.

Expand Down
16 changes: 9 additions & 7 deletions cylc/flow/task_events_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1511,13 +1511,15 @@ def _reset_job_timers(self, itask):
if not time_limit_delays:
time_limit_delays = [60, 120, 420]
timeout = time_limit + sum(time_limit_delays)
# Remove excessive polling before time limit
while sum(delays) > time_limit:
del delays[-1]
# But fill up the gap before time limit
if delays:
size = int((time_limit - sum(delays)) / delays[-1])
delays.extend([delays[-1]] * size)
if sum(delays) > time_limit:
# Remove excessive polling before time limit
while sum(delays) > time_limit:
del delays[-1]
else:
# Fill up the gap before time limit
if delays:
size = int((time_limit - sum(delays)) / delays[-1])
delays.extend([delays[-1]] * size)
time_limit_delays[0] += time_limit - sum(delays)
delays += time_limit_delays
else: # if itask.state.status == TASK_STATUS_SUBMITTED:
Expand Down
59 changes: 59 additions & 0 deletions tests/functional/execution-time-limit/04-polling-intervals.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/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/>.
#-------------------------------------------------------------------------------
# Test execution time limit works correctly with polling intervals

. "$(dirname "$0")/test_header"
set_test_number 6

init_workflow "${TEST_NAME_BASE}" << __FLOW__
[scheduling]
[[graph]]
R1 = nolimit & limit95M & limit1H & limit10M & limit70S
[runtime]
[[root]]
script = "echo Hello"
execution polling intervals = 3*PT30S, PT10M, PT1H
[[nolimit]]
[[limit95M]]
execution time limit = PT95M
[[limit1H]]
execution time limit = PT1H
[[limit10M]]
execution time limit = PT10M
[[limit70S]]
execution time limit = PT70S
__FLOW__

run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}"

cylc play "${WORKFLOW_NAME}"

poll_grep_workflow_log "INFO - DONE"

# NOTE: execution timeout polling is delayed by PT1M to let things settle
# PT10M = (3*PT3S + PT9M30S) - PT1M
grep_workflow_log_ok grep-limit10M "\[1/limit10M running job:01 flows:1\] health: execution timeout=PT20M, polling intervals=3\*PT30S,PT9M30S,PT2M,PT7M,..."
# PT60M = (3*PT3S + PT10M + PT49M30S) - PT1M
grep_workflow_log_ok grep-limit1H "\[1/limit1H running job:01 flows:1\] health: execution timeout=PT1H10M, polling intervals=3\*PT30S,PT10M,PT49M30S,PT2M,PT7M,..."
# PT70S = (2*PT30S + PT1M10S) - PT1M
grep_workflow_log_ok grep-limit70S "\[1/limit70S running job:01 flows:1\] health: execution timeout=PT11M10S, polling intervals=2\*PT30S,PT1M10S,PT2M,PT7M,..."
# PT95M = (3*PT3S + PT10M + PT1H + PT24M30S) - PT1M
grep_workflow_log_ok grep-limit95M "\[1/limit95M running job:01 flows:1\] health: execution timeout=PT1H45M, polling intervals=3\*PT30S,PT10M,PT1H,PT24M30S,PT2M,PT7M,..."
grep_workflow_log_ok grep-no-limit "\[1/nolimit running job:01 flows:1\] health: execution timeout=None, polling intervals=3\*PT30S,PT10M,PT1H,..."

purge