Skip to content

Convert execd to use pcmk__request_t #3915

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

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3ee3cf3
Refactor: daemons: Move IPC server skeleton code to execd_messages.c.
clumens Jul 11, 2025
836ae0d
Refactor: daemons: Rename variables in execd_messages.c.
clumens Jul 15, 2025
a3bb87a
Refactor: daemons: Add execd_process_message.
clumens Jul 11, 2025
9f83b81
Refactor: daemons: Condense duplicated IPC code.
clumens Jul 11, 2025
78e8997
Refactor: daemons: Use pcmk__request_t for CRM_OP_REGISTER.
clumens Jul 9, 2025
2e4be16
Refactor: daemons: Use pcmk__request_t for LRMD_OP_RSC_INFO.
clumens Jul 9, 2025
a21c989
Refactor: daemons: Expose two more functions to all of execd.
clumens Jul 9, 2025
397804a
Refactor: daemons: Use pcmk__request_t for LRMD_OP_RSC_REG.
clumens Jul 9, 2025
694061d
Refactor: daemons: Use pcmk__request_t for LRMD_OP_RSC_EXEC.
clumens Jul 9, 2025
cd1ba02
Refactor: daemons: Use pcmk__request_t for LRMD_OP_RSC_CANCEL.
clumens Jul 9, 2025
0f1ef52
Refactor: daemons: Use pcmk__request_t for LRMD_OP_ALERT_EXEC.
clumens Jul 9, 2025
9dcef97
Refactor: daemons: Use pcmk__request_t for LRMD_OP_POKE.
clumens Jul 9, 2025
f49fe3a
Refactor: daemons: Use pcmk__request_t for LRMD_OP_GET_RECURRING.
clumens Jul 9, 2025
63f0603
Refactor: daemons: Use pcmk__request_t for LRMD_OP_CHECK.
clumens Jul 9, 2025
10d2a05
Refactor: daemons: Use pcmk__request_t for LRMD_OP_RSC_UNREG.
clumens Jul 9, 2025
c59059b
Refactor: daemons: Use pcmk__request_t for LRMD_OP_IPC_FWD.
clumens Jul 9, 2025
7d56d46
Refactor: daemons: Add handle_unknown_request.
clumens Jul 15, 2025
ba47d0b
Low: daemons: Correct result error string on unknown IPC messages.
clumens Jul 17, 2025
5dc6e6c
Refactor: daemons: Add an execd_create_reply macro...
clumens Jul 17, 2025
34d7619
Low: daemons: Return CRM_EX_PROTOCOL when ACKing an unknown request.
clumens Jul 21, 2025
821786b
Low: daemons: Send a NACK instead of an ACK when there's an error.
clumens Jul 21, 2025
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/attrd/attrd_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ attrd_ipc_dispatch(qb_ipcs_connection_t * c, void *data, size_t size)

if (xml == NULL) {
crm_debug("Unrecognizable IPC data from PID %d", pcmk__client_pid(c));
pcmk__ipc_send_ack(client, id, flags, PCMK__XE_ACK, NULL,
pcmk__ipc_send_ack(client, id, flags, PCMK__XE_NACK, NULL,
CRM_EX_PROTOCOL);
return 0;

Expand Down
3 changes: 2 additions & 1 deletion daemons/attrd/attrd_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ handle_unknown_request(pcmk__request_t *request)
request->op, pcmk__request_origin_type(request),
pcmk__request_origin(request));
pcmk__format_result(&request->result, CRM_EX_PROTOCOL, PCMK_EXEC_INVALID,
"Unknown request type '%s' (bug?)", request->op);
"Unknown request type '%s' (bug?)",
pcmk__s(request->op, ""));
return NULL;
}

Expand Down
4 changes: 2 additions & 2 deletions daemons/attrd/attrd_sync.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2024 the Pacemaker project contributors
* Copyright 2022-2025 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand Down Expand Up @@ -379,7 +379,7 @@ confirmation_timeout_cb(gpointer data)
crm_trace("Timed out waiting for confirmations for client %s", client->id);
pcmk__ipc_send_ack(client, action->ipc_id,
action->flags|crm_ipc_client_response,
PCMK__XE_ACK, ATTRD_PROTOCOL_VERSION,
PCMK__XE_NACK, ATTRD_PROTOCOL_VERSION,
CRM_EX_TIMEOUT);

g_hash_table_iter_remove(&iter);
Expand Down
9 changes: 8 additions & 1 deletion daemons/based/based_callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,14 @@ cib_common_callback_worker(uint32_t id, uint32_t flags, xmlNode * op_request,
}
}

pcmk__ipc_send_ack(cib_client, id, flags, PCMK__XE_ACK, NULL, status);
if (status == CRM_EX_OK) {
pcmk__ipc_send_ack(cib_client, id, flags, PCMK__XE_ACK, NULL,
status);
} else {
pcmk__ipc_send_ack(cib_client, id, flags, PCMK__XE_NACK, NULL,
status);
}

return;
}

Expand Down
2 changes: 1 addition & 1 deletion daemons/controld/controld_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ dispatch_controller_ipc(qb_ipcs_connection_t * c, void *data, size_t size)
}

if (msg == NULL) {
pcmk__ipc_send_ack(client, id, flags, PCMK__XE_ACK, NULL,
pcmk__ipc_send_ack(client, id, flags, PCMK__XE_NACK, NULL,
CRM_EX_PROTOCOL);
return 0;
}
Expand Down
5 changes: 3 additions & 2 deletions daemons/execd/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2012-2024 the Pacemaker project contributors
# Copyright 2012-2025 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
Expand All @@ -25,7 +25,8 @@ pacemaker_execd_LDADD += $(top_builddir)/lib/services/libcrmservice.la
pacemaker_execd_LDADD += $(top_builddir)/lib/common/libcrmcommon.la
pacemaker_execd_SOURCES = pacemaker-execd.c \
execd_commands.c \
execd_alerts.c
execd_alerts.c \
execd_messages.c

sbin_PROGRAMS = pacemaker-remoted
if BUILD_SYSTEMD
Expand Down
13 changes: 7 additions & 6 deletions daemons/execd/execd_alerts.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ alert_complete(svc_action_t *action)
}

int
process_lrmd_alert_exec(pcmk__client_t *client, uint32_t id, xmlNode *request)
execd_process_alert_exec(pcmk__client_t *client, xmlNode *request)
{
static int alert_sequence_no = 0;

Expand All @@ -114,17 +114,17 @@ process_lrmd_alert_exec(pcmk__client_t *client, uint32_t id, xmlNode *request)
PCMK__XA_LRMD_ALERT_PATH);
svc_action_t *action = NULL;
int alert_timeout = 0;
int rc = pcmk_ok;
int rc = pcmk_rc_ok;
GHashTable *params = NULL;
struct alert_cb_s *cb_data = NULL;

if ((alert_id == NULL) || (alert_path == NULL) ||
(client == NULL) || (client->id == NULL)) { /* hint static analyzer */
rc = -EINVAL;
rc = EINVAL;
goto err;
}
if (draining_alerts) {
return pcmk_ok;
return pcmk_rc_ok;
}

crm_element_value_int(alert_xml, PCMK__XA_LRMD_TIMEOUT, &alert_timeout);
Expand All @@ -144,20 +144,21 @@ process_lrmd_alert_exec(pcmk__client_t *client, uint32_t id, xmlNode *request)
action = services_alert_create(alert_id, alert_path, alert_timeout, params,
alert_sequence_no, cb_data);
if (action->rc != PCMK_OCF_UNKNOWN) {
rc = -E2BIG;
rc = E2BIG;
goto err;
}

rc = services_action_user(action, CRM_DAEMON_USER);
if (rc < 0) {
rc = pcmk_legacy2rc(rc);
goto err;
}

add_inflight_alert(cb_data->call_id, alert_timeout);
if (services_alert_async(action, alert_complete) == FALSE) {
services_action_free(action);
}
return pcmk_ok;
return pcmk_rc_ok;

err:
if (cb_data) {
Expand Down
Loading