Skip to content

Commit 3c253fa

Browse files
authored
Fix erroneous submissions to localhost when using deprecated batch system setting (#6990)
1 parent 764197f commit 3c253fa

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

changes.d/6990.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug where setting 'batch system' and not setting host could lead to the wrong platform being selected.

cylc/flow/task_job_mgr.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
from cylc.flow.job_runner_mgr import JOB_FILES_REMOVED_MESSAGE, JobPollContext
6565
from cylc.flow.pathutil import get_remote_workflow_run_job_dir
6666
from cylc.flow.platforms import (
67+
FORBIDDEN_WITH_PLATFORM,
6768
get_host_from_platform,
6869
get_install_target_from_platform,
6970
get_localhost_install_target,
@@ -1222,14 +1223,21 @@ def _prep_submit_task_job(
12221223

12231224
host_name, platform_name = None, None
12241225
try:
1225-
if rtconfig['remote']['host'] is not None:
1226+
# We need to assume that we want a host if any of the items
1227+
# for the old host/batch system plaform selection system are set.
1228+
if any(
1229+
rtconfig[section][key] is not None
1230+
for section, values in FORBIDDEN_WITH_PLATFORM.items()
1231+
for key in values
1232+
):
12261233
host_name = self.task_remote_mgr.eval_host(
12271234
rtconfig['remote']['host']
12281235
)
12291236
else:
12301237
platform_name = self.task_remote_mgr.eval_platform(
12311238
rtconfig['platform']
12321239
)
1240+
12331241
except PlatformError as exc:
12341242
itask.waiting_on_job_prep = False
12351243
itask.summary['platforms_used'][itask.submit_num] = ''

tests/integration/test_task_job_mgr.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,38 @@ async def test_poll_job_deleted_log_folder(
258258
assert log_filter(
259259
logging.ERROR, f"job log directory {job_id} no longer exists"
260260
)
261+
262+
263+
async def test__prep_submit_task_job_impl_handles_all_old_platform_settings(
264+
flow: Fixture,
265+
scheduler: Fixture,
266+
start: Fixture,
267+
mock_glbl_cfg: Fixture,
268+
):
269+
"""Ensure that if the old host/batch system settings
270+
are set that task job manager will wait for the any hostname to be
271+
resolved.
272+
273+
https://github.com/cylc/cylc-flow/pull/6990
274+
"""
275+
mock_glbl_cfg(
276+
'cylc.flow.platforms.glbl_cfg',
277+
'''
278+
[platforms]
279+
[[bakery]]
280+
hosts = localhost
281+
job runner = loaf
282+
''',
283+
)
284+
id_ = flow({
285+
"scheduling": {"graph": {"R1": "a"}},
286+
"runtime": {"a": {"job": {"batch system": "loaf"}}}
287+
})
288+
289+
schd = scheduler(id_, run_mode='live')
290+
async with start(schd):
291+
task_a = schd.pool.get_tasks()[0]
292+
with suppress(FileExistsError):
293+
schd.task_job_mgr._prep_submit_task_job(task_a)
294+
295+
assert task_a.platform['name'] == 'bakery'

0 commit comments

Comments
 (0)