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