Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle errors from cluster_status #3735

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion daemons/execd/cts-exec-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ generate_params(void)
pcmk__set_scheduler_flags(scheduler, pcmk__sched_no_counts);
scheduler->input = cib_xml_copy;
scheduler->priv->now = crm_time_new(NULL);
cluster_status(scheduler);
pcmk_unpack_scheduler_input(scheduler);

// Find resource in CIB
rsc = pe_find_resource_with_flags(scheduler->priv->resources,
Expand Down
3 changes: 0 additions & 3 deletions include/crm/pengine/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ const char *rsc_printable_id(const pcmk_resource_t *rsc);

int pcmk_unpack_scheduler_input(pcmk_scheduler_t *scheduler);

// NOTE: sbd (as of at least 1.5.2) uses this
gboolean cluster_status(pcmk_scheduler_t *scheduler);

// NOTE: sbd (as of at least 1.5.2) uses this
pcmk_scheduler_t *pe_new_working_set(void);

Expand Down
3 changes: 3 additions & 0 deletions include/crm/pengine/status_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ extern "C" {
* release.
*/

// NOTE: sbd (as of at least 1.5.2) uses this
gboolean cluster_status(pcmk_scheduler_t *scheduler);
clumens marked this conversation as resolved.
Show resolved Hide resolved

// NOTE: sbd (as of at least 1.5.2) uses this
//! \deprecated Use pcmk_find_node() with scheduler object instead
pcmk_node_t *pe_find_node(const GList *node_list, const char *node_name);
Expand Down
4 changes: 2 additions & 2 deletions lib/pacemaker/pcmk_scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ unpack_cib(xmlNode *cib, unsigned long long flags, pcmk_scheduler_t *scheduler)

pcmk__set_scheduler_flags(scheduler, flags);
scheduler->input = cib;
cluster_status(scheduler); // Sets pcmk__sched_have_status
pcmk_unpack_scheduler_input(scheduler); // Sets pcmk__sched_have_status
}

/*!
Expand Down Expand Up @@ -873,7 +873,7 @@ pcmk__init_scheduler(pcmk__output_t *out, xmlNodePtr input, const crm_time_t *da
}

// Unpack everything
cluster_status(new_scheduler);
pcmk_unpack_scheduler_input(new_scheduler);
*scheduler = new_scheduler;

return pcmk_rc_ok;
Expand Down
6 changes: 3 additions & 3 deletions lib/pacemaker/pcmk_simulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ pcmk__simulate(pcmk_scheduler_t *scheduler, pcmk__output_t *out,
}

reset(scheduler, input, out, use_date, flags);
cluster_status(scheduler);
pcmk_unpack_scheduler_input(scheduler);

if (!out->is_quiet(out)) {
const bool show_pending = pcmk_is_set(flags, pcmk_sim_show_pending);
Expand Down Expand Up @@ -862,7 +862,7 @@ pcmk__simulate(pcmk_scheduler_t *scheduler, pcmk__output_t *out,

cleanup_calculations(scheduler);
reset(scheduler, input, out, use_date, flags);
cluster_status(scheduler);
pcmk_unpack_scheduler_input(scheduler);
}

if (input_file != NULL) {
Expand Down Expand Up @@ -972,7 +972,7 @@ pcmk__simulate(pcmk_scheduler_t *scheduler, pcmk__output_t *out,
pcmk__set_scheduler_flags(scheduler, pcmk__sched_show_utilization);
}

cluster_status(scheduler);
pcmk_unpack_scheduler_input(scheduler);
print_cluster_status(scheduler, 0, section_opts, "Revised Cluster Status",
true);

Expand Down
2 changes: 1 addition & 1 deletion lib/pacemaker/pcmk_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pcmk__output_cluster_status(pcmk_scheduler_t *scheduler, stonith_t *stonith,

pe_reset_working_set(scheduler);
scheduler->input = cib_copy;
cluster_status(scheduler);
pcmk_unpack_scheduler_input(scheduler);

/* Unpack constraints if any section will need them
* (tickets may be referenced in constraints but not granted yet,
Expand Down
12 changes: 6 additions & 6 deletions lib/pengine/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,6 @@ pcmk_unpack_scheduler_input(pcmk_scheduler_t *scheduler)
return pcmk_rc_ok;
}

gboolean
cluster_status(pcmk_scheduler_t * scheduler)
{
return pcmk_unpack_scheduler_input(scheduler) == pcmk_rc_ok;
}

/*!
* \internal
* \brief Free a list of pcmk_resource_t
Expand Down Expand Up @@ -537,6 +531,12 @@ pe_find_node_id(const GList *nodes, const char *id)

#include <crm/pengine/status_compat.h>

gboolean
cluster_status(pcmk_scheduler_t * scheduler)
{
return pcmk_unpack_scheduler_input(scheduler) == pcmk_rc_ok;
}

/*!
* \brief Find a node by name in a list of nodes
*
Expand Down
2 changes: 1 addition & 1 deletion lib/pengine/tests/native/native_find_rsc_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ setup(void **state) {
pcmk__set_scheduler_flags(scheduler, pcmk__sched_no_counts);
scheduler->input = input;

cluster_status(scheduler);
pcmk_unpack_scheduler_input(scheduler);

/* Get references to the cluster nodes so we don't have to find them repeatedly. */
cluster01 = pcmk_find_node(scheduler, "cluster01");
Expand Down
2 changes: 1 addition & 1 deletion lib/pengine/tests/native/pe_base_name_eq_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ setup(void **state) {
pcmk__set_scheduler_flags(scheduler, pcmk__sched_no_counts);
scheduler->input = input;

cluster_status(scheduler);
pcmk_unpack_scheduler_input(scheduler);

/* Get references to several resources we use frequently. */
for (GList *iter = scheduler->priv->resources;
Expand Down
4 changes: 2 additions & 2 deletions tools/crm_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ clear_constraints(pcmk__output_t *out)
}

scheduler->input = cib_xml;
cluster_status(scheduler);
pcmk_unpack_scheduler_input(scheduler);

after = build_constraint_list(scheduler->input);
remaining = pcmk__subtract_lists(before, after, (GCompareFunc) strcmp);
Expand Down Expand Up @@ -993,7 +993,7 @@ initialize_scheduler_data(xmlNode **cib_xml_orig)
return rc;
}

cluster_status(scheduler);
pcmk_unpack_scheduler_input(scheduler);
return pcmk_rc_ok;
}

Expand Down
2 changes: 1 addition & 1 deletion tools/crm_resource_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ update_dataset(cib_t *cib, pcmk_scheduler_t *scheduler, xmlNode **cib_xml_orig,

pcmk__xml_free(*cib_xml_orig);
*cib_xml_orig = xml;
cluster_status(scheduler);
pcmk_unpack_scheduler_input(scheduler);
}

done:
Expand Down
2 changes: 1 addition & 1 deletion tools/crm_ticket.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ main(int argc, char **argv)
scheduler->input = cib_xml_copy;
scheduler->priv->now = crm_time_new(NULL);

cluster_status(scheduler);
pcmk_unpack_scheduler_input(scheduler);

/* For recording the tickets that are referenced in PCMK_XE_RSC_TICKET
* constraints but have never been granted yet.
Expand Down