From 3afc8b64384e748b0fa256a54c7ffe574949cc1b Mon Sep 17 00:00:00 2001 From: Reid Wahl Date: Tue, 29 Oct 2024 22:19:42 -0700 Subject: [PATCH 01/13] Refactor: tools: Drop cli_resource_restart() cib_options argument It's always cib_sync_call. Signed-off-by: Reid Wahl --- tools/crm_resource.c | 2 +- tools/crm_resource.h | 2 +- tools/crm_resource_runtime.c | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/crm_resource.c b/tools/crm_resource.c index 271c74f8b5c..fd0306a740d 100644 --- a/tools/crm_resource.c +++ b/tools/crm_resource.c @@ -1840,7 +1840,7 @@ main(int argc, char **argv) */ rc = cli_resource_restart(out, rsc, node, options.move_lifetime, options.timeout_ms, cib_conn, - cib_sync_call, options.promoted_role_only, + options.promoted_role_only, options.force); break; diff --git a/tools/crm_resource.h b/tools/crm_resource.h index de85a5b3585..70298349e8f 100644 --- a/tools/crm_resource.h +++ b/tools/crm_resource.h @@ -98,7 +98,7 @@ int cli_cleanup_all(pcmk_ipc_api_t *controld_api, const char *node_name, pcmk_scheduler_t *scheduler); int cli_resource_restart(pcmk__output_t *out, pcmk_resource_t *rsc, const pcmk_node_t *node, const char *move_lifetime, - guint timeout_ms, cib_t *cib, int cib_options, + guint timeout_ms, cib_t *cib, gboolean promoted_role_only, gboolean force); int cli_resource_move(const pcmk_resource_t *rsc, const char *rsc_id, const char *host_name, const char *move_lifetime, diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c index 54defef53ec..ca6029e4abe 100644 --- a/tools/crm_resource_runtime.c +++ b/tools/crm_resource_runtime.c @@ -1555,8 +1555,6 @@ wait_time_estimate(pcmk_scheduler_t *scheduler, const GList *resources) * used; if 0, it will be calculated based on * the resource timeout) * \param[in,out] cib Connection to the CIB manager - * \param[in] cib_options Group of enum cib_call_options flags to - * use with CIB calls * \param[in] promoted_role_only If true, limit to promoted instances * \param[in] force If true, apply only to requested instance * if part of a collective resource @@ -1566,8 +1564,8 @@ wait_time_estimate(pcmk_scheduler_t *scheduler, const GList *resources) int cli_resource_restart(pcmk__output_t *out, pcmk_resource_t *rsc, const pcmk_node_t *node, const char *move_lifetime, - guint timeout_ms, cib_t *cib, int cib_options, - gboolean promoted_role_only, gboolean force) + guint timeout_ms, cib_t *cib, gboolean promoted_role_only, + gboolean force) { int rc = pcmk_rc_ok; int lpc = 0; @@ -1691,7 +1689,7 @@ cli_resource_restart(pcmk__output_t *out, pcmk_resource_t *rsc, /* Stop the clone or bundle instance by banning it from the host */ out->quiet = true; rc = cli_resource_ban(out, lookup_id, host, move_lifetime, cib, - cib_options, promoted_role_only, + cib_sync_call, promoted_role_only, PCMK_ROLE_PROMOTED); } else { xmlNode *xml_search = NULL; @@ -1789,7 +1787,8 @@ cli_resource_restart(pcmk__output_t *out, pcmk_resource_t *rsc, } if (stop_via_ban) { - rc = cli_resource_clear(lookup_id, host, NULL, cib, cib_options, true, force); + rc = cli_resource_clear(lookup_id, host, NULL, cib, cib_sync_call, true, + force); } else if (orig_target_role) { rc = cli_resource_update_attribute(rsc, rsc_id, NULL, @@ -1802,7 +1801,7 @@ cli_resource_restart(pcmk__output_t *out, pcmk_resource_t *rsc, rc = cli_resource_delete_attribute(rsc, rsc_id, NULL, PCMK_XE_META_ATTRIBUTES, NULL, PCMK_META_TARGET_ROLE, cib, - cib_options, force); + cib_sync_call, force); } if(rc != pcmk_rc_ok) { @@ -1874,7 +1873,8 @@ cli_resource_restart(pcmk__output_t *out, pcmk_resource_t *rsc, failure: if (stop_via_ban) { - cli_resource_clear(lookup_id, host, NULL, cib, cib_options, true, force); + cli_resource_clear(lookup_id, host, NULL, cib, cib_sync_call, true, + force); } else if (orig_target_role) { cli_resource_update_attribute(rsc, rsc_id, NULL, PCMK_XE_META_ATTRIBUTES, NULL, @@ -1884,7 +1884,7 @@ cli_resource_restart(pcmk__output_t *out, pcmk_resource_t *rsc, } else { cli_resource_delete_attribute(rsc, rsc_id, NULL, PCMK_XE_META_ATTRIBUTES, NULL, - PCMK_META_TARGET_ROLE, cib, cib_options, + PCMK_META_TARGET_ROLE, cib, cib_sync_call, force); } From 5704f7b251963dbaf74a556926cad62014e3abb6 Mon Sep 17 00:00:00 2001 From: Reid Wahl Date: Tue, 29 Oct 2024 22:24:37 -0700 Subject: [PATCH 02/13] Refactor: tools: Drop cli_resource_move() cib_options argument It's always cib_sync_call. Signed-off-by: Reid Wahl --- tools/crm_resource.c | 3 +-- tools/crm_resource.h | 2 +- tools/crm_resource_runtime.c | 14 +++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tools/crm_resource.c b/tools/crm_resource.c index fd0306a740d..c80c542792b 100644 --- a/tools/crm_resource.c +++ b/tools/crm_resource.c @@ -1939,8 +1939,7 @@ main(int argc, char **argv) } else { rc = cli_resource_move(rsc, options.rsc_id, options.host_uname, options.move_lifetime, cib_conn, - cib_sync_call, scheduler, - options.promoted_role_only, + scheduler, options.promoted_role_only, options.force); } diff --git a/tools/crm_resource.h b/tools/crm_resource.h index 70298349e8f..7fdb9b3a6d9 100644 --- a/tools/crm_resource.h +++ b/tools/crm_resource.h @@ -102,7 +102,7 @@ int cli_resource_restart(pcmk__output_t *out, pcmk_resource_t *rsc, gboolean promoted_role_only, gboolean force); int cli_resource_move(const pcmk_resource_t *rsc, const char *rsc_id, const char *host_name, const char *move_lifetime, - cib_t *cib, int cib_options, pcmk_scheduler_t *scheduler, + cib_t *cib, pcmk_scheduler_t *scheduler, gboolean promoted_role_only, gboolean force); crm_exit_t cli_resource_execute_from_params(pcmk__output_t *out, const char *rsc_name, const char *rsc_class, const char *rsc_prov, diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c index ca6029e4abe..b4394d7e075 100644 --- a/tools/crm_resource_runtime.c +++ b/tools/crm_resource_runtime.c @@ -2317,8 +2317,8 @@ cli_resource_execute(pcmk_resource_t *rsc, const char *requested_name, int cli_resource_move(const pcmk_resource_t *rsc, const char *rsc_id, const char *host_name, const char *move_lifetime, cib_t *cib, - int cib_options, pcmk_scheduler_t *scheduler, - gboolean promoted_role_only, gboolean force) + pcmk_scheduler_t *scheduler, gboolean promoted_role_only, + gboolean force) { pcmk__output_t *out = scheduler->priv->out; int rc = pcmk_rc_ok; @@ -2393,16 +2393,16 @@ cli_resource_move(const pcmk_resource_t *rsc, const char *rsc_id, } /* Clear any previous prefer constraints across all nodes. */ - cli_resource_clear(rsc_id, NULL, scheduler->nodes, cib, cib_options, false, - force); + cli_resource_clear(rsc_id, NULL, scheduler->nodes, cib, cib_sync_call, + false, force); /* Clear any previous ban constraints on 'dest'. */ cli_resource_clear(rsc_id, dest->priv->name, scheduler->nodes, cib, - cib_options, TRUE, force); + cib_sync_call, TRUE, force); /* Record an explicit preference for 'dest' */ rc = cli_resource_prefer(out, rsc_id, dest->priv->name, move_lifetime, - cib, cib_options, promoted_role_only, + cib, cib_sync_call, promoted_role_only, PCMK_ROLE_PROMOTED); crm_trace("%s%s now prefers %s%s", @@ -2416,7 +2416,7 @@ cli_resource_move(const pcmk_resource_t *rsc, const char *rsc_id, /* Ban the original location if possible */ if(current) { (void)cli_resource_ban(out, rsc_id, current->priv->name, - move_lifetime, cib, cib_options, + move_lifetime, cib, cib_sync_call, promoted_role_only, PCMK_ROLE_PROMOTED); } else if(count > 1) { out->info(out, "Resource '%s' is currently %s in %d locations. " From 30f0b2e6cf30364061f77272ca1864b76ab4f38e Mon Sep 17 00:00:00 2001 From: Reid Wahl Date: Tue, 29 Oct 2024 22:28:23 -0700 Subject: [PATCH 03/13] Refactor: tools: Drop cli_resource_ban() cib_options argument It's always cib_sync_call. Signed-off-by: Reid Wahl --- tools/crm_resource.c | 6 +++--- tools/crm_resource.h | 2 +- tools/crm_resource_ban.c | 8 ++++---- tools/crm_resource_runtime.c | 7 +++---- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/tools/crm_resource.c b/tools/crm_resource.c index c80c542792b..3d6d592db7b 100644 --- a/tools/crm_resource.c +++ b/tools/crm_resource.c @@ -858,7 +858,7 @@ ban_or_move(pcmk__output_t *out, pcmk_resource_t *rsc, if (nactive == 1) { rc = cli_resource_ban(out, options.rsc_id, current->priv->name, - move_lifetime, cib_conn, cib_sync_call, + move_lifetime, cib_conn, options.promoted_role_only, PCMK_ROLE_PROMOTED); } else if (pcmk_is_set(rsc->flags, pcmk__rsc_promotable)) { @@ -878,7 +878,7 @@ ban_or_move(pcmk__output_t *out, pcmk_resource_t *rsc, if(count == 1 && current) { rc = cli_resource_ban(out, options.rsc_id, current->priv->name, - move_lifetime, cib_conn, cib_sync_call, + move_lifetime, cib_conn, options.promoted_role_only, PCMK_ROLE_PROMOTED); @@ -1958,7 +1958,7 @@ main(int argc, char **argv) } else { rc = cli_resource_ban(out, options.rsc_id, node->priv->name, options.move_lifetime, cib_conn, - cib_sync_call, options.promoted_role_only, + options.promoted_role_only, PCMK_ROLE_PROMOTED); } diff --git a/tools/crm_resource.h b/tools/crm_resource.h index 7fdb9b3a6d9..4cda340b903 100644 --- a/tools/crm_resource.h +++ b/tools/crm_resource.h @@ -66,7 +66,7 @@ int cli_resource_prefer(pcmk__output_t *out, const char *rsc_id, const char *hos const char *move_lifetime, cib_t * cib_conn, int cib_options, gboolean promoted_role_only, const char *promoted_role); int cli_resource_ban(pcmk__output_t *out, const char *rsc_id, const char *host, - const char *move_lifetime, cib_t *cib_conn, int cib_options, + const char *move_lifetime, cib_t *cib_conn, gboolean promoted_role_only, const char *promoted_role); int cli_resource_clear(const char *rsc_id, const char *host, GList *allnodes, cib_t * cib_conn, int cib_options, bool clear_ban_constraints, gboolean force); diff --git a/tools/crm_resource_ban.c b/tools/crm_resource_ban.c index 128cf451274..8ada42f567b 100644 --- a/tools/crm_resource_ban.c +++ b/tools/crm_resource_ban.c @@ -59,7 +59,7 @@ parse_cli_lifetime(pcmk__output_t *out, const char *move_lifetime) // \return Standard Pacemaker return code int cli_resource_ban(pcmk__output_t *out, const char *rsc_id, const char *host, - const char *move_lifetime, cib_t * cib_conn, int cib_options, + const char *move_lifetime, cib_t *cib_conn, gboolean promoted_role_only, const char *promoted_role) { char *later_s = NULL; @@ -122,7 +122,7 @@ cli_resource_ban(pcmk__output_t *out, const char *rsc_id, const char *host, crm_log_xml_notice(fragment, "Modify"); rc = cib_conn->cmds->modify(cib_conn, PCMK_XE_CONSTRAINTS, fragment, - cib_options); + cib_sync_call); rc = pcmk_legacy2rc(rc); pcmk__xml_free(fragment); @@ -133,8 +133,8 @@ cli_resource_ban(pcmk__output_t *out, const char *rsc_id, const char *host, && (strcmp(promoted_role, PCMK_ROLE_PROMOTED) == 0)) { int banrc = cli_resource_ban(out, rsc_id, host, move_lifetime, - cib_conn, cib_options, promoted_role_only, - PCMK__ROLE_PROMOTED_LEGACY); + cib_conn, promoted_role_only, + PCMK__ROLE_PROMOTED_LEGACY); if (banrc == pcmk_rc_ok) { rc = banrc; } diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c index b4394d7e075..33e8a62ea34 100644 --- a/tools/crm_resource_runtime.c +++ b/tools/crm_resource_runtime.c @@ -1689,8 +1689,7 @@ cli_resource_restart(pcmk__output_t *out, pcmk_resource_t *rsc, /* Stop the clone or bundle instance by banning it from the host */ out->quiet = true; rc = cli_resource_ban(out, lookup_id, host, move_lifetime, cib, - cib_sync_call, promoted_role_only, - PCMK_ROLE_PROMOTED); + promoted_role_only, PCMK_ROLE_PROMOTED); } else { xmlNode *xml_search = NULL; @@ -2416,8 +2415,8 @@ cli_resource_move(const pcmk_resource_t *rsc, const char *rsc_id, /* Ban the original location if possible */ if(current) { (void)cli_resource_ban(out, rsc_id, current->priv->name, - move_lifetime, cib, cib_sync_call, - promoted_role_only, PCMK_ROLE_PROMOTED); + move_lifetime, cib, promoted_role_only, + PCMK_ROLE_PROMOTED); } else if(count > 1) { out->info(out, "Resource '%s' is currently %s in %d locations. " "One may now move to %s", From b8352dc99fd7b87b2721cf603d7af30e0a407118 Mon Sep 17 00:00:00 2001 From: Reid Wahl Date: Tue, 29 Oct 2024 22:30:39 -0700 Subject: [PATCH 04/13] Refactor: tools: Drop cli_resource_prefer() cib_options argument It's always cib_sync_call. Signed-off-by: Reid Wahl --- tools/crm_resource.h | 2 +- tools/crm_resource_ban.c | 8 ++++---- tools/crm_resource_runtime.c | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/crm_resource.h b/tools/crm_resource.h index 4cda340b903..1637c3e4fa5 100644 --- a/tools/crm_resource.h +++ b/tools/crm_resource.h @@ -63,7 +63,7 @@ resource_checks_t *cli_check_resource(pcmk_resource_t *rsc, char *role_s, /* ban */ int cli_resource_prefer(pcmk__output_t *out, const char *rsc_id, const char *host, - const char *move_lifetime, cib_t * cib_conn, int cib_options, + const char *move_lifetime, cib_t *cib_conn, gboolean promoted_role_only, const char *promoted_role); int cli_resource_ban(pcmk__output_t *out, const char *rsc_id, const char *host, const char *move_lifetime, cib_t *cib_conn, diff --git a/tools/crm_resource_ban.c b/tools/crm_resource_ban.c index 8ada42f567b..b6152999fb2 100644 --- a/tools/crm_resource_ban.c +++ b/tools/crm_resource_ban.c @@ -146,7 +146,7 @@ cli_resource_ban(pcmk__output_t *out, const char *rsc_id, const char *host, // \return Standard Pacemaker return code int cli_resource_prefer(pcmk__output_t *out,const char *rsc_id, const char *host, - const char *move_lifetime, cib_t *cib_conn, int cib_options, + const char *move_lifetime, cib_t *cib_conn, gboolean promoted_role_only, const char *promoted_role) { char *later_s = parse_cli_lifetime(out, move_lifetime); @@ -202,7 +202,7 @@ cli_resource_prefer(pcmk__output_t *out,const char *rsc_id, const char *host, crm_log_xml_info(fragment, "Modify"); rc = cib_conn->cmds->modify(cib_conn, PCMK_XE_CONSTRAINTS, fragment, - cib_options); + cib_sync_call); rc = pcmk_legacy2rc(rc); pcmk__xml_free(fragment); @@ -213,8 +213,8 @@ cli_resource_prefer(pcmk__output_t *out,const char *rsc_id, const char *host, && (strcmp(promoted_role, PCMK_ROLE_PROMOTED) == 0)) { int preferrc = cli_resource_prefer(out, rsc_id, host, move_lifetime, - cib_conn, cib_options, promoted_role_only, - PCMK__ROLE_PROMOTED_LEGACY); + cib_conn, promoted_role_only, + PCMK__ROLE_PROMOTED_LEGACY); if (preferrc == pcmk_rc_ok) { rc = preferrc; } diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c index 33e8a62ea34..4c10b90c0ab 100644 --- a/tools/crm_resource_runtime.c +++ b/tools/crm_resource_runtime.c @@ -2401,8 +2401,7 @@ cli_resource_move(const pcmk_resource_t *rsc, const char *rsc_id, /* Record an explicit preference for 'dest' */ rc = cli_resource_prefer(out, rsc_id, dest->priv->name, move_lifetime, - cib, cib_sync_call, promoted_role_only, - PCMK_ROLE_PROMOTED); + cib, promoted_role_only, PCMK_ROLE_PROMOTED); crm_trace("%s%s now prefers %s%s", rsc->id, (promoted_role_only? " (promoted)" : ""), From b6889f3247b7191f80e6ebeaeeb2a937c7f6ed25 Mon Sep 17 00:00:00 2001 From: Reid Wahl Date: Tue, 29 Oct 2024 22:38:31 -0700 Subject: [PATCH 05/13] Refactor: tools: Drop cli_resource_clear() cib_options argument It's always cib_sync_call. Signed-off-by: Reid Wahl --- tools/crm_resource.c | 4 ++-- tools/crm_resource.h | 3 ++- tools/crm_resource_ban.c | 21 ++++++++++----------- tools/crm_resource_runtime.c | 13 +++++-------- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/tools/crm_resource.c b/tools/crm_resource.c index 3d6d592db7b..a4adeb96a2e 100644 --- a/tools/crm_resource.c +++ b/tools/crm_resource.c @@ -960,11 +960,11 @@ clear_constraints(pcmk__output_t *out, xmlNodePtr *cib_xml_copy) return rc; } rc = cli_resource_clear(options.rsc_id, dest->priv->name, NULL, - cib_conn, cib_sync_call, true, options.force); + cib_conn, true, options.force); } else { rc = cli_resource_clear(options.rsc_id, NULL, scheduler->nodes, - cib_conn, cib_sync_call, true, options.force); + cib_conn, true, options.force); } if (!out->is_quiet(out)) { diff --git a/tools/crm_resource.h b/tools/crm_resource.h index 1637c3e4fa5..d83b5a1fe62 100644 --- a/tools/crm_resource.h +++ b/tools/crm_resource.h @@ -69,7 +69,8 @@ int cli_resource_ban(pcmk__output_t *out, const char *rsc_id, const char *host, const char *move_lifetime, cib_t *cib_conn, gboolean promoted_role_only, const char *promoted_role); int cli_resource_clear(const char *rsc_id, const char *host, GList *allnodes, - cib_t * cib_conn, int cib_options, bool clear_ban_constraints, gboolean force); + cib_t *cib_conn, bool clear_ban_constraints, + gboolean force); int cli_resource_clear_all_expired(xmlNode *root, cib_t *cib_conn, int cib_options, const char *rsc, const char *node, gboolean promoted_role_only); diff --git a/tools/crm_resource_ban.c b/tools/crm_resource_ban.c index b6152999fb2..ca56b671b0b 100644 --- a/tools/crm_resource_ban.c +++ b/tools/crm_resource_ban.c @@ -245,8 +245,8 @@ cli_resource_prefer(pcmk__output_t *out,const char *rsc_id, const char *host, * \return Standard Pacemaker return code */ static int -resource_clear_node_in_expr(const char *rsc_id, const char *host, cib_t * cib_conn, - int cib_options) +resource_clear_node_in_expr(const char *rsc_id, const char *host, + cib_t *cib_conn) { int rc = pcmk_rc_ok; char *xpath_string = NULL; @@ -262,7 +262,8 @@ resource_clear_node_in_expr(const char *rsc_id, const char *host, cib_t * cib_co xpath_string = crm_strdup_printf(XPATH_FMT, rsc_id, rsc_id, host); - rc = cib_conn->cmds->remove(cib_conn, xpath_string, NULL, cib_xpath | cib_options); + rc = cib_conn->cmds->remove(cib_conn, xpath_string, NULL, + cib_xpath|cib_sync_call); if (rc == -ENXIO) { rc = pcmk_rc_ok; } else { @@ -276,7 +277,7 @@ resource_clear_node_in_expr(const char *rsc_id, const char *host, cib_t * cib_co // \return Standard Pacemaker return code static int resource_clear_node_in_location(const char *rsc_id, const char *host, cib_t * cib_conn, - int cib_options, bool clear_ban_constraints, gboolean force) + bool clear_ban_constraints, gboolean force) { int rc = pcmk_rc_ok; xmlNode *fragment = NULL; @@ -297,7 +298,7 @@ resource_clear_node_in_location(const char *rsc_id, const char *host, cib_t * ci crm_log_xml_info(fragment, "Delete"); rc = cib_conn->cmds->remove(cib_conn, PCMK_XE_CONSTRAINTS, fragment, - cib_options); + cib_sync_call); if (rc == -ENXIO) { rc = pcmk_rc_ok; } else { @@ -311,7 +312,7 @@ resource_clear_node_in_location(const char *rsc_id, const char *host, cib_t * ci // \return Standard Pacemaker return code int cli_resource_clear(const char *rsc_id, const char *host, GList *allnodes, cib_t * cib_conn, - int cib_options, bool clear_ban_constraints, gboolean force) + bool clear_ban_constraints, gboolean force) { int rc = pcmk_rc_ok; @@ -320,7 +321,7 @@ cli_resource_clear(const char *rsc_id, const char *host, GList *allnodes, cib_t } if (host) { - rc = resource_clear_node_in_expr(rsc_id, host, cib_conn, cib_options); + rc = resource_clear_node_in_expr(rsc_id, host, cib_conn); /* rc does not tell us whether the previous operation did anything, only * whether it failed or not. Thus, as long as it did not fail, we need @@ -328,8 +329,7 @@ cli_resource_clear(const char *rsc_id, const char *host, GList *allnodes, cib_t */ if (rc == pcmk_rc_ok) { rc = resource_clear_node_in_location(rsc_id, host, cib_conn, - cib_options, clear_ban_constraints, - force); + clear_ban_constraints, force); } } else { @@ -342,8 +342,7 @@ cli_resource_clear(const char *rsc_id, const char *host, GList *allnodes, cib_t pcmk_node_t *target = n->data; rc = cli_resource_clear(rsc_id, target->priv->name, NULL, - cib_conn, cib_options, clear_ban_constraints, - force); + cib_conn, clear_ban_constraints, force); if (rc != pcmk_rc_ok) { break; } diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c index 4c10b90c0ab..313c1f28b8e 100644 --- a/tools/crm_resource_runtime.c +++ b/tools/crm_resource_runtime.c @@ -1786,8 +1786,7 @@ cli_resource_restart(pcmk__output_t *out, pcmk_resource_t *rsc, } if (stop_via_ban) { - rc = cli_resource_clear(lookup_id, host, NULL, cib, cib_sync_call, true, - force); + rc = cli_resource_clear(lookup_id, host, NULL, cib, true, force); } else if (orig_target_role) { rc = cli_resource_update_attribute(rsc, rsc_id, NULL, @@ -1872,8 +1871,7 @@ cli_resource_restart(pcmk__output_t *out, pcmk_resource_t *rsc, failure: if (stop_via_ban) { - cli_resource_clear(lookup_id, host, NULL, cib, cib_sync_call, true, - force); + cli_resource_clear(lookup_id, host, NULL, cib, true, force); } else if (orig_target_role) { cli_resource_update_attribute(rsc, rsc_id, NULL, PCMK_XE_META_ATTRIBUTES, NULL, @@ -2392,12 +2390,11 @@ cli_resource_move(const pcmk_resource_t *rsc, const char *rsc_id, } /* Clear any previous prefer constraints across all nodes. */ - cli_resource_clear(rsc_id, NULL, scheduler->nodes, cib, cib_sync_call, - false, force); + cli_resource_clear(rsc_id, NULL, scheduler->nodes, cib, false, force); /* Clear any previous ban constraints on 'dest'. */ - cli_resource_clear(rsc_id, dest->priv->name, scheduler->nodes, cib, - cib_sync_call, TRUE, force); + cli_resource_clear(rsc_id, dest->priv->name, scheduler->nodes, cib, true, + force); /* Record an explicit preference for 'dest' */ rc = cli_resource_prefer(out, rsc_id, dest->priv->name, move_lifetime, From 684205a67962ef5060067637958b20e9aba0cd8e Mon Sep 17 00:00:00 2001 From: Reid Wahl Date: Tue, 29 Oct 2024 22:40:11 -0700 Subject: [PATCH 06/13] Refactor: tools: Drop cli_resource_clear_all_expired() cib_options arg It's always cib_sync_call. Signed-off-by: Reid Wahl --- tools/crm_resource.c | 3 +-- tools/crm_resource.h | 2 +- tools/crm_resource_ban.c | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/crm_resource.c b/tools/crm_resource.c index a4adeb96a2e..4b14932f308 100644 --- a/tools/crm_resource.c +++ b/tools/crm_resource.c @@ -946,8 +946,7 @@ clear_constraints(pcmk__output_t *out, xmlNodePtr *cib_xml_copy) if (options.clear_expired) { rc = cli_resource_clear_all_expired(scheduler->input, cib_conn, - cib_sync_call, options.rsc_id, - options.host_uname, + options.rsc_id, options.host_uname, options.promoted_role_only); } else if (options.host_uname) { diff --git a/tools/crm_resource.h b/tools/crm_resource.h index d83b5a1fe62..c8a6676df0e 100644 --- a/tools/crm_resource.h +++ b/tools/crm_resource.h @@ -71,7 +71,7 @@ int cli_resource_ban(pcmk__output_t *out, const char *rsc_id, const char *host, int cli_resource_clear(const char *rsc_id, const char *host, GList *allnodes, cib_t *cib_conn, bool clear_ban_constraints, gboolean force); -int cli_resource_clear_all_expired(xmlNode *root, cib_t *cib_conn, int cib_options, +int cli_resource_clear_all_expired(xmlNode *root, cib_t *cib_conn, const char *rsc, const char *node, gboolean promoted_role_only); /* print */ diff --git a/tools/crm_resource_ban.c b/tools/crm_resource_ban.c index ca56b671b0b..f5a3af4386a 100644 --- a/tools/crm_resource_ban.c +++ b/tools/crm_resource_ban.c @@ -435,8 +435,8 @@ build_clear_xpath_string(GString *buf, const xmlNode *constraint_node, // \return Standard Pacemaker return code int -cli_resource_clear_all_expired(xmlNode *root, cib_t *cib_conn, int cib_options, - const char *rsc, const char *node, gboolean promoted_role_only) +cli_resource_clear_all_expired(xmlNode *root, cib_t *cib_conn, const char *rsc, + const char *node, gboolean promoted_role_only) { GString *buf = NULL; xmlXPathObject *xpathObj = NULL; @@ -491,7 +491,7 @@ cli_resource_clear_all_expired(xmlNode *root, cib_t *cib_conn, int cib_options, crm_log_xml_info(fragment, "Delete"); rc = cib_conn->cmds->remove(cib_conn, PCMK_XE_CONSTRAINTS, fragment, - cib_options); + cib_sync_call); rc = pcmk_legacy2rc(rc); if (rc != pcmk_rc_ok) { From 8e1d9638924976f4771d740c92ca0fab6f3360ba Mon Sep 17 00:00:00 2001 From: Reid Wahl Date: Tue, 29 Oct 2024 22:43:07 -0700 Subject: [PATCH 07/13] Refactor: tools: Drop cli_resource_delete_attribute() cib_options arg It's always cib_sync_call. Signed-off-by: Reid Wahl --- tools/crm_resource.c | 2 +- tools/crm_resource.h | 2 +- tools/crm_resource_runtime.c | 12 +++++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/crm_resource.c b/tools/crm_resource.c index 4b14932f308..392dc4f08cc 100644 --- a/tools/crm_resource.c +++ b/tools/crm_resource.c @@ -2062,7 +2062,7 @@ main(int argc, char **argv) options.attr_set_type, options.prop_id, options.prop_name, cib_conn, - cib_sync_call, options.force); + options.force); break; case cmd_cleanup: diff --git a/tools/crm_resource.h b/tools/crm_resource.h index c8a6676df0e..5855011d5a1 100644 --- a/tools/crm_resource.h +++ b/tools/crm_resource.h @@ -129,7 +129,7 @@ int cli_resource_delete_attribute(pcmk_resource_t *rsc, const char *requested_name, const char *attr_set, const char *attr_set_type, const char *attr_id, const char *attr_name, - cib_t *cib, int cib_options, gboolean force); + cib_t *cib, gboolean force); int update_scheduler_input(pcmk_scheduler_t *scheduler, xmlNode **xml); int wait_till_stable(pcmk__output_t *out, guint timeout_ms, cib_t * cib); diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c index 313c1f28b8e..b5ac86804c5 100644 --- a/tools/crm_resource_runtime.c +++ b/tools/crm_resource_runtime.c @@ -562,7 +562,7 @@ int cli_resource_delete_attribute(pcmk_resource_t *rsc, const char *requested_name, const char *attr_set, const char *attr_set_type, const char *attr_id, const char *attr_name, - cib_t *cib, int cib_options, gboolean force) + cib_t *cib, gboolean force) { pcmk__output_t *out = rsc->priv->scheduler->priv->out; int rc = pcmk_rc_ok; @@ -584,7 +584,7 @@ cli_resource_delete_attribute(pcmk_resource_t *rsc, const char *requested_name, pcmk__xe_remove_attr(rsc->priv->xml, attr_name); pcmk__assert(cib != NULL); rc = cib->cmds->replace(cib, PCMK_XE_RESOURCES, rsc->priv->xml, - cib_options); + cib_sync_call); rc = pcmk_legacy2rc(rc); if (rc == pcmk_rc_ok) { out->info(out, "Deleted attribute: %s", attr_name); @@ -633,7 +633,7 @@ cli_resource_delete_attribute(pcmk_resource_t *rsc, const char *requested_name, crm_log_xml_debug(xml_obj, "Delete"); pcmk__assert(cib != NULL); - rc = cib->cmds->remove(cib, PCMK_XE_RESOURCES, xml_obj, cib_options); + rc = cib->cmds->remove(cib, PCMK_XE_RESOURCES, xml_obj, cib_sync_call); rc = pcmk_legacy2rc(rc); if (rc == pcmk_rc_ok) { @@ -1798,8 +1798,7 @@ cli_resource_restart(pcmk__output_t *out, pcmk_resource_t *rsc, } else { rc = cli_resource_delete_attribute(rsc, rsc_id, NULL, PCMK_XE_META_ATTRIBUTES, NULL, - PCMK_META_TARGET_ROLE, cib, - cib_sync_call, force); + PCMK_META_TARGET_ROLE, cib, force); } if(rc != pcmk_rc_ok) { @@ -1881,8 +1880,7 @@ cli_resource_restart(pcmk__output_t *out, pcmk_resource_t *rsc, } else { cli_resource_delete_attribute(rsc, rsc_id, NULL, PCMK_XE_META_ATTRIBUTES, NULL, - PCMK_META_TARGET_ROLE, cib, cib_sync_call, - force); + PCMK_META_TARGET_ROLE, cib, force); } done: From c095318ddbb125de6e3701d04a4bfb8c1f799283 Mon Sep 17 00:00:00 2001 From: Reid Wahl Date: Wed, 30 Oct 2024 22:03:06 -0700 Subject: [PATCH 08/13] Feature: tools: Drop deprecated crm_resource --xml-file option This option has been hidden since at least f33d9ee5 (2009) and deprecated via comment since ea636bc7 (2020). Signed-off-by: Reid Wahl --- tools/crm_resource.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/tools/crm_resource.c b/tools/crm_resource.c index 392dc4f08cc..2c1ae633b07 100644 --- a/tools/crm_resource.c +++ b/tools/crm_resource.c @@ -94,7 +94,6 @@ struct { gchar *prop_value; // --parameter-value (attribute value) guint timeout_ms; // Parsed from --timeout value char *agent_spec; // Standard and/or provider and/or agent - gchar *xml_file; // Value of (deprecated) --xml-file int check_level; // Optional value of --validate or --force-check // Resource configuration specified via command-line arguments @@ -776,9 +775,6 @@ static GOptionEntry addl_entries[] = { "Force the action to be performed. See help for individual commands for\n" INDENT "additional behavior.", NULL }, - { "xml-file", 'x', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME, &options.xml_file, - NULL, - "FILE" }, { "host-uname", 'H', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &options.host_uname, NULL, "HOST" }, @@ -1002,15 +998,8 @@ initialize_scheduler_data(xmlNodePtr *cib_xml_copy) { int rc = pcmk_rc_ok; - if (options.xml_file != NULL) { - *cib_xml_copy = pcmk__xml_read(options.xml_file); - if (*cib_xml_copy == NULL) { - rc = pcmk_rc_cib_corrupt; - } - } else { - rc = cib_conn->cmds->query(cib_conn, NULL, cib_xml_copy, cib_sync_call); - rc = pcmk_legacy2rc(rc); - } + rc = cib_conn->cmds->query(cib_conn, NULL, cib_xml_copy, cib_sync_call); + rc = pcmk_legacy2rc(rc); if (rc == pcmk_rc_ok) { scheduler = pe_new_working_set(); @@ -2158,7 +2147,6 @@ main(int argc, char **argv) free(options.v_agent); free(options.v_class); free(options.v_provider); - g_free(options.xml_file); g_strfreev(options.remainder); if (options.override_params != NULL) { From 1641df8291f2a1b926dbe25b18db1524733f95f8 Mon Sep 17 00:00:00 2001 From: Reid Wahl Date: Wed, 30 Oct 2024 22:04:46 -0700 Subject: [PATCH 09/13] Doc: tools: Add COMPAT note for crm_resource --host-uname option This is a hidden alias for the --node option. It has been hidden since at least f33d9ee5 (2009), but it was used in resource-agents --- tools/crm_resource.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/crm_resource.c b/tools/crm_resource.c index 2c1ae633b07..135d74bd367 100644 --- a/tools/crm_resource.c +++ b/tools/crm_resource.c @@ -775,6 +775,8 @@ static GOptionEntry addl_entries[] = { "Force the action to be performed. See help for individual commands for\n" INDENT "additional behavior.", NULL }, + + // @COMPAT Used in resource-agents prior to v4.2.0 { "host-uname", 'H', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &options.host_uname, NULL, "HOST" }, From 6e5959facc619892219ee01eb8c1aa7715e1ca7e Mon Sep 17 00:00:00 2001 From: Reid Wahl Date: Thu, 31 Oct 2024 14:01:59 -0700 Subject: [PATCH 10/13] Refactor: cts: Expand non-obvious crm_resource options We almost accidentally removed the --list-cts option because it wasn't clear that it was being used anywhere. This commit is to improve readability and to make it more obvious where rarely used options are used. Signed-off-by: Reid Wahl --- python/pacemaker/_cts/audits.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/pacemaker/_cts/audits.py b/python/pacemaker/_cts/audits.py index 2c8329186fc..5c97425479c 100644 --- a/python/pacemaker/_cts/audits.py +++ b/python/pacemaker/_cts/audits.py @@ -491,7 +491,8 @@ def _setup(self): self.debug("No nodes active - skipping %s" % self.name) return False - (_, lines) = self._cm.rsh(self._target, "crm_resource -c", verbose=1) + (_, lines) = self._cm.rsh(self._target, "crm_resource --list-cts", + verbose=1) for line in lines: if re.search("^Resource", line): @@ -650,7 +651,9 @@ def __init__(self, cm): def _crm_location(self, resource): """Return a list of cluster nodes where a given resource is running.""" - (rc, lines) = self._cm.rsh(self._target, "crm_resource -W -r %s -Q" % resource, verbose=1) + (rc, lines) = self._cm.rsh(self._target, + "crm_resource --locate -r %s -Q" % resource, + verbose=1) hosts = [] if rc == 0: From 15a859de7d08f0088a53f817a4c94b15ca447de4 Mon Sep 17 00:00:00 2001 From: Reid Wahl Date: Wed, 30 Oct 2024 22:47:06 -0700 Subject: [PATCH 11/13] Feature: tools: Drop crm_resource --get-property option Added by 78502f6e and it's unclear that it was ever used either internally or externally. It's been hidden since fe96d691. Signed-off-by: Reid Wahl --- tools/crm_resource.c | 20 -------------------- tools/crm_resource_print.c | 34 ---------------------------------- 2 files changed, 54 deletions(-) diff --git a/tools/crm_resource.c b/tools/crm_resource.c index 135d74bd367..bc7375e4985 100644 --- a/tools/crm_resource.c +++ b/tools/crm_resource.c @@ -48,7 +48,6 @@ enum rsc_command { cmd_execute_agent, cmd_fail, cmd_get_param, - cmd_get_property, cmd_list_active_ops, cmd_list_agents, cmd_list_all_ops, @@ -382,10 +381,6 @@ command_cb(const gchar *option_name, const gchar *optarg, gpointer data, options.rsc_cmd = cmd_get_param; pcmk__str_update(&options.prop_name, optarg); - } else if (pcmk__str_any_of(option_name, "-G", "--get-property", NULL)) { - options.rsc_cmd = cmd_get_property; - pcmk__str_update(&options.prop_name, optarg); - } else if (pcmk__str_any_of(option_name, "-O", "--list-operations", NULL)) { options.rsc_cmd = cmd_list_active_ops; @@ -521,11 +516,6 @@ static GOptionEntry query_entries[] = { "Display named parameter for resource (use instance attribute\n" INDENT "unless --element, --meta, or --utilization is specified)", "PARAM" }, - { "get-property", 'G', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, - command_cb, - "Display named property of resource ('class', 'type', or 'provider') " - "(requires --resource)", - "PROPERTY" }, { "locate", 'W', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, command_cb, "Show node(s) currently running resource", NULL }, @@ -1261,7 +1251,6 @@ get_find_flags(void) case cmd_delete_param: case cmd_get_param: - case cmd_get_property: case cmd_query_xml_raw: case cmd_query_xml: case cmd_set_param: @@ -1618,7 +1607,6 @@ main(int argc, char **argv) * argument. */ case cmd_get_param: - case cmd_get_property: case cmd_list_instances: case cmd_list_standards: pcmk__output_enable_list_element(out); @@ -1959,14 +1947,6 @@ main(int argc, char **argv) break; - case cmd_get_property: - rc = out->message(out, "property-list", rsc, options.prop_name); - if (rc == pcmk_rc_no_output) { - rc = ENXIO; - } - - break; - case cmd_set_property: rc = set_property(); break; diff --git a/tools/crm_resource_print.c b/tools/crm_resource_print.c index e37b7cbd9aa..e8c95fd7a4d 100644 --- a/tools/crm_resource_print.c +++ b/tools/crm_resource_print.c @@ -360,38 +360,6 @@ override_xml(pcmk__output_t *out, va_list args) { return pcmk_rc_ok; } -PCMK__OUTPUT_ARGS("property-list", "pcmk_resource_t *", "const char *") -static int -property_list_default(pcmk__output_t *out, va_list args) { - pcmk_resource_t *rsc = va_arg(args, pcmk_resource_t *); - const char *attr = va_arg(args, char *); - - const char *value = crm_element_value(rsc->priv->xml, attr); - - if (value != NULL) { - out->begin_list(out, NULL, NULL, "Properties"); - out->list_item(out, attr, "%s", value); - out->end_list(out); - } - - return pcmk_rc_ok; -} - -PCMK__OUTPUT_ARGS("property-list", "pcmk_resource_t *", "const char *") -static int -property_list_text(pcmk__output_t *out, va_list args) { - pcmk_resource_t *rsc = va_arg(args, pcmk_resource_t *); - const char *attr = va_arg(args, const char *); - - const char *value = crm_element_value(rsc->priv->xml, attr); - - if (value != NULL) { - pcmk__formatted_printf(out, "%s\n", value); - } - - return pcmk_rc_ok; -} - PCMK__OUTPUT_ARGS("resource-agent-action", "int", "const char *", "const char *", "const char *", "const char *", "const char *", "GHashTable *", "crm_exit_t", "int", "const char *", "const char *", "const char *") @@ -896,8 +864,6 @@ static pcmk__message_entry_t fmt_functions[] = { { "attribute-list", "text", attribute_list_text }, { "override", "default", override_default }, { "override", "xml", override_xml }, - { "property-list", "default", property_list_default }, - { "property-list", "text", property_list_text }, { "resource-agent-action", "default", resource_agent_action_default }, { "resource-agent-action", "xml", resource_agent_action_xml }, { "resource-check-list", "default", resource_check_list_default }, From 47237fb8c3f94bba482571361fe4b6095291f2a1 Mon Sep 17 00:00:00 2001 From: Reid Wahl Date: Wed, 30 Oct 2024 22:53:57 -0700 Subject: [PATCH 12/13] Feature: tools: Drop crm_resource --set-property option Added by 78502f6e and it's unclear that it was ever used either internally or externally. It's been hidden since fe96d691. Signed-off-by: Reid Wahl --- tools/crm_resource.c | 48 -------------------------------------------- 1 file changed, 48 deletions(-) diff --git a/tools/crm_resource.c b/tools/crm_resource.c index bc7375e4985..bd61a079086 100644 --- a/tools/crm_resource.c +++ b/tools/crm_resource.c @@ -65,7 +65,6 @@ enum rsc_command { cmd_refresh, cmd_restart, cmd_set_param, - cmd_set_property, cmd_wait, cmd_why, }; @@ -441,10 +440,6 @@ command_cb(const gchar *option_name, const gchar *optarg, gpointer data, options.rsc_cmd = cmd_set_param; pcmk__str_update(&options.prop_name, optarg); - } else if (pcmk__str_any_of(option_name, "-S", "--set-property", NULL)) { - options.rsc_cmd = cmd_set_property; - pcmk__str_update(&options.prop_name, optarg); - } else if (pcmk__str_eq(option_name, "--wait", pcmk__str_none)) { options.rsc_cmd = cmd_wait; @@ -577,11 +572,6 @@ static GOptionEntry command_entries[] = { "Delete named parameter for resource. Use instance attribute\n" INDENT "unless --element, --meta or, --utilization is specified.", "PARAM" }, - { "set-property", 'S', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, - command_cb, - "Set named property of resource ('class', 'type', or 'provider') " - "(requires -r, -t, -v)", - "PROPERTY" }, { NULL } }; @@ -1102,39 +1092,6 @@ refresh_resource(pcmk__output_t *out, pcmk_resource_t *rsc, pcmk_node_t *node) } } -static int -set_property(void) -{ - int rc = pcmk_rc_ok; - xmlNode *msg_data = NULL; - - if (pcmk__str_empty(options.rsc_type)) { - g_set_error(&error, PCMK__EXITC_ERROR, CRM_EX_USAGE, - _("Must specify -t with resource type")); - rc = ENXIO; - return rc; - - } else if (pcmk__str_empty(options.prop_value)) { - g_set_error(&error, PCMK__EXITC_ERROR, CRM_EX_USAGE, - _("Must supply -v with new value")); - rc = ENXIO; - return rc; - } - - CRM_LOG_ASSERT(options.prop_name != NULL); - - msg_data = pcmk__xe_create(NULL, options.rsc_type); - crm_xml_add(msg_data, PCMK_XA_ID, options.rsc_id); - crm_xml_add(msg_data, options.prop_name, options.prop_value); - - rc = cib_conn->cmds->modify(cib_conn, PCMK_XE_RESOURCES, msg_data, - cib_sync_call); - rc = pcmk_legacy2rc(rc); - pcmk__xml_free(msg_data); - - return rc; -} - static int show_metadata(pcmk__output_t *out, const char *agent_spec) { @@ -1254,7 +1211,6 @@ get_find_flags(void) case cmd_query_xml_raw: case cmd_query_xml: case cmd_set_param: - case cmd_set_property: return pcmk_rsc_match_history|pcmk_rsc_match_basename; default: @@ -1947,10 +1903,6 @@ main(int argc, char **argv) break; - case cmd_set_property: - rc = set_property(); - break; - case cmd_get_param: { unsigned int count = 0; GHashTable *params = NULL; From 9ff48f55681ea5067cf047fa0c3afb81032d7007 Mon Sep 17 00:00:00 2001 From: Reid Wahl Date: Wed, 30 Oct 2024 20:35:46 -0700 Subject: [PATCH 13/13] Refactor: tools: Drop cib_xml_copy function arguments The caller doesn't set or use the contents, so it's clearer to use local variables. Signed-off-by: Reid Wahl --- tools/crm_resource.c | 26 +++++++++++++------------- tools/crm_resource_runtime.c | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/crm_resource.c b/tools/crm_resource.c index bd61a079086..45362914697 100644 --- a/tools/crm_resource.c +++ b/tools/crm_resource.c @@ -909,7 +909,7 @@ cleanup(pcmk__output_t *out, pcmk_resource_t *rsc, pcmk_node_t *node) } static int -clear_constraints(pcmk__output_t *out, xmlNodePtr *cib_xml_copy) +clear_constraints(pcmk__output_t *out) { GList *before = NULL; GList *after = NULL; @@ -945,19 +945,20 @@ clear_constraints(pcmk__output_t *out, xmlNodePtr *cib_xml_copy) } if (!out->is_quiet(out)) { - rc = cib_conn->cmds->query(cib_conn, NULL, cib_xml_copy, cib_sync_call); + xmlNode *cib_xml = NULL; + + rc = cib_conn->cmds->query(cib_conn, NULL, &cib_xml, cib_sync_call); rc = pcmk_legacy2rc(rc); if (rc != pcmk_rc_ok) { g_set_error(&error, PCMK__RC_ERROR, rc, _("Could not get modified CIB: %s\n"), pcmk_rc_str(rc)); g_list_free(before); - pcmk__xml_free(*cib_xml_copy); - *cib_xml_copy = NULL; + pcmk__xml_free(cib_xml); return rc; } - scheduler->input = *cib_xml_copy; + scheduler->input = cib_xml; cluster_status(scheduler); after = build_constraint_list(scheduler->input); @@ -976,11 +977,12 @@ clear_constraints(pcmk__output_t *out, xmlNodePtr *cib_xml_copy) } static int -initialize_scheduler_data(xmlNodePtr *cib_xml_copy) +initialize_scheduler_data(void) { + xmlNode *cib_xml = NULL; int rc = pcmk_rc_ok; - rc = cib_conn->cmds->query(cib_conn, NULL, cib_xml_copy, cib_sync_call); + rc = cib_conn->cmds->query(cib_conn, NULL, &cib_xml, cib_sync_call); rc = pcmk_legacy2rc(rc); if (rc == pcmk_rc_ok) { @@ -990,13 +992,12 @@ initialize_scheduler_data(xmlNodePtr *cib_xml_copy) } else { pcmk__set_scheduler_flags(scheduler, pcmk__sched_no_counts); scheduler->priv->out = out; - rc = update_scheduler_input(scheduler, cib_xml_copy); + rc = update_scheduler_input(scheduler, &cib_xml); } } if (rc != pcmk_rc_ok) { - pcmk__xml_free(*cib_xml_copy); - *cib_xml_copy = NULL; + pcmk__xml_free(cib_xml); return rc; } @@ -1442,7 +1443,6 @@ build_arg_context(pcmk__common_args_t *args, GOptionGroup **group) { int main(int argc, char **argv) { - xmlNode *cib_xml_copy = NULL; pcmk_resource_t *rsc = NULL; pcmk_node_t *node = NULL; uint32_t find_flags = 0; @@ -1645,7 +1645,7 @@ main(int argc, char **argv) // Populate scheduler data from XML file if specified or CIB query otherwise if (is_scheduler_required()) { - rc = initialize_scheduler_data(&cib_xml_copy); + rc = initialize_scheduler_data(); if (rc != pcmk_rc_ok) { exit_code = pcmk_rc2exitc(rc); goto done; @@ -1864,7 +1864,7 @@ main(int argc, char **argv) break; case cmd_clear: - rc = clear_constraints(out, &cib_xml_copy); + rc = clear_constraints(out); break; case cmd_move: diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c index b5ac86804c5..530ae1d866b 100644 --- a/tools/crm_resource_runtime.c +++ b/tools/crm_resource_runtime.c @@ -1319,8 +1319,8 @@ static void display_list(pcmk__output_t *out, GList *items, const char *tag) * \param[in,out] xml XML to use as input * * \return Standard Pacemaker return code - * \note On success, caller is responsible for freeing memory allocated for - * scheduler->priv->now. + * \note On success, \p scheduler takes ownership of \p xml, and the caller is + * responsible for freeing memory allocated for \c scheduler->priv->now. */ int update_scheduler_input(pcmk_scheduler_t *scheduler, xmlNode **xml)