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

Ensure jobs are created if task is in waiting state #6176

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions changes.d/6176.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug where jobs which fail to submit are not shown in GUI/TUI if submission retries are set.
12 changes: 11 additions & 1 deletion cylc/flow/task_events_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,11 +1535,21 @@ def _insert_task_job(
else:
job_conf = itask.jobs[-1]

# Job status should be task status unless task is awaiting a
# retry:
if itask.state.status == TASK_STATUS_WAITING and itask.try_timers:
job_status = (
TASK_STATUS_SUBMITTED if submit_status == 0
else TASK_STATUS_SUBMIT_FAILED
)
else:
job_status = itask.state.status

# insert job into data store
self.data_store_mgr.insert_job(
Copy link
Member Author

Choose a reason for hiding this comment

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

This method takes a job status, not a task status. If the task status is 'waiting' it returns None and doesn't register the job with the data store.

itask.tdef.name,
itask.point,
itask.state.status,
job_status,
{
**job_conf,
# NOTE: the platform name may have changed since task
Expand Down
73 changes: 70 additions & 3 deletions tests/integration/test_task_events_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from cylc.flow.task_events_mgr import TaskJobLogsRetrieveContext
from cylc.flow.scheduler import Scheduler

from itertools import product
import logging
from typing import Any as Fixture

from cylc.flow.task_events_mgr import TaskJobLogsRetrieveContext
from cylc.flow.scheduler import Scheduler
from cylc.flow.data_store_mgr import (
JOBS,
TASK_STATUSES_ORDERED,
TASK_STATUS_WAITING,
TASK_STATUS_SUBMIT_FAILED,
)


async def test_process_job_logs_retrieval_warns_no_platform(
one_conf: Fixture, flow: Fixture, scheduler: Fixture, run: Fixture,
Expand Down Expand Up @@ -99,3 +106,63 @@ async def test__insert_task_job(flow, one_conf, scheduler, start, validate):
i.submit_num for i
in schd.data_store_mgr.added['jobs'].values()
] == [1, 2]


async def test__always_insert_task_job(
flow, scheduler, mock_glbl_cfg, start, run
):
"""Insert Task Job _Always_ inserts a task into the data store.

Bug https://github.com/cylc/cylc-flow/issues/6172 was caused
by passing task state to data_store_mgr.insert_job: Where
a submission retry was in progress the task state would be
"waiting" which caused the data_store_mgr.insert_job
to return without adding the task to the data store.
"""
wxtim marked this conversation as resolved.
Show resolved Hide resolved
global_config = """
[platforms]
[[broken1]]
hosts = no-such-host-1
[[broken2]]
hosts = no-such-host-2
[platform groups]
[[broken]]
platforms = broken1
"""
mock_glbl_cfg('cylc.flow.platforms.glbl_cfg', global_config)

id_ = flow({
'scheduling': {'graph': {'R1': 'broken & broken2'}},
'runtime': {
'root': {'submission retry delays': 'PT10M'},
'broken': {'platform': 'broken'},
wxtim marked this conversation as resolved.
Show resolved Hide resolved
'broken2': {'platform': 'broken2'}
}
wxtim marked this conversation as resolved.
Show resolved Hide resolved
})

schd = scheduler(id_, run_mode='live')
schd.bad_hosts = {'no-such-host-1', 'no-such-host-2'}
wxtim marked this conversation as resolved.
Show resolved Hide resolved
async with start(schd):
schd.task_job_mgr.submit_task_jobs(
schd.workflow,
schd.pool.get_tasks(),
schd.server.curve_auth,
schd.server.client_pub_key_dir,
is_simulation=False
)

# Both tasks are in a waiting state:
assert all(
i.state.status == TASK_STATUS_WAITING
for i in schd.pool.get_tasks())

# Both tasks have updated the data store with info
# about a failed job:
updates = {
k.split('//')[-1]: v.state
for k, v in schd.data_store_mgr.updated[JOBS].items()
}
assert updates == {
'1/broken/01': 'submit-failed',
'1/broken2/01': 'submit-failed'
}
Loading