Skip to content

Commit 4c986c2

Browse files
committed
Refactor: controller: Add cur_data arg to register_fsa_error()
Previously, we relied on a msg_data variable being declared. I found this very non-intuitive. We often created such a variable just as a dummy so that the macro would work. Signed-off-by: Reid Wahl <[email protected]>
1 parent e45ed18 commit 4c986c2

File tree

10 files changed

+27
-46
lines changed

10 files changed

+27
-46
lines changed

daemons/controld/controld_cib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ do_cib_control(long long action, enum crmd_fsa_cause cause,
193193
} else {
194194
crm_err("Could not complete CIB registration %d times... "
195195
"hard error", cib_retries);
196-
register_fsa_error(I_ERROR);
196+
register_fsa_error(I_ERROR, msg_data);
197197
}
198198
}
199199
}

daemons/controld/controld_control.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ do_ha_control(long long action, enum crmd_fsa_cause cause,
7777

7878
if (!connected) {
7979
controld_set_fsa_input_flags(R_HA_DISCONNECTED);
80-
register_fsa_error(I_ERROR);
80+
register_fsa_error(I_ERROR, msg_data);
8181
return;
8282
}
8383

@@ -120,7 +120,7 @@ do_shutdown_req(long long action, enum crmd_fsa_cause cause,
120120
CRM_SYSTEM_CRMD, CRM_OP_SHUTDOWN_REQ, NULL);
121121

122122
if (!pcmk__cluster_send_message(NULL, pcmk_ipc_controld, msg)) {
123-
register_fsa_error(I_ERROR);
123+
register_fsa_error(I_ERROR, msg_data);
124124
}
125125
pcmk__xml_free(msg);
126126
}
@@ -342,7 +342,7 @@ do_startup(long long action, enum crmd_fsa_cause cause,
342342

343343
lrm_state_init_local();
344344
if (!controld_init_fsa_timers()) {
345-
register_fsa_error(I_ERROR);
345+
register_fsa_error(I_ERROR, msg_data);
346346
}
347347
}
348348

@@ -509,7 +509,7 @@ do_started(long long action, enum crmd_fsa_cause cause,
509509
if (ipcs == NULL) {
510510
crm_err("Failed to create IPC server: shutting down and inhibiting "
511511
"respawn");
512-
register_fsa_error(I_ERROR);
512+
register_fsa_error(I_ERROR, msg_data);
513513

514514
} else {
515515
crm_notice("Pacemaker controller successfully started and accepting "
@@ -545,10 +545,8 @@ config_query_callback(xmlNode * msg, int call_id, int rc, xmlNode * output, void
545545
};
546546

547547
if (rc != pcmk_ok) {
548-
fsa_data_t *msg_data = NULL;
549-
550548
crm_err("Local CIB query resulted in an error: %s", pcmk_strerror(rc));
551-
register_fsa_error(I_ERROR);
549+
register_fsa_error(I_ERROR, NULL);
552550

553551
if (rc == -EACCES || rc == -pcmk_err_schema_validation) {
554552
crm_err("The cluster is mis-configured - shutting down and staying down");
@@ -563,10 +561,8 @@ config_query_callback(xmlNode * msg, int call_id, int rc, xmlNode * output, void
563561
NULL);
564562
}
565563
if (!crmconfig) {
566-
fsa_data_t *msg_data = NULL;
567-
568564
crm_err("Local CIB query for " PCMK_XE_CRM_CONFIG " section failed");
569-
register_fsa_error(I_ERROR);
565+
register_fsa_error(I_ERROR, NULL);
570566
goto bail;
571567
}
572568

daemons/controld/controld_election.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,9 @@ feature_update_callback(xmlNode *msg, int call_id, int rc, xmlNode *output,
165165
rc = pcmk_legacy2rc(rc);
166166

167167
if (rc != pcmk_rc_ok) {
168-
fsa_data_t *msg_data = NULL;
169-
170168
crm_notice("Feature set update failed: %s " QB_XS " rc=%d",
171169
pcmk_rc_str(rc), rc);
172-
register_fsa_error(I_ERROR);
170+
register_fsa_error(I_ERROR, NULL);
173171
}
174172
}
175173

daemons/controld/controld_execd.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ try_local_executor_connect(long long action, fsa_data_t *msg_data,
340340
"%d time%s: %s", lrm_state->num_lrm_register_fails,
341341
pcmk__plural_s(lrm_state->num_lrm_register_fails),
342342
pcmk_rc_str(rc));
343-
register_fsa_error(I_ERROR);
343+
register_fsa_error(I_ERROR, msg_data);
344344
}
345345

346346
// A_LRM_CONNECT
@@ -361,7 +361,7 @@ do_lrm_control(long long action, enum crmd_fsa_cause cause,
361361

362362
lrm_state = controld_get_executor_state(NULL, true);
363363
if (lrm_state == NULL) {
364-
register_fsa_error(I_ERROR);
364+
register_fsa_error(I_ERROR, msg_data);
365365
return;
366366
}
367367

@@ -942,8 +942,6 @@ get_lrm_resource(lrm_state_t *lrm_state, const xmlNode *rsc_xml,
942942
rc = lrm_state_register_rsc(lrm_state, id, class, provider, type,
943943
lrmd_opt_drop_recurring);
944944
if (rc != pcmk_ok) {
945-
fsa_data_t *msg_data = NULL;
946-
947945
crm_err("Could not register resource %s with the executor on %s: %s "
948946
QB_XS " rc=%d",
949947
id, lrm_state->node_name, pcmk_strerror(rc), rc);
@@ -953,7 +951,7 @@ get_lrm_resource(lrm_state_t *lrm_state, const xmlNode *rsc_xml,
953951
* remote node, which is not an FSA failure.
954952
*/
955953
if (lrm_state_is_local(lrm_state) == TRUE) {
956-
register_fsa_error(I_FAIL);
954+
register_fsa_error(I_FAIL, NULL);
957955
}
958956
return rc;
959957
}
@@ -1569,7 +1567,7 @@ controld_invoke_execd(fsa_data_t *msg_data)
15691567
} else {
15701568
crm_err("Invalid execution request: unknown command '%s' (bug?)",
15711569
crm_op);
1572-
register_fsa_error(I_ERROR);
1570+
register_fsa_error(I_ERROR, msg_data);
15731571
}
15741572
}
15751573

@@ -1898,7 +1896,6 @@ do_lrm_rsc_op(lrm_state_t *lrm_state, lrmd_rsc_info_t *rsc, xmlNode *msg,
18981896
int call_id = 0;
18991897
char *op_id = NULL;
19001898
lrmd_event_data_t *op = NULL;
1901-
fsa_data_t *msg_data = NULL;
19021899
const char *transition = NULL;
19031900
const char *operation = NULL;
19041901
const char *nack_reason = NULL;
@@ -2032,7 +2029,7 @@ do_lrm_rsc_op(lrm_state_t *lrm_state, lrmd_rsc_info_t *rsc, xmlNode *msg,
20322029
fake_op_status(lrm_state, op, PCMK_EXEC_NOT_CONNECTED,
20332030
PCMK_OCF_UNKNOWN_ERROR, pcmk_rc_str(rc));
20342031
process_lrm_event(lrm_state, op, NULL, NULL);
2035-
register_fsa_error(I_FAIL);
2032+
register_fsa_error(I_FAIL, NULL);
20362033

20372034
} else {
20382035
crm_err("Could not initiate %s action for resource %s remotely on %s: "

daemons/controld/controld_join_client.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,11 @@ join_query_callback(xmlNode *msg, int call_id, int rc, xmlNode *output,
112112
query_call_id = 0;
113113

114114
if ((rc != pcmk_ok) || (output == NULL)) {
115-
fsa_data_t *msg_data = NULL;
116-
117115
rc = pcmk_legacy2rc(rc);
118116
crm_err("Could not retrieve version details for join-%s: %s (%d)",
119117
pcmk__s(join_id, "(unknown)"), pcmk_rc_str(rc), rc);
120118

121-
register_fsa_error(I_ERROR);
119+
register_fsa_error(I_ERROR, NULL);
122120
return;
123121
}
124122
if (controld_globals.dc_name == NULL) {
@@ -288,7 +286,7 @@ do_cl_join_finalize_respond(long long action, enum crmd_fsa_cause cause,
288286
crm_err("Shutting down because cluster join with leader %s failed "
289287
QB_XS " join-%d NACK'd",
290288
pcmk__s(welcome_from, "(unknown)"), join_id);
291-
register_fsa_error(I_ERROR);
289+
register_fsa_error(I_ERROR, msg_data);
292290
controld_set_fsa_input_flags(R_STAYDOWN);
293291
return;
294292
}
@@ -315,7 +313,7 @@ do_cl_join_finalize_respond(long long action, enum crmd_fsa_cause cause,
315313
crm_err("Could not confirm join-%d with %s: "
316314
"Failed to get executor state for local node",
317315
join_id, controld_globals.dc_name);
318-
register_fsa_error(I_FAIL);
316+
register_fsa_error(I_FAIL, msg_data);
319317
return;
320318
}
321319

daemons/controld/controld_join_dc.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,13 +730,11 @@ join_node_state_commit_callback(xmlNode *msg, int call_id, int rc,
730730
const char *node = user_data;
731731

732732
if (rc != pcmk_ok) {
733-
fsa_data_t *msg_data = NULL; // for register_fsa_error() macro
734-
735733
crm_crit("join-%d node history update (via CIB call %d) for node %s "
736734
"failed: %s",
737735
current_join_id, call_id, node, pcmk_strerror(rc));
738736
crm_log_xml_debug(msg, "failed");
739-
register_fsa_error(I_ERROR);
737+
register_fsa_error(I_ERROR, NULL);
740738
}
741739

742740
crm_debug("join-%d node history update (via CIB call %d) for node %s "
@@ -879,7 +877,7 @@ do_dc_join_ack(long long action, enum crmd_fsa_cause cause,
879877
rc = pcmk_legacy2rc(rc);
880878
crm_crit("join-%d node history update for node %s failed: %s",
881879
current_join_id, join_from, pcmk_rc_str(rc));
882-
register_fsa_error(I_ERROR);
880+
register_fsa_error(I_ERROR, msg_data);
883881
}
884882
free(join_from);
885883
free(xpath);

daemons/controld/controld_membership.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,18 @@ post_cache_update(int instance)
9696
static void
9797
crmd_node_update_complete(xmlNode * msg, int call_id, int rc, xmlNode * output, void *user_data)
9898
{
99-
fsa_data_t *msg_data = NULL;
100-
10199
if (rc == pcmk_ok) {
102100
crm_trace("Node update %d complete", call_id);
103101

104102
} else if(call_id < pcmk_ok) {
105103
crm_err("Node update failed: %s (%d)", pcmk_strerror(call_id), call_id);
106104
crm_log_xml_debug(msg, "failed");
107-
register_fsa_error(I_ERROR);
105+
register_fsa_error(I_ERROR, NULL);
108106

109107
} else {
110108
crm_err("Node update %d failed: %s (%d)", call_id, pcmk_strerror(rc), rc);
111109
crm_log_xml_debug(msg, "failed");
112-
register_fsa_error(I_ERROR);
110+
register_fsa_error(I_ERROR, NULL);
113111
}
114112
}
115113

@@ -352,17 +350,15 @@ populate_cib_nodes_from_cache(xmlNode *nodes_xml)
352350
static void
353351
node_list_update_callback(xmlNode * msg, int call_id, int rc, xmlNode * output, void *user_data)
354352
{
355-
fsa_data_t *msg_data = NULL;
356-
357353
if(call_id < pcmk_ok) {
358354
crm_err("Node list update failed: %s (%d)", pcmk_strerror(call_id), call_id);
359355
crm_log_xml_debug(msg, "update:failed");
360-
register_fsa_error(I_ERROR);
356+
register_fsa_error(I_ERROR, NULL);
361357

362358
} else if(rc < pcmk_ok) {
363359
crm_err("Node update %d failed: %s (%d)", call_id, pcmk_strerror(rc), rc);
364360
crm_log_xml_debug(msg, "update:failed");
365-
register_fsa_error(I_ERROR);
361+
register_fsa_error(I_ERROR, NULL);
366362
}
367363
}
368364

@@ -429,15 +425,13 @@ populate_cib_nodes(uint32_t flags, const char *source)
429425
static void
430426
cib_quorum_update_complete(xmlNode * msg, int call_id, int rc, xmlNode * output, void *user_data)
431427
{
432-
fsa_data_t *msg_data = NULL;
433-
434428
if (rc == pcmk_ok) {
435429
crm_trace("Quorum update %d complete", call_id);
436430

437431
} else {
438432
crm_err("Quorum update %d failed: %s (%d)", call_id, pcmk_strerror(rc), rc);
439433
crm_log_xml_debug(msg, "failed");
440-
register_fsa_error(I_ERROR);
434+
register_fsa_error(I_ERROR, NULL);
441435
}
442436
}
443437

daemons/controld/controld_messages.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ extern void delete_ha_msg_input(ha_msg_input_t * orig);
2323
void register_fsa_error_adv(enum crmd_fsa_input input, fsa_data_t *cur_data,
2424
ha_msg_input_t *new_data, const char *raised_from);
2525

26-
#define register_fsa_error(input) \
27-
register_fsa_error_adv(input, msg_data, NULL, __func__)
26+
#define register_fsa_error(input, cur_data) \
27+
register_fsa_error_adv((input), (cur_data), NULL, __func__)
2828

2929
void register_fsa_input_adv(enum crmd_fsa_cause cause,
3030
enum crmd_fsa_input input, ha_msg_input_t *data,

daemons/controld/controld_schedulerd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ do_pe_control(long long action, enum crmd_fsa_cause cause,
230230

231231
} else if (!new_schedulerd_ipc_connection()) {
232232
crm_warn("Could not connect to scheduler");
233-
register_fsa_error(I_FAIL);
233+
register_fsa_error(I_FAIL, msg_data);
234234
}
235235
}
236236
}

daemons/controld/controld_transition.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ do_te_invoke(long long action, enum crmd_fsa_cause cause,
130130
graph_data = input->xml;
131131
if (graph_data == NULL) {
132132
crm_log_xml_err(input->msg, "Bad command");
133-
register_fsa_error(I_FAIL);
133+
register_fsa_error(I_FAIL, msg_data);
134134
return;
135135
}
136136

0 commit comments

Comments
 (0)