File pacemaker-messages-failed-remote-sends.patch of Package pacemaker.14737

commit ee97c386e6d7163ca09606680152fc21002e753b
Author: Ken Gaillot <kgaillot@redhat.com>
Date:   Thu Oct 26 12:37:54 2017 -0500

    Log: libcrmcommon,liblrmd,lrmd: improve messages for failed remote sends
    
    Most significantly, don't log a redundant message in lrmd_tls_send_msg()
    (crm_remote_send() will already log the error), and don't warn if
    a client notification fails because the client is disconnected.

diff --git a/lib/common/remote.c b/lib/common/remote.c
index a3e472003..01f0409ef 100644
--- a/lib/common/remote.c
+++ b/lib/common/remote.c
@@ -342,7 +342,7 @@ crm_remote_send(crm_remote_t * remote, xmlNode * msg)
     struct crm_remote_header_v0 *header;
 
     if (xml_text == NULL) {
-        crm_err("Invalid XML, can not send msg");
+        crm_err("Could not send remote message: no message provided");
         return -EINVAL;
     }
 
@@ -365,7 +365,8 @@ crm_remote_send(crm_remote_t * remote, xmlNode * msg)
               (int)iov[0].iov_len, *(int*)(void*)xml_text);
     rc = crm_remote_sendv(remote, iov, 2);
     if (rc < 0) {
-        crm_err("Failed to send remote msg, rc = %d", rc);
+        crm_err("Could not send remote message: %s " CRM_XS " rc=%d",
+                pcmk_strerror(rc), rc);
     }
 
     free(iov[0].iov_base);
diff --git a/lib/lrmd/lrmd_client.c b/lib/lrmd/lrmd_client.c
index 44b7f2ace..b91f7eb6c 100644
--- a/lib/lrmd/lrmd_client.c
+++ b/lib/lrmd/lrmd_client.c
@@ -553,19 +553,9 @@ lrmd_tls_connection_destroy(gpointer userdata)
 int
 lrmd_tls_send_msg(crm_remote_t * session, xmlNode * msg, uint32_t id, const char *msg_type)
 {
-    int rc = -1;
-
     crm_xml_add_int(msg, F_LRMD_REMOTE_MSG_ID, id);
     crm_xml_add(msg, F_LRMD_REMOTE_MSG_TYPE, msg_type);
-
-    rc = crm_remote_send(session, msg);
-
-    if (rc < 0) {
-        crm_err("Failed to send remote lrmd tls msg, rc = %d", rc);
-        return rc;
-    }
-
-    return rc;
+    return crm_remote_send(session, msg);
 }
 
 static xmlNode *
diff --git a/lrmd/lrmd.c b/lrmd/lrmd.c
index 49bc0c283..918261c88 100644
--- a/lrmd/lrmd.c
+++ b/lrmd/lrmd.c
@@ -396,6 +396,7 @@ send_client_notify(gpointer key, gpointer value, gpointer user_data)
 {
     xmlNode *update_msg = user_data;
     crm_client_t *client = value;
+    int rc;
 
     if (client == NULL) {
         crm_err("Asked to send event to  NULL client");
@@ -405,8 +406,11 @@ send_client_notify(gpointer key, gpointer value, gpointer user_data)
         return;
     }
 
-    if (lrmd_server_send_notify(client, update_msg) <= 0) {
-        crm_warn("Notification of client %s/%s failed", client->name, client->id);
+    rc = lrmd_server_send_notify(client, update_msg);
+    if ((rc <= 0) && (rc != -ENOTCONN)) {
+        crm_warn("Could not notify client %s/%s: %s " CRM_XS " rc=%d",
+                 client->name, client->id,
+                 (rc? pcmk_strerror(rc) : "no data sent"), rc);
     }
 }
 
diff --git a/lrmd/main.c b/lrmd/main.c
index 0a4ce3915..940cf104e 100644
--- a/lrmd/main.c
+++ b/lrmd/main.c
@@ -224,7 +224,7 @@ int
 lrmd_server_send_reply(crm_client_t * client, uint32_t id, xmlNode * reply)
 {
 
-    crm_trace("sending reply to client (%s) with msg id %d", client->id, id);
+    crm_trace("Sending reply (%d) to client (%s)", id, client->id);
     switch (client->kind) {
         case CRM_CLIENT_IPC:
             return crm_ipcs_send(client, id, reply, FALSE);
@@ -233,7 +233,8 @@ lrmd_server_send_reply(crm_client_t * client, uint32_t id, xmlNode * reply)
             return lrmd_tls_send_msg(client->remote, reply, id, "reply");
 #endif
         default:
-            crm_err("Unknown lrmd client type %d", client->kind);
+            crm_err("Could not send reply: unknown client type %d",
+                    client->kind);
     }
     return -ENOTCONN;
 }
@@ -241,24 +242,24 @@ lrmd_server_send_reply(crm_client_t * client, uint32_t id, xmlNode * reply)
 int
 lrmd_server_send_notify(crm_client_t * client, xmlNode * msg)
 {
-    crm_trace("sending notify to client (%s)", client->id);
+    crm_trace("Sending notification to client (%s)", client->id);
     switch (client->kind) {
         case CRM_CLIENT_IPC:
             if (client->ipcs == NULL) {
-                crm_trace("Asked to send event to disconnected local client");
+                crm_trace("Could not notify local client: disconnected");
                 return -ENOTCONN;
             }
             return crm_ipcs_send(client, 0, msg, crm_ipc_server_event);
 #ifdef ENABLE_PCMK_REMOTE
         case CRM_CLIENT_TLS:
             if (client->remote == NULL) {
-                crm_trace("Asked to send event to disconnected remote client");
+                crm_trace("Could not notify remote client: disconnected");
                 return -ENOTCONN;
             }
             return lrmd_tls_send_msg(client->remote, msg, 0, "notify");
 #endif
         default:
-            crm_err("Unknown lrmd client type %d", client->kind);
+            crm_err("Could not notify client: unknown type %d", client->kind);
     }
     return -ENOTCONN;
 }
openSUSE Build Service is sponsored by