Skip to content

Commit 1c464c7

Browse files
committed
add --disable-job in 'eb' command used in jobs, to prevent infinite job cycle (fixes #3307)
1 parent 3b53953 commit 1c464c7

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

easybuild/tools/parallelbuild.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,17 @@ def submit_jobs(ordered_ecs, cmd_line_opts, testing=False, prepare_first=True):
127127
curdir = os.getcwd()
128128

129129
# regex pattern for options to ignore (help options can't reach here)
130-
ignore_opts = re.compile('^--robot$|^--job$|^--try-.*$')
130+
ignore_opts = re.compile('^--robot$|^--job|^--try-.*$')
131131

132132
# generate_cmd_line returns the options in form --longopt=value
133133
opts = [o for o in cmd_line_opts if not ignore_opts.match(o.split('=')[0])]
134134

135+
# add --disable-job to make sure the submitted job doesn't submit a job itself,
136+
# resulting in an infinite cycle of jobs;
137+
# this can happen if job submission is enabled via a configuration file or via $EASYBUILD_JOB,
138+
# cfr. https://github.com/easybuilders/easybuild-framework/issues/3307
139+
opts.append('--disable-job')
140+
135141
# compose string with command line options, properly quoted and with '%' characters escaped
136142
opts_str = ' '.join(opts).replace('%', '%%')
137143

test/framework/parallelbuild.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,10 @@ def test_build_easyconfigs_in_parallel_pbs_python(self):
173173
# dependencies for gzip/1.4-GCC-4.6.3: GCC/4.6.3 (toolchain) + toy/.0.0-deps
174174
self.assertTrue('gzip-1.4-GCC-4.6.3.eb' in jobs[3].script)
175175
self.assertEqual(len(jobs[3].deps), 2)
176-
regex = re.compile('toy-0.0-deps.eb\s* --hidden')
177-
self.assertTrue(regex.search(jobs[3].deps[0].script))
176+
regex = re.compile(r'toy-0.0-deps\.eb.* --hidden')
177+
script_txt = jobs[3].deps[0].script
178+
fail_msg = "Pattern '%s' should be found in: %s" % (regex.pattern, script_txt)
179+
self.assertTrue(regex.search(script_txt), fail_msg)
178180
self.assertTrue('GCC-4.6.3.eb' in jobs[3].deps[1].script)
179181

180182
# also test use of --pre-create-installdir
@@ -290,6 +292,7 @@ def test_submit_jobs(self):
290292
'--try-toolchain=intel,2016a', # should be excluded in job script
291293
'--robot', self.test_prefix, # should be excluded in job script
292294
'--job', # should be excluded in job script
295+
'--job-cores=3',
293296
]
294297
eb_go = parse_options(args=args)
295298
cmd = submit_jobs([toy_ec], eb_go.generate_cmd_line(), testing=True)
@@ -306,16 +309,17 @@ def test_submit_jobs(self):
306309
' eb %\(spec\)s ',
307310
' %\(add_opts\)s ',
308311
' --testoutput=%\(output_dir\)s',
312+
' --disable-job ',
309313
]
310314
for regex in regexs:
311315
regex = re.compile(regex)
312316
self.assertTrue(regex.search(cmd), "Pattern '%s' found in: %s" % (regex.pattern, cmd))
313317

314318
# these patterns should NOT be found, these options get filtered out
315319
# (self.test_prefix was argument to --robot)
316-
for regex in ['--job', '--try-toolchain', '--robot=[ =]', self.test_prefix + ' ']:
320+
for regex in ['--job', '--job-cores', '--try-toolchain', '--robot=[ =]', self.test_prefix + ' ']:
317321
regex = re.compile(regex)
318-
self.assertFalse(regex.search(cmd), "Pattern '%s' *not* found in: %s" % (regex.pattern, cmd))
322+
self.assertFalse(regex.search(cmd), "Pattern '%s' should *not* be found in: %s" % (regex.pattern, cmd))
319323

320324
def test_build_easyconfigs_in_parallel_slurm(self):
321325
"""Test build_easyconfigs_in_parallel(), using (mocked) Slurm as backend for --job."""

0 commit comments

Comments
 (0)