Skip to content

Commit

Permalink
Apply clang formatting
Browse files Browse the repository at this point in the history
Problem: The formatting did not pass the CI code formatting check.

Apply the required changes.
  • Loading branch information
jacobtkeio committed Aug 30, 2024
1 parent 066d516 commit 3efa3f6
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 116 deletions.
36 changes: 16 additions & 20 deletions resource/modules/feasibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ MOD_NAME ("sched-fluxion-feasibility");
////////////////////////////////////////////////////////////////////////////////

static void feasibility_request_cb (flux_t *h,
flux_msg_handler_t *w,
const flux_msg_t *msg,
void *arg);
flux_msg_handler_t *w,
const flux_msg_t *msg,
void *arg);

static const struct flux_msg_handler_spec htab[] =
{{FLUX_MSGTYPE_REQUEST, "feasibility.check", feasibility_request_cb, 0},
Expand Down Expand Up @@ -102,11 +102,7 @@ static int process_config_file (std::shared_ptr<resource_ctx_t> &ctx)
int rc = 0;
json_t *conf = nullptr;

if ((rc = flux_conf_unpack (flux_get_conf (ctx->h),
nullptr,
"{ s?:o }",
mod_name,
&conf))
if ((rc = flux_conf_unpack (flux_get_conf (ctx->h), nullptr, "{ s?:o }", mod_name, &conf))
< 0) {
flux_log_error (ctx->h, "%s: flux_conf_unpack", __FUNCTION__);
return rc;
Expand Down Expand Up @@ -153,7 +149,7 @@ static std::shared_ptr<resource_ctx_t> init_module (flux_t *h, int argc, char **
std::shared_ptr<resource_ctx_t> ctx = nullptr;
flux_future_t *f = nullptr;
uint32_t rank = 1;

if (!(ctx = getctx (h))) {
flux_log (h, LOG_ERR, "%s: can't allocate the context", __FUNCTION__);
return nullptr;
Expand Down Expand Up @@ -188,7 +184,7 @@ static std::shared_ptr<resource_ctx_t> init_module (flux_t *h, int argc, char **
goto error;
}
return ctx;

error:
return nullptr;
}
Expand All @@ -198,9 +194,9 @@ static std::shared_ptr<resource_ctx_t> init_module (flux_t *h, int argc, char **
////////////////////////////////////////////////////////////////////////////////

static void feasibility_request_cb (flux_t *h,
flux_msg_handler_t *w,
const flux_msg_t *msg,
void *arg)
flux_msg_handler_t *w,
const flux_msg_t *msg,
void *arg)
{
int64_t at = 0;
int64_t now = 0;
Expand Down Expand Up @@ -275,7 +271,7 @@ static int init_resource_graph (std::shared_ptr<resource_ctx_t> &ctx)
if (!(ctx->writers = match_writers_factory_t::create (format)))
return -1;

//TODO remove?
// TODO remove?
if (ctx->opts.get_opt ().is_prune_filters_set ()
&& ctx->matcher->set_pruning_types_w_spec (ctx->matcher->dom_subsystem (),
ctx->opts.get_opt ().get_prune_filters ())
Expand All @@ -294,11 +290,11 @@ static int init_resource_graph (std::shared_ptr<resource_ctx_t> &ctx)
return -1;
}

//TODO remove?
// Perform the initial status marking only when "up" rankset is available
// Rankless reader cases (required for testing e.g., GRUG) must not
// execute the following branch.
// Use ctx->update_f != nullptr to differentiate
// TODO remove?
// Perform the initial status marking only when "up" rankset is available
// Rankless reader cases (required for testing e.g., GRUG) must not
// execute the following branch.
// Use ctx->update_f != nullptr to differentiate
if (ctx->update_f) {
if (mark (ctx, "all", resource_pool_t::status_t::DOWN) < 0) {
flux_log (ctx->h, LOG_ERR, "%s: mark (down)", __FUNCTION__);
Expand Down Expand Up @@ -332,7 +328,7 @@ extern "C" int mod_main (flux_t *h, int argc, char **argv)
flux_log (h, LOG_ERR, "%s: can't initialize feasibility module", __FUNCTION__);
goto done;
}

// Because mod_main is always active, the following is safe.
flux_aux_set (h, mod_name, &ctx, NULL);
flux_log (h, LOG_DEBUG, "%s: feasibility module starting", __FUNCTION__);
Expand Down
21 changes: 8 additions & 13 deletions resource/modules/resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,7 @@ static int process_config_file (std::shared_ptr<resource_ctx_t> &ctx)
int rc = 0;
json_t *conf = nullptr;

if ((rc = flux_conf_unpack (flux_get_conf (ctx->h),
nullptr,
"{ s?:o }",
mod_name,
&conf))
if ((rc = flux_conf_unpack (flux_get_conf (ctx->h), nullptr, "{ s?:o }", mod_name, &conf))
< 0) {
flux_log_error (ctx->h, "%s: flux_conf_unpack", __FUNCTION__);
return rc;
Expand Down Expand Up @@ -1027,20 +1023,20 @@ static void notify_request_cb (flux_t *h, flux_msg_handler_t *w, const flux_msg_
// This is guaranteed by the order of mod_main:
// init_resource_graph runs before flux_reactor_run.
if (flux_respond_pack (ctx->h,
msg,
"{s:O s:f}",
"resources",
ctx->m_acquired_resources.get (),
"expiration",
ctx->m_acquired_resources_expiration)
msg,
"{s:O s:f}",
"resources",
ctx->m_acquired_resources.get (),
"expiration",
ctx->m_acquired_resources_expiration)
< 0) {
flux_log_error (ctx->h, "%s: flux_respond_pack", __FUNCTION__);
}

// Add msg as a subscriber to resource UP/DOWN updates
m->set_msg (msg);
auto ret = ctx->notify_msgs.insert (
std::pair<std::string, std::shared_ptr<msg_wrap_t>> (route, m));
std::pair<std::string, std::shared_ptr<msg_wrap_t>> (route, m));
if (!ret.second) {
errno = EEXIST;
flux_log_error (h, "%s: insert", __FUNCTION__);
Expand Down Expand Up @@ -1352,7 +1348,6 @@ static int init_resource_graph (std::shared_ptr<resource_ctx_t> &ctx)
return 0;
}


////////////////////////////////////////////////////////////////////////////////
// Module Main
////////////////////////////////////////////////////////////////////////////////
Expand Down
102 changes: 49 additions & 53 deletions resource/modules/resource_match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,13 @@ static void update_resource (flux_future_t *f, void *arg)
&down,
"expiration",
&expiration)
< 0) {
< 0) {
flux_log_error (ctx->h,
ctx->m_acquire_resources_from_core \
? "%s: exiting due to resource.acquire failure" \
: "%s: exiting due to sched-fluxion-resource.notify failure",
ctx->m_acquire_resources_from_core ? "%s: exiting due to resource.acquire "
"failure"
: "%s: exiting due to "
"sched-fluxion-resource.notify "
"failure",
__FUNCTION__);
flux_reactor_stop (flux_get_reactor (ctx->h)); /* Cancels notify msgs */
goto done;
Expand Down Expand Up @@ -266,7 +268,8 @@ static void update_resource (flux_future_t *f, void *arg)
ctx->set_update_rc (rc);
}

static void update_resource_no_up_down (flux_future_t *f, void *arg) {
static void update_resource_no_up_down (flux_future_t *f, void *arg)
{
int rc = -1;

std::shared_ptr<resource_ctx_t> &ctx = *(static_cast<std::shared_ptr<resource_ctx_t> *> (arg));
Expand All @@ -287,17 +290,15 @@ static int populate_resource_db_acquire (std::shared_ptr<resource_ctx_t> &ctx)
json_t *o = NULL;

// If this module is not getting resources from core, use
// sched-fluxion-resource.notify instead of resource.acquire to avoid
// sched-fluxion-resource.notify instead of resource.acquire to avoid
// using more than one resource.acquire RPC, which is not allowed
if (!(ctx->update_f =
flux_rpc (ctx->h,
ctx->m_acquire_resources_from_core \
? "resource.acquire" \
: "sched-fluxion-resource.notify",
NULL,
FLUX_NODEID_ANY,
FLUX_RPC_STREAMING)))
{
if (!(ctx->update_f = flux_rpc (ctx->h,
ctx->m_acquire_resources_from_core ? "resource.acquire"
: "sched-fluxion-resource."
"notify",
NULL,
FLUX_NODEID_ANY,
FLUX_RPC_STREAMING))) {
flux_log_error (ctx->h, "%s: flux_rpc", __FUNCTION__);
goto done;
}
Expand All @@ -311,24 +312,20 @@ static int populate_resource_db_acquire (std::shared_ptr<resource_ctx_t> &ctx)
// Only add full update_resource callback if the module needs UP/DOWN updates
// Otherwise, add update_resource_no_up_down callback to get error updates
if (ctx->m_get_up_down_updates) {
if (rc = flux_future_then (ctx->update_f,
-1.0,
update_resource,
static_cast<void *> (&ctx))
< 0) {
if (rc = flux_future_then (ctx->update_f, -1.0, update_resource, static_cast<void *> (&ctx))
< 0) {
flux_log_error (ctx->h, "%s: flux_future_then", __FUNCTION__);
goto done;
}
} else {
if (rc = flux_future_then (ctx->update_f,
-1.0,
update_resource_no_up_down,
-1.0,
update_resource_no_up_down,
static_cast<void *> (&ctx))
< 0) {
< 0) {
flux_log_error (ctx->h, "%s: flux_future_then", __FUNCTION__);
goto done;
}

}

done:
Expand Down Expand Up @@ -360,9 +357,10 @@ int populate_resource_db (std::shared_ptr<resource_ctx_t> &ctx)
}
flux_log (ctx->h,
LOG_DEBUG,
ctx->m_acquire_resources_from_core \
? "%s: loaded resources from core's resource.acquire" \
: "%s: loaded resources from sched-fluxion-resource.notify",
ctx->m_acquire_resources_from_core ? "%s: loaded resources from core's "
"resource.acquire"
: "%s: loaded resources from "
"sched-fluxion-resource.notify",
__FUNCTION__);
}

Expand Down Expand Up @@ -1077,18 +1075,16 @@ static int mark_now (std::shared_ptr<resource_ctx_t> &ctx,
return rc;
}

int mark (std::shared_ptr<resource_ctx_t> &ctx,
const char *ids,
resource_pool_t::status_t status)
int mark (std::shared_ptr<resource_ctx_t> &ctx, const char *ids, resource_pool_t::status_t status)
{
return (ctx->traverser->is_initialized ()) ? mark_now (ctx, ids, status)
: mark_lazy (ctx, ids, status);
}

int update_resource_db (std::shared_ptr<resource_ctx_t> &ctx,
json_t *resources,
const char *up,
const char *down)
json_t *resources,
const char *up,
const char *down)
{
int rc = 0;
// TODO Will need to get duration update and set graph metadata when
Expand Down Expand Up @@ -1393,14 +1389,14 @@ static int run (std::shared_ptr<resource_ctx_t> &ctx,
}

int run_match (std::shared_ptr<resource_ctx_t> &ctx,
int64_t jobid,
const char *cmd,
const std::string &jstr,
int64_t *now,
int64_t *at,
double *overhead,
std::stringstream &o,
flux_error_t *errp)
int64_t jobid,
const char *cmd,
const std::string &jstr,
int64_t *now,
int64_t *at,
double *overhead,
std::stringstream &o,
flux_error_t *errp)
{
int rc = 0;
std::chrono::time_point<std::chrono::system_clock> start;
Expand Down Expand Up @@ -1451,11 +1447,11 @@ int run_match (std::shared_ptr<resource_ctx_t> &ctx,
}

int run_update (std::shared_ptr<resource_ctx_t> &ctx,
int64_t jobid,
const char *R,
int64_t &at,
double &overhead,
std::stringstream &o)
int64_t jobid,
const char *R,
int64_t &at,
double &overhead,
std::stringstream &o)
{
int rc = 0;
uint64_t duration = 0;
Expand Down Expand Up @@ -1493,10 +1489,10 @@ int run_update (std::shared_ptr<resource_ctx_t> &ctx,
}

int run_remove (std::shared_ptr<resource_ctx_t> &ctx,
int64_t jobid,
const char *R,
bool part_cancel,
bool &full_removal)
int64_t jobid,
const char *R,
bool part_cancel,
bool &full_removal)
{
int rc = -1;
dfu_traverser_t &tr = *(ctx->traverser);
Expand Down Expand Up @@ -1547,9 +1543,9 @@ int run_remove (std::shared_ptr<resource_ctx_t> &ctx,
}

int run_find (std::shared_ptr<resource_ctx_t> &ctx,
const std::string &criteria,
const std::string &format_str,
json_t **R)
const std::string &criteria,
const std::string &format_str,
json_t **R)
{
int rc = -1;
json_t *o = nullptr;
Expand Down
Loading

0 comments on commit 3efa3f6

Please sign in to comment.