Fix minor issue with crm_resource error message change

- Resolves: rhbz1983196
This commit is contained in:
Ken Gaillot 2021-08-12 15:38:09 -05:00
parent 6dec65dd8f
commit 2918108071
2 changed files with 120 additions and 1 deletions

114
019-crm_resource.patch Normal file
View File

@ -0,0 +1,114 @@
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

View File

@ -36,7 +36,7 @@
## can be incremented to build packages reliably considered "newer"
## than previously built packages with the same pcmkversion)
%global pcmkversion 2.1.0
%global specversion 9
%global specversion 10
## Upstream commit (full commit ID, abbreviated commit ID, or tag) to build
%global commit 7c3f660707a495a1331716ad32cd3ac9d9f8ff58
@ -260,6 +260,7 @@ Patch15: 015-sbd.patch
Patch16: 016-cts.patch
Patch17: 017-watchdog-fixes.patch
Patch18: 018-controller.patch
Patch19: 019-crm_resource.patch
Requires: resource-agents
Requires: %{pkgname_pcmk_libs}%{?_isa} = %{version}-%{release}
@ -862,6 +863,10 @@ exit 0
%license %{nagios_name}-%{nagios_hash}/COPYING
%changelog
* Thu Aug 12 2021 Ken Gaillot <kgaillot@redhat.com> - 2.1.0-10
- Fix minor issue with crm_resource error message change
- Resolves: rhbz1983196
* Wed Aug 11 2021 Ken Gaillot <kgaillot@redhat.com> - 2.1.0-9
- Fix watchdog agent version information
- Ensure transient attributes are cleared when multiple nodes are lost