Skip to content

Commit 2c4f952

Browse files
committed
Merge branch 'nate-i50190-job-submit' into 'master'
See merge request SchedMD/dev/slurm!2491
2 parents dc257c2 + f9aa6d1 commit 2c4f952

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

‎doc/html/job_submit_plugins.shtml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ better ease of use. Sample Lua scripts can be found with the Slurm distribution
144144
in the directory <i>contribs/lua</i>. The default installation location of
145145
the Lua scripts is the same location as the Slurm configuration file,
146146
<i>slurm.conf</i>.
147+
Setting <code>debugflags=script</code> and (at least debug)
148+
<code>SlurmctldDebug=debug</code> in <a href="slurm.conf">slurm.conf</a> will
149+
dump error stacktraces in the slurmctld.log along with the debugging
150+
information but should <b>not</b> be configured on production clusters.
147151
Reading and writing of job environment variables using Lua is possible
148152
by referencing the environment variables as a data structure containing
149153
named elements.</p>

‎src/plugins/job_submit/lua/job_submit_lua.c‎

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,6 +1393,8 @@ extern int job_submit(job_desc_msg_t *job_desc, uint32_t submit_uid,
13931393
char **err_msg)
13941394
{
13951395
int rc;
1396+
char *err_str = NULL;
1397+
13961398
slurm_mutex_lock (&lua_lock);
13971399

13981400
rc = slurm_lua_loadscript(&L, "job_submit/lua",
@@ -1419,9 +1421,18 @@ extern int job_submit(job_desc_msg_t *job_desc, uint32_t submit_uid,
14191421
lua_pushnumber(L, submit_uid);
14201422
slurm_lua_stack_dump(
14211423
"job_submit/lua", "job_submit, before lua_pcall", L);
1422-
if (lua_pcall(L, 3, 1, 0) != 0) {
1424+
if ((rc = slurm_lua_pcall(L, 3, 1, &err_str, __func__))) {
1425+
if (!err_str)
1426+
err_str = xstrdup_printf("Lua %s failed: %s",
1427+
lua_script_path,
1428+
slurm_strerror(rc));
1429+
14231430
error("%s/lua: %s: %s",
1424-
__func__, lua_script_path, lua_tostring(L, -1));
1431+
__func__, lua_script_path, err_str);
1432+
1433+
/* Replace user_msg as err_msg with Lua error */
1434+
xfree(user_msg);
1435+
SWAP(*err_msg, err_str);
14251436
} else {
14261437
if (lua_isnumber(L, -1)) {
14271438
rc = lua_tonumber(L, -1);
@@ -1440,6 +1451,8 @@ extern int job_submit(job_desc_msg_t *job_desc, uint32_t submit_uid,
14401451
}
14411452

14421453
out: slurm_mutex_unlock (&lua_lock);
1454+
1455+
xfree(err_str);
14431456
return rc;
14441457
}
14451458

@@ -1448,6 +1461,8 @@ extern int job_modify(job_desc_msg_t *job_desc, job_record_t *job_ptr,
14481461
uint32_t submit_uid, char **err_msg)
14491462
{
14501463
int rc;
1464+
char *err_str = NULL;
1465+
14511466
slurm_mutex_lock (&lua_lock);
14521467

14531468
rc = slurm_lua_loadscript(&L, "job_submit/lua",
@@ -1475,9 +1490,18 @@ extern int job_modify(job_desc_msg_t *job_desc, job_record_t *job_ptr,
14751490
lua_pushnumber(L, submit_uid);
14761491
slurm_lua_stack_dump(
14771492
"job_submit/lua", "job_modify, before lua_pcall", L);
1478-
if (lua_pcall(L, 4, 1, 0) != 0) {
1493+
if ((rc = slurm_lua_pcall(L, 4, 1, &err_str, __func__))) {
1494+
if (!err_str)
1495+
err_str = xstrdup_printf("Lua %s failed: %s",
1496+
lua_script_path,
1497+
slurm_strerror(rc));
1498+
14791499
error("%s/lua: %s: %s",
1480-
__func__, lua_script_path, lua_tostring(L, -1));
1500+
__func__, lua_script_path, err_str);
1501+
1502+
/* Replace user_msg as err_msg with Lua error */
1503+
xfree(user_msg);
1504+
SWAP(*err_msg, err_str);
14811505
} else {
14821506
if (lua_isnumber(L, -1)) {
14831507
rc = lua_tonumber(L, -1);
@@ -1496,5 +1520,7 @@ extern int job_modify(job_desc_msg_t *job_desc, job_record_t *job_ptr,
14961520
}
14971521

14981522
out: slurm_mutex_unlock (&lua_lock);
1523+
1524+
xfree(err_str);
14991525
return rc;
15001526
}

0 commit comments

Comments
 (0)