Skip to content

Commit

Permalink
Merge pull request #1323 from milroy/wrap-error-reset
Browse files Browse the repository at this point in the history
Clear traverser before traversal operations in dfu
  • Loading branch information
mergify[bot] authored Jan 10, 2025
2 parents 4b9cbec + 73222a7 commit 5ae7459
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
3 changes: 0 additions & 3 deletions resource/modules/resource_match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,6 @@ static int mark_now (std::shared_ptr<resource_ctx_t> &ctx,
"%s: traverser::mark: %s",
__FUNCTION__,
ctx->traverser->err_message ().c_str ());
ctx->traverser->clear_err_message ();
goto done;
}
flux_log (ctx->h,
Expand Down Expand Up @@ -2685,7 +2684,6 @@ static int run_find (std::shared_ptr<resource_ctx_t> &ctx,
"%s: %s",
__FUNCTION__,
ctx->traverser->err_message ().c_str ());
ctx->traverser->clear_err_message ();
}
goto error;
}
Expand Down Expand Up @@ -2956,7 +2954,6 @@ static void set_status_request_cb (flux_t *h,
"%s: traverser::mark: %s",
__FUNCTION__,
ctx->traverser->err_message ().c_str ());
ctx->traverser->clear_err_message ();
errmsg = "Failed to set status of resource vertex";
goto error;
}
Expand Down
2 changes: 0 additions & 2 deletions resource/reapi/bindings/c++/reapi_cli_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,6 @@ int resource_query_t::remove_job (const uint64_t jobid)
}
} else {
m_err_msg += traverser->err_message ();
traverser->clear_err_message ();
}
return rc;
}
Expand Down Expand Up @@ -716,7 +715,6 @@ int resource_query_t::remove_job (const uint64_t jobid, const std::string &R, bo
}
} else {
m_err_msg += traverser->err_message ();
traverser->clear_err_message ();
}

return rc;
Expand Down
21 changes: 21 additions & 0 deletions resource/traversers/dfu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ bool dfu_traverser_t::is_initialized () const

int dfu_traverser_t::initialize ()
{
// Clear the error message to disambiguate errors
clear_err_message ();

int rc = 0;
vtx_t root;
if (!get_graph () || !get_graph_db () || !get_match_cb ()) {
Expand Down Expand Up @@ -350,6 +353,9 @@ int dfu_traverser_t::run (Jobspec::Jobspec &jobspec,
int64_t jobid,
int64_t *at)
{
// Clear the error message to disambiguate errors
clear_err_message ();

subsystem_t dom = get_match_cb ()->dom_subsystem ();
graph_duration_t graph_duration = get_graph_db ()->metadata.graph_duration;
if (!get_graph () || !get_graph_db ()
Expand Down Expand Up @@ -413,6 +419,9 @@ int dfu_traverser_t::run (const std::string &str,
int64_t at,
uint64_t duration)
{
// Clear the error message to disambiguate errors
clear_err_message ();

if (!get_match_cb () || !get_graph () || !get_graph_db () || !reader || at < 0) {
errno = EINVAL;
return -1;
Expand All @@ -435,11 +444,16 @@ int dfu_traverser_t::run (const std::string &str,

int dfu_traverser_t::find (std::shared_ptr<match_writers_t> &writers, const std::string &criteria)
{
// Clear the error message to disambiguate errors
clear_err_message ();
return detail::dfu_impl_t::find (writers, criteria);
}

int dfu_traverser_t::remove (int64_t jobid)
{
// Clear the error message to disambiguate errors
clear_err_message ();

subsystem_t dom = get_match_cb ()->dom_subsystem ();
if (!get_graph () || !get_graph_db ()
|| get_graph_db ()->metadata.roots.find (dom) == get_graph_db ()->metadata.roots.end ()
Expand All @@ -457,6 +471,9 @@ int dfu_traverser_t::remove (const std::string &R_to_cancel,
int64_t jobid,
bool &full_cancel)
{
// Clear the error message to disambiguate errors
clear_err_message ();

subsystem_t dom = get_match_cb ()->dom_subsystem ();
if (!get_graph () || !get_graph_db ()
|| get_graph_db ()->metadata.roots.find (dom) == get_graph_db ()->metadata.roots.end ()
Expand All @@ -471,11 +488,15 @@ int dfu_traverser_t::remove (const std::string &R_to_cancel,

int dfu_traverser_t::mark (const std::string &root_path, resource_pool_t::status_t status)
{
// Clear the error message to disambiguate errors
clear_err_message ();
return detail::dfu_impl_t::mark (root_path, status);
}

int dfu_traverser_t::mark (std::set<int64_t> &ranks, resource_pool_t::status_t status)
{
// Clear the error message to disambiguate errors
clear_err_message ();
return detail::dfu_impl_t::mark (ranks, status);
}

Expand Down
5 changes: 0 additions & 5 deletions resource/utilities/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ static int do_remove (std::shared_ptr<resource_context_t> &ctx, int64_t jobid)
}
} else {
std::cout << ctx->traverser->err_message ();
ctx->traverser->clear_err_message ();
}
return rc;
}
Expand All @@ -135,7 +134,6 @@ static int do_partial_remove (std::shared_ptr<resource_context_t> &ctx,
}
} else {
std::cout << ctx->traverser->err_message ();
ctx->traverser->clear_err_message ();
}
return rc;
}
Expand Down Expand Up @@ -295,7 +293,6 @@ static int run_match (std::shared_ptr<resource_context_t> &ctx,

if (ctx->traverser->err_message () != "") {
std::cerr << "ERROR: " << ctx->traverser->err_message ();
ctx->traverser->clear_err_message ();
}
if ((rc = ctx->writers->emit (o)) < 0) {
std::cerr << "ERROR: match writer emit: " << strerror (errno) << std::endl;
Expand Down Expand Up @@ -436,7 +433,6 @@ static int update_run (std::shared_ptr<resource_context_t> &ctx,
std::cerr << "ERROR: traverser run () returned error " << std::endl;
if (ctx->traverser->err_message () != "") {
std::cerr << "ERROR: " << ctx->traverser->err_message ();
ctx->traverser->clear_err_message ();
}
}
}
Expand Down Expand Up @@ -619,7 +615,6 @@ int cmd_find (std::shared_ptr<resource_context_t> &ctx, std::vector<std::string>
if ((rc = ctx->traverser->find (ctx->writers, criteria)) < 0) {
if (ctx->traverser->err_message () != "") {
std::cerr << "ERROR: " << ctx->traverser->err_message ();
ctx->traverser->clear_err_message ();
}
goto done;
}
Expand Down

0 comments on commit 5ae7459

Please sign in to comment.