|
|
b8eb17 |
From b4e426a016a4d7c9ade39e60a83644fc537bce26 Mon Sep 17 00:00:00 2001
|
|
|
b8eb17 |
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
|
|
b8eb17 |
Date: Wed, 11 Aug 2021 12:10:32 +0200
|
|
|
b8eb17 |
Subject: [PATCH 1/2] Fix: crm_resource: translate LSB rc to exit code and fix
|
|
|
b8eb17 |
resources_find_service_class() call
|
|
|
b8eb17 |
|
|
|
b8eb17 |
---
|
|
|
b8eb17 |
tools/crm_resource_runtime.c | 16 ++++++++++++----
|
|
|
b8eb17 |
1 file changed, 12 insertions(+), 4 deletions(-)
|
|
|
b8eb17 |
|
|
|
b8eb17 |
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c
|
|
|
b8eb17 |
index ce037c514..e9d8aa687 100644
|
|
|
b8eb17 |
--- a/tools/crm_resource_runtime.c
|
|
|
b8eb17 |
+++ b/tools/crm_resource_runtime.c
|
|
|
b8eb17 |
@@ -1718,10 +1718,10 @@ cli_resource_execute_from_params(pcmk__output_t *out, const char *rsc_name,
|
|
|
b8eb17 |
crm_exit(CRM_EX_UNIMPLEMENT_FEATURE);
|
|
|
b8eb17 |
} else if (pcmk__str_eq(rsc_class, PCMK_RESOURCE_CLASS_SERVICE,
|
|
|
b8eb17 |
pcmk__str_casei) && !pcmk__str_eq(
|
|
|
b8eb17 |
- resources_find_service_class(rsc_name), PCMK_RESOURCE_CLASS_LSB,
|
|
|
b8eb17 |
+ resources_find_service_class(rsc_type), PCMK_RESOURCE_CLASS_LSB,
|
|
|
b8eb17 |
pcmk__str_casei)) {
|
|
|
b8eb17 |
out->err(out, "Sorry, the %s option doesn't support %s resources",
|
|
|
b8eb17 |
- rsc_action, resources_find_service_class(rsc_name));
|
|
|
b8eb17 |
+ rsc_action, resources_find_service_class(rsc_type));
|
|
|
b8eb17 |
crm_exit(CRM_EX_UNIMPLEMENT_FEATURE);
|
|
|
b8eb17 |
}
|
|
|
b8eb17 |
|
|
|
b8eb17 |
@@ -1798,9 +1798,17 @@ cli_resource_execute_from_params(pcmk__output_t *out, const char *rsc_name,
|
|
|
b8eb17 |
if (services_action_sync(op)) {
|
|
|
b8eb17 |
exit_code = op->rc;
|
|
|
b8eb17 |
|
|
|
b8eb17 |
+ /* Lookup exit code based on rc for LSB resources */
|
|
|
b8eb17 |
+ if (( pcmk__str_eq(rsc_class, PCMK_RESOURCE_CLASS_LSB, pcmk__str_casei) ||
|
|
|
b8eb17 |
+ (pcmk__str_eq(rsc_class, PCMK_RESOURCE_CLASS_SERVICE, pcmk__str_casei) &&
|
|
|
b8eb17 |
+ pcmk__str_eq(resources_find_service_class(rsc_type), PCMK_RESOURCE_CLASS_LSB, pcmk__str_casei)) ) &&
|
|
|
b8eb17 |
+ pcmk__str_eq(rsc_action, "force-check", pcmk__str_casei)) {
|
|
|
b8eb17 |
+ exit_code = services_get_ocf_exitcode(action, exit_code);
|
|
|
b8eb17 |
+ }
|
|
|
b8eb17 |
+
|
|
|
b8eb17 |
out->message(out, "resource-agent-action", resource_verbose, rsc_class,
|
|
|
b8eb17 |
- rsc_prov, rsc_type, rsc_name, rsc_action, override_hash, op->rc,
|
|
|
b8eb17 |
- op->status, op->stdout_data, op->stderr_data);
|
|
|
b8eb17 |
+ rsc_prov, rsc_type, rsc_name, rsc_action, override_hash,
|
|
|
b8eb17 |
+ exit_code, op->status, op->stdout_data, op->stderr_data);
|
|
|
b8eb17 |
} else {
|
|
|
b8eb17 |
exit_code = op->rc == 0 ? CRM_EX_ERROR : op->rc;
|
|
|
b8eb17 |
}
|
|
|
b8eb17 |
--
|
|
|
b8eb17 |
2.27.0
|
|
|
b8eb17 |
|
|
|
b8eb17 |
|
|
|
b8eb17 |
From 9a6beb74adfb4710fb3a4e588bef79a562c101f3 Mon Sep 17 00:00:00 2001
|
|
|
b8eb17 |
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
|
|
b8eb17 |
Date: Thu, 12 Aug 2021 18:54:30 +0200
|
|
|
b8eb17 |
Subject: [PATCH 2/2] Refactor: crm_resource: simplify rsc_class logic by
|
|
|
b8eb17 |
getting actual class early if it's of class "service"
|
|
|
b8eb17 |
|
|
|
b8eb17 |
---
|
|
|
b8eb17 |
tools/crm_resource_runtime.c | 23 +++++++++--------------
|
|
|
b8eb17 |
1 file changed, 9 insertions(+), 14 deletions(-)
|
|
|
b8eb17 |
|
|
|
b8eb17 |
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c
|
|
|
b8eb17 |
index e9d8aa687..13b78b6b9 100644
|
|
|
b8eb17 |
--- a/tools/crm_resource_runtime.c
|
|
|
b8eb17 |
+++ b/tools/crm_resource_runtime.c
|
|
|
b8eb17 |
@@ -1702,26 +1702,23 @@ cli_resource_execute_from_params(pcmk__output_t *out, const char *rsc_name,
|
|
|
b8eb17 |
int timeout_ms, int resource_verbose, gboolean force,
|
|
|
b8eb17 |
int check_level)
|
|
|
b8eb17 |
{
|
|
|
b8eb17 |
+ const char *class = NULL;
|
|
|
b8eb17 |
const char *action = NULL;
|
|
|
b8eb17 |
GHashTable *params_copy = NULL;
|
|
|
b8eb17 |
crm_exit_t exit_code = CRM_EX_OK;
|
|
|
b8eb17 |
svc_action_t *op = NULL;
|
|
|
b8eb17 |
|
|
|
b8eb17 |
- if (pcmk__str_eq(rsc_class, PCMK_RESOURCE_CLASS_STONITH, pcmk__str_casei)) {
|
|
|
b8eb17 |
+ class = !pcmk__str_eq(rsc_class, PCMK_RESOURCE_CLASS_SERVICE, pcmk__str_casei) ?
|
|
|
b8eb17 |
+ rsc_class : resources_find_service_class(rsc_type);
|
|
|
b8eb17 |
+
|
|
|
b8eb17 |
+ if (pcmk__str_eq(class, PCMK_RESOURCE_CLASS_STONITH, pcmk__str_casei)) {
|
|
|
b8eb17 |
out->err(out, "Sorry, the %s option doesn't support %s resources yet",
|
|
|
b8eb17 |
- rsc_action, rsc_class);
|
|
|
b8eb17 |
+ rsc_action, class);
|
|
|
b8eb17 |
crm_exit(CRM_EX_UNIMPLEMENT_FEATURE);
|
|
|
b8eb17 |
- } else if (pcmk__strcase_any_of(rsc_class, PCMK_RESOURCE_CLASS_SYSTEMD,
|
|
|
b8eb17 |
+ } else if (pcmk__strcase_any_of(class, PCMK_RESOURCE_CLASS_SYSTEMD,
|
|
|
b8eb17 |
PCMK_RESOURCE_CLASS_UPSTART, PCMK_RESOURCE_CLASS_NAGIOS, NULL)) {
|
|
|
b8eb17 |
out->err(out, "Sorry, the %s option doesn't support %s resources",
|
|
|
b8eb17 |
- rsc_action, rsc_class);
|
|
|
b8eb17 |
- crm_exit(CRM_EX_UNIMPLEMENT_FEATURE);
|
|
|
b8eb17 |
- } else if (pcmk__str_eq(rsc_class, PCMK_RESOURCE_CLASS_SERVICE,
|
|
|
b8eb17 |
- pcmk__str_casei) && !pcmk__str_eq(
|
|
|
b8eb17 |
- resources_find_service_class(rsc_type), PCMK_RESOURCE_CLASS_LSB,
|
|
|
b8eb17 |
- pcmk__str_casei)) {
|
|
|
b8eb17 |
- out->err(out, "Sorry, the %s option doesn't support %s resources",
|
|
|
b8eb17 |
- rsc_action, resources_find_service_class(rsc_type));
|
|
|
b8eb17 |
+ rsc_action, class);
|
|
|
b8eb17 |
crm_exit(CRM_EX_UNIMPLEMENT_FEATURE);
|
|
|
b8eb17 |
}
|
|
|
b8eb17 |
|
|
|
b8eb17 |
@@ -1799,9 +1796,7 @@ cli_resource_execute_from_params(pcmk__output_t *out, const char *rsc_name,
|
|
|
b8eb17 |
exit_code = op->rc;
|
|
|
b8eb17 |
|
|
|
b8eb17 |
/* Lookup exit code based on rc for LSB resources */
|
|
|
b8eb17 |
- if (( pcmk__str_eq(rsc_class, PCMK_RESOURCE_CLASS_LSB, pcmk__str_casei) ||
|
|
|
b8eb17 |
- (pcmk__str_eq(rsc_class, PCMK_RESOURCE_CLASS_SERVICE, pcmk__str_casei) &&
|
|
|
b8eb17 |
- pcmk__str_eq(resources_find_service_class(rsc_type), PCMK_RESOURCE_CLASS_LSB, pcmk__str_casei)) ) &&
|
|
|
b8eb17 |
+ if (pcmk__str_eq(class, PCMK_RESOURCE_CLASS_LSB, pcmk__str_casei) &&
|
|
|
b8eb17 |
pcmk__str_eq(rsc_action, "force-check", pcmk__str_casei)) {
|
|
|
b8eb17 |
exit_code = services_get_ocf_exitcode(action, exit_code);
|
|
|
b8eb17 |
}
|
|
|
b8eb17 |
--
|
|
|
b8eb17 |
2.27.0
|
|
|
b8eb17 |
|