Skip to content

Commit d6b2ff4

Browse files
committed
wip
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
1 parent 9827176 commit d6b2ff4

2 files changed

Lines changed: 22 additions & 19 deletions

File tree

daemons/based/based_callbacks.c

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,14 @@ static bool
333333
parse_peer_options(const cib__operation_t *operation, pcmk__request_t *request,
334334
bool *local_notify, bool *needs_reply, bool *process)
335335
{
336+
/* Don't send replies for modifying ops because they already get forwarded
337+
* to all nodes. Also don't send a reply if the client specifically told us
338+
* not to.
339+
*/
340+
const bool can_reply = !operation->modifies_cib
341+
&& !pcmk__is_set(request->call_options,
342+
cib_discard_reply);
343+
336344
const char *host = pcmk__xe_get(request->xml, PCMK__XA_CIB_HOST);
337345
const char *delegated = pcmk__xe_get(request->xml,
338346
PCMK__XA_CIB_DELEGATED_FROM);
@@ -366,7 +374,6 @@ parse_peer_options(const cib__operation_t *operation, pcmk__request_t *request,
366374
pcmk__trace("Will notify local clients for %s reply from %s",
367375
request->op, originator);
368376
*process = false;
369-
*needs_reply = false;
370377
*local_notify = true;
371378
return true;
372379
}
@@ -378,6 +385,11 @@ parse_peer_options(const cib__operation_t *operation, pcmk__request_t *request,
378385
// sync_our_cib() sets PCMK__XA_CIB_ISREPLYTO
379386
delegated = reply_to;
380387

388+
/* @FIXME can_reply is always false here because cib__op_replace has
389+
* modifies_cib=true. Should we be sending a reply here?
390+
*/
391+
*needs_reply = can_reply;
392+
381393
} else if (pcmk__str_eq(request->op, PCMK__CIB_REQUEST_UPGRADE,
382394
pcmk__str_none)) {
383395
/* Only the DC (node with the oldest software) should process
@@ -407,7 +419,6 @@ parse_peer_options(const cib__operation_t *operation, pcmk__request_t *request,
407419
pcmk__trace("Will notify local clients for %s reply from %s",
408420
request->op, originator);
409421
*process = false;
410-
*needs_reply = false;
411422
*local_notify = true;
412423
return true;
413424
}
@@ -423,6 +434,7 @@ parse_peer_options(const cib__operation_t *operation, pcmk__request_t *request,
423434
if (pcmk__str_eq(host, OUR_NODENAME, pcmk__str_casei)) {
424435
pcmk__trace("Processing %s request sent to us from %s", request->op,
425436
originator);
437+
*needs_reply = can_reply;
426438
return true;
427439
}
428440

@@ -433,10 +445,10 @@ parse_peer_options(const cib__operation_t *operation, pcmk__request_t *request,
433445
}
434446

435447
if (!is_reply && pcmk__str_eq(request->op, CRM_OP_PING, pcmk__str_none)) {
448+
*needs_reply = can_reply;
436449
return true;
437450
}
438451

439-
*needs_reply = false;
440452
pcmk__trace("Processing %s request broadcast by %s call %s on %s "
441453
"(local clients will%s be notified)", request->op,
442454
pcmk__s(pcmk__xe_get(request->xml, PCMK__XA_CIB_CLIENTNAME),
@@ -643,11 +655,9 @@ based_handle_request(pcmk__request_t *request)
643655
{
644656
// @TODO: Break into multiple smaller functions
645657
bool process = true; // Whether to process request locally now
646-
bool needs_reply = true; // Whether to build a reply
658+
bool needs_reply = false; // Whether to build a reply
647659
bool local_notify = false; // Whether to notify (local) requester
648660

649-
xmlNode *reply = NULL;
650-
651661
int rc = pcmk_rc_ok;
652662
const char *originator = pcmk__xe_get(request->xml, PCMK__XA_SRC);
653663
const char *host = pcmk__xe_get(request->xml, PCMK__XA_CIB_HOST);
@@ -708,7 +718,6 @@ based_handle_request(pcmk__request_t *request)
708718
* CIB copy, and we don't notify for individual requests because the
709719
* entire transaction is atomic.
710720
*/
711-
needs_reply = false;
712721
pcmk__trace("Processing %s op from %s/%s on %s locally because it's "
713722
"part of a transaction", request->op, client_name, call_id,
714723
pcmk__xe_get(request->xml, PCMK__XA_SRC));
@@ -726,7 +735,6 @@ based_handle_request(pcmk__request_t *request)
726735
}
727736

728737
// Process locally and notify local client; no peer to reply to
729-
needs_reply = false;
730738
local_notify = true;
731739

732740
log_local_options(request->ipc_client, host, request->op);
@@ -738,7 +746,6 @@ based_handle_request(pcmk__request_t *request)
738746
}
739747

740748
if (pcmk__is_set(request->call_options, cib_discard_reply)) {
741-
needs_reply = false;
742749
local_notify = false;
743750
pcmk__trace("Client is not interested in the reply");
744751
}
@@ -747,11 +754,7 @@ based_handle_request(pcmk__request_t *request)
747754
rc = cib_status;
748755
pcmk__err("Ignoring request because cluster configuration is invalid "
749756
"(please repair and restart): %s", pcmk_rc_str(rc));
750-
751-
if (!pcmk__is_set(request->call_options, cib_discard_reply)) {
752-
reply = create_cib_reply(request->xml, rc, based_cib);
753-
}
754-
757+
output = based_cib;
755758
goto done;
756759
}
757760

@@ -770,13 +773,12 @@ based_handle_request(pcmk__request_t *request)
770773

771774
log_op_result(request->xml, operation, rc, (time(NULL) - start_time));
772775

773-
if (!pcmk__is_set(request->call_options, cib_discard_reply)) {
774-
reply = create_cib_reply(request->xml, rc, output);
775-
}
776-
777776
done:
778-
if (!operation->modifies_cib && needs_reply && !based_stand_alone()) {
777+
if (needs_reply) {
778+
xmlNode *reply = create_cib_reply(request->xml, rc, output);
779+
779780
send_peer_reply(reply, originator);
781+
pcmk__xml_free(reply);
780782
}
781783

782784
if (local_notify && (client_id != NULL)) {

daemons/based/based_messages.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ based_process_upgrade(xmlNode *req, xmlNode **cib, xmlNode **answer)
277277
static xmlNode *
278278
cib_msg_copy(const xmlNode *msg)
279279
{
280+
// @FIXME Copying CIB_CALLOPT seems problematic if it has cib_discard_reply
280281
static const char *field_list[] = {
281282
PCMK__XA_T,
282283
PCMK__XA_CIB_CLIENTID,

0 commit comments

Comments
 (0)