From 048b75fa9ad4e10e4357e3e0a7db06af5c3f3601 Mon Sep 17 00:00:00 2001 From: "Dong H. Ahn" Date: Tue, 20 Mar 2018 15:08:43 -0700 Subject: [PATCH] sched: Add errno for an error that leads to a module exit --- sched/sched.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sched/sched.c b/sched/sched.c index fc7d23a49..4779de7f6 100644 --- a/sched/sched.c +++ b/sched/sched.c @@ -700,12 +700,16 @@ static int load_resources (ssrvctx_t *ctx) case RSREADER_RESRC_EMUL: if (rsreader_resrc_bulkload (ctx->rsapi, path, uri) != 0) { flux_log (ctx->h, LOG_ERR, "failed to load resrc"); + errno = EINVAL; goto done; } else if (build_hwloc_rs2rank (ctx, r_mode) != 0) { flux_log (ctx->h, LOG_ERR, "failed to build rs2rank"); + if (errno != 0) + errno = EINVAL; goto done; } else if (rsreader_force_link2rank (ctx->rsapi, ctx->machs) != 0) { flux_log (ctx->h, LOG_ERR, "failed to force a link to a rank"); + errno = EINVAL; goto done; } flux_log (ctx->h, LOG_INFO, "loaded resrc"); @@ -715,9 +719,11 @@ static int load_resources (ssrvctx_t *ctx) case RSREADER_RESRC: if (rsreader_resrc_bulkload (ctx->rsapi, path, uri) != 0) { flux_log (ctx->h, LOG_ERR, "failed to load resrc"); + errno = EINVAL; goto done; } else if (build_hwloc_rs2rank (ctx, r_mode) != 0) { flux_log (ctx->h, LOG_ERR, "failed to build rs2rank"); + errno = EINVAL; goto done; } flux_log (ctx->h, LOG_INFO, "resrc constructed using RDL "); @@ -732,7 +738,8 @@ static int load_resources (ssrvctx_t *ctx) free (e_str); } if (ctx->arg.fail_on_error) - goto done; + goto done; /* don't set errno - only needed for testing */ + flux_log (ctx->h, LOG_INFO, "rebuild resrc using hwloc"); resrc_tree_t *mismatch_root = resrc_tree_root (ctx->rsapi); if (mismatch_root) @@ -748,6 +755,7 @@ static int load_resources (ssrvctx_t *ctx) case RSREADER_HWLOC: if (build_hwloc_rs2rank (ctx, r_mode) != 0) { flux_log (ctx->h, LOG_ERR, "failed to load resrc using hwloc"); + errno = EINVAL; goto done; } flux_log (ctx->h, LOG_INFO, "resrc constructed using hwloc");