pacemaker  1.1.24-3850484742
Scalable High-Availability cluster resource manager
corosync.c
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2019 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8  */
9 
10 #include <crm_internal.h>
11 #include <bzlib.h>
12 #include <sys/socket.h>
13 #include <netinet/in.h>
14 #include <arpa/inet.h>
15 #include <netdb.h>
16 
17 #include <crm/common/ipc.h>
18 #include <crm/cluster/internal.h>
19 #include <crm/common/mainloop.h>
20 #include <sys/utsname.h>
21 
22 #include <qb/qbipcc.h>
23 #include <qb/qbutil.h>
24 
25 #include <corosync/corodefs.h>
26 #include <corosync/corotypes.h>
27 #include <corosync/hdb.h>
28 #include <corosync/cfg.h>
29 #include <corosync/cmap.h>
30 #include <corosync/quorum.h>
31 
32 #include <crm/msg_xml.h>
33 
34 #include <crm/common/ipc_internal.h> /* PCMK__SPECIAL_PID* */
35 
36 quorum_handle_t pcmk_quorum_handle = 0;
37 
38 gboolean(*quorum_app_callback) (unsigned long long seq, gboolean quorate) = NULL;
39 
40 /*
41  * CFG functionality stolen from node_name() in corosync-quorumtool.c
42  * This resolves the first address assigned to a node and returns the name or IP address.
43  */
44 char *
45 corosync_node_name(uint64_t /*cmap_handle_t */ cmap_handle, uint32_t nodeid)
46 {
47  int lpc = 0;
48  cs_error_t rc = CS_OK;
49  int retries = 0;
50  char *name = NULL;
51  cmap_handle_t local_handle = 0;
52  int fd = -1;
53  uid_t found_uid = 0;
54  gid_t found_gid = 0;
55  pid_t found_pid = 0;
56  int rv;
57 
58  /* nodeid == 0 == CMAN_NODEID_US */
59  if (nodeid == 0) {
60  nodeid = get_local_nodeid(0);
61  }
62 
63  if (cmap_handle == 0 && local_handle == 0) {
64  retries = 0;
65  crm_trace("Initializing CMAP connection");
66  do {
67  rc = cmap_initialize(&local_handle);
68  if (rc != CS_OK) {
69  retries++;
70  crm_debug("API connection setup failed: %s. Retrying in %ds", cs_strerror(rc),
71  retries);
72  sleep(retries);
73  }
74 
75  } while (retries < 5 && rc != CS_OK);
76 
77  if (rc != CS_OK) {
78  crm_warn("Could not connect to Cluster Configuration Database API, error %s",
79  cs_strerror(rc));
80  local_handle = 0;
81  }
82  }
83 
84  if (cmap_handle == 0) {
85  cmap_handle = local_handle;
86 
87  rc = cmap_fd_get(cmap_handle, &fd);
88  if (rc != CS_OK) {
89  crm_err("Could not obtain the CMAP API connection: %s (%d)",
90  cs_strerror(rc), rc);
91  goto bail;
92  }
93 
94  /* CMAP provider run as root (in given user namespace, anyway)? */
95  if (!(rv = crm_ipc_is_authentic_process(fd, (uid_t) 0,(gid_t) 0, &found_pid,
96  &found_uid, &found_gid))) {
97  crm_err("CMAP provider is not authentic:"
98  " process %lld (uid: %lld, gid: %lld)",
99  (long long) PCMK__SPECIAL_PID_AS_0(found_pid),
100  (long long) found_uid, (long long) found_gid);
101  goto bail;
102  } else if (rv < 0) {
103  crm_err("Could not verify authenticity of CMAP provider: %s (%d)",
104  strerror(-rv), -rv);
105  goto bail;
106  }
107  }
108 
109  while (name == NULL && cmap_handle != 0) {
110  uint32_t id = 0;
111  char *key = NULL;
112 
113  key = crm_strdup_printf("nodelist.node.%d.nodeid", lpc);
114  rc = cmap_get_uint32(cmap_handle, key, &id);
115  crm_trace("Checking %u vs %u from %s", nodeid, id, key);
116  free(key);
117 
118  if (rc != CS_OK) {
119  break;
120  }
121 
122  if (nodeid == id) {
123  crm_trace("Searching for node name for %u in nodelist.node.%d %s", nodeid, lpc, name);
124  if (name == NULL) {
125  key = crm_strdup_printf("nodelist.node.%d.ring0_addr", lpc);
126  cmap_get_string(cmap_handle, key, &name);
127  crm_trace("%s = %s", key, name);
128 
129  if (node_name_is_valid(key, name) == FALSE) {
130  free(name);
131  name = NULL;
132  }
133  free(key);
134  }
135 
136  if (name == NULL) {
137  key = crm_strdup_printf("nodelist.node.%d.name", lpc);
138  cmap_get_string(cmap_handle, key, &name);
139  crm_trace("%s = %s %d", key, name, rc);
140  free(key);
141  }
142  break;
143  }
144 
145  lpc++;
146  }
147 
148 bail:
149  if(local_handle) {
150  cmap_finalize(local_handle);
151  }
152 
153  if (name == NULL) {
154  crm_info("Unable to get node name for nodeid %u", nodeid);
155  }
156  return name;
157 }
158 
159 void
161 {
162  crm_info("Disconnecting from Corosync");
163 
164  cluster_disconnect_cpg(cluster);
165 
166  if (pcmk_quorum_handle) {
167  crm_trace("Disconnecting quorum");
168  quorum_finalize(pcmk_quorum_handle);
169  pcmk_quorum_handle = 0;
170 
171  } else {
172  crm_info("No Quorum connection");
173  }
174 
175  crm_notice("Disconnected from Corosync");
176 }
177 
179 gboolean ais_membership_force = FALSE;
180 
181 
182 static int
183 pcmk_quorum_dispatch(gpointer user_data)
184 {
185  int rc = 0;
186 
187  rc = quorum_dispatch(pcmk_quorum_handle, CS_DISPATCH_ALL);
188  if (rc < 0) {
189  crm_err("Connection to the Quorum API failed: %d", rc);
190  pcmk_quorum_handle = 0;
191  return -1;
192  }
193  return 0;
194 }
195 
196 static void
197 pcmk_quorum_notification(quorum_handle_t handle,
199  uint64_t ring_id, uint32_t view_list_entries, uint32_t * view_list)
200 {
201  int i;
202  GHashTableIter iter;
203  crm_node_t *node = NULL;
204  static gboolean init_phase = TRUE;
205 
206  if (quorate != crm_have_quorum) {
207  if (quorate) {
208  crm_notice("Quorum acquired " CRM_XS " membership=" U64T " members=%lu",
209  ring_id, (long unsigned int)view_list_entries);
210  } else {
211  crm_warn("Quorum lost " CRM_XS " membership=" U64T " members=%lu",
212  ring_id, (long unsigned int)view_list_entries);
213  }
215 
216  } else {
217  crm_info("Quorum %s " CRM_XS " membership=" U64T " members=%lu",
218  (quorate? "retained" : "still lost"), ring_id,
219  (long unsigned int)view_list_entries);
220  }
221 
222  if (view_list_entries == 0 && init_phase) {
223  crm_info("Corosync membership is still forming, ignoring");
224  return;
225  }
226 
227  init_phase = FALSE;
228 
229  /* Reset last_seen for all cached nodes so we can tell which ones aren't
230  * in the view list */
231  g_hash_table_iter_init(&iter, crm_peer_cache);
232  while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &node)) {
233  node->last_seen = 0;
234  }
235 
236  /* Update the peer cache for each node in view list */
237  for (i = 0; i < view_list_entries; i++) {
238  uint32_t id = view_list[i];
239 
240  crm_debug("Member[%d] %u ", i, id);
241 
242  /* Get this node's peer cache entry (adding one if not already there) */
243  node = crm_get_peer(id, NULL);
244  if (node->uname == NULL) {
245  char *name = corosync_node_name(0, id);
246 
247  crm_info("Obtaining name for new node %u", id);
248  node = crm_get_peer(id, name);
249  free(name);
250  }
251 
252  /* Update the node state (including updating last_seen to ring_id) */
253  crm_update_peer_state(__FUNCTION__, node, CRM_NODE_MEMBER, ring_id);
254  }
255 
256  /* Remove any peer cache entries we didn't update */
257  crm_reap_unseen_nodes(ring_id);
258 
259  if (quorum_app_callback) {
260  quorum_app_callback(ring_id, quorate);
261  }
262 }
263 
264 quorum_callbacks_t quorum_callbacks = {
265  .quorum_notify_fn = pcmk_quorum_notification,
266 };
267 
268 gboolean
269 cluster_connect_quorum(gboolean(*dispatch) (unsigned long long, gboolean),
270  void (*destroy) (gpointer))
271 {
272  cs_error_t rc;
273  int fd = 0;
274  int quorate = 0;
275  uint32_t quorum_type = 0;
276  struct mainloop_fd_callbacks quorum_fd_callbacks;
277  uid_t found_uid = 0;
278  gid_t found_gid = 0;
279  pid_t found_pid = 0;
280  int rv;
281 
282  quorum_fd_callbacks.dispatch = pcmk_quorum_dispatch;
283  quorum_fd_callbacks.destroy = destroy;
284 
285  crm_debug("Configuring Pacemaker to obtain quorum from Corosync");
286 
287  rc = quorum_initialize(&pcmk_quorum_handle, &quorum_callbacks, &quorum_type);
288  if (rc != CS_OK) {
289  crm_err("Could not connect to the Quorum API: %s (%d)",
290  cs_strerror(rc), rc);
291  goto bail;
292 
293  } else if (quorum_type != QUORUM_SET) {
294  crm_err("Corosync quorum is not configured");
295  goto bail;
296  }
297 
298  rc = quorum_fd_get(pcmk_quorum_handle, &fd);
299  if (rc != CS_OK) {
300  crm_err("Could not obtain the Quorum API connection: %s (%d)",
301  strerror(rc), rc);
302  goto bail;
303  }
304 
305  /* Quorum provider run as root (in given user namespace, anyway)? */
306  if (!(rv = crm_ipc_is_authentic_process(fd, (uid_t) 0,(gid_t) 0, &found_pid,
307  &found_uid, &found_gid))) {
308  crm_err("Quorum provider is not authentic:"
309  " process %lld (uid: %lld, gid: %lld)",
310  (long long) PCMK__SPECIAL_PID_AS_0(found_pid),
311  (long long) found_uid, (long long) found_gid);
312  rc = CS_ERR_ACCESS;
313  goto bail;
314  } else if (rv < 0) {
315  crm_err("Could not verify authenticity of Quorum provider: %s (%d)",
316  strerror(-rv), -rv);
317  rc = CS_ERR_ACCESS;
318  goto bail;
319  }
320 
321  rc = quorum_getquorate(pcmk_quorum_handle, &quorate);
322  if (rc != CS_OK) {
323  crm_err("Could not obtain the current Quorum API state: %d", rc);
324  goto bail;
325  }
326 
327  if (quorate) {
328  crm_notice("Quorum acquired");
329  } else {
330  crm_warn("Quorum lost");
331  }
334 
335  rc = quorum_trackstart(pcmk_quorum_handle, CS_TRACK_CHANGES | CS_TRACK_CURRENT);
336  if (rc != CS_OK) {
337  crm_err("Could not setup Quorum API notifications: %d", rc);
338  goto bail;
339  }
340 
341  mainloop_add_fd("quorum", G_PRIORITY_HIGH, fd, dispatch, &quorum_fd_callbacks);
342 
343  corosync_initialize_nodelist(NULL, FALSE, NULL);
344 
345  bail:
346  if (rc != CS_OK) {
347  quorum_finalize(pcmk_quorum_handle);
348  return FALSE;
349  }
350  return TRUE;
351 }
352 
353 gboolean
355 {
356  int retries = 0;
357 
358  while (retries < 5) {
359  int rc = init_cs_connection_once(cluster);
360 
361  retries++;
362 
363  switch (rc) {
364  case CS_OK:
365  return TRUE;
366  break;
367  case CS_ERR_TRY_AGAIN:
368  case CS_ERR_QUEUE_FULL:
369  sleep(retries);
370  break;
371  default:
372  return FALSE;
373  }
374  }
375 
376  crm_err("Could not connect to corosync after %d retries", retries);
377  return FALSE;
378 }
379 
380 gboolean
382 {
383  crm_node_t *peer = NULL;
384  enum cluster_type_e stack = get_cluster_type();
385 
386  crm_peer_init();
387 
388  /* Here we just initialize comms */
389  if (stack != pcmk_cluster_corosync) {
390  crm_err("Invalid cluster type: %s (%d)", name_for_cluster_type(stack), stack);
391  return FALSE;
392  }
393 
394  if (cluster_connect_cpg(cluster) == FALSE) {
395  return FALSE;
396  }
397  crm_info("Connection to '%s': established", name_for_cluster_type(stack));
398 
399  cluster->nodeid = get_local_nodeid(0);
400  if(cluster->nodeid == 0) {
401  crm_err("Could not establish local nodeid");
402  return FALSE;
403  }
404 
405  cluster->uname = get_node_name(0);
406  if(cluster->uname == NULL) {
407  crm_err("Could not establish local node name");
408  return FALSE;
409  }
410 
411  /* Ensure the local node always exists */
412  peer = crm_get_peer(cluster->nodeid, cluster->uname);
413  cluster->uuid = get_corosync_uuid(peer);
414 
415  return TRUE;
416 }
417 
418 gboolean
419 check_message_sanity(const AIS_Message * msg, const char *data)
420 {
421  gboolean sane = TRUE;
422  int dest = msg->host.type;
423  int tmp_size = msg->header.size - sizeof(AIS_Message);
424 
425  if (sane && msg->header.size == 0) {
426  crm_warn("Message with no size");
427  sane = FALSE;
428  }
429 
430  if (sane && msg->header.error != CS_OK) {
431  crm_warn("Message header contains an error: %d", msg->header.error);
432  sane = FALSE;
433  }
434 
435  if (sane && ais_data_len(msg) != tmp_size) {
436  crm_warn("Message payload size is incorrect: expected %d, got %d", ais_data_len(msg),
437  tmp_size);
438  sane = TRUE;
439  }
440 
441  if (sane && ais_data_len(msg) == 0) {
442  crm_warn("Message with no payload");
443  sane = FALSE;
444  }
445 
446  if (sane && data && msg->is_compressed == FALSE) {
447  int str_size = strlen(data) + 1;
448 
449  if (ais_data_len(msg) != str_size) {
450  int lpc = 0;
451 
452  crm_warn("Message payload is corrupted: expected %d bytes, got %d",
453  ais_data_len(msg), str_size);
454  sane = FALSE;
455  for (lpc = (str_size - 10); lpc < msg->size; lpc++) {
456  if (lpc < 0) {
457  lpc = 0;
458  }
459  crm_debug("bad_data[%d]: %d / '%c'", lpc, data[lpc], data[lpc]);
460  }
461  }
462  }
463 
464  if (sane == FALSE) {
465  crm_err("Invalid message %d: (dest=%s:%s, from=%s:%s.%u, compressed=%d, size=%d, total=%d)",
466  msg->id, ais_dest(&(msg->host)), msg_type2text(dest),
467  ais_dest(&(msg->sender)), msg_type2text(msg->sender.type),
468  msg->sender.pid, msg->is_compressed, ais_data_len(msg), msg->header.size);
469 
470  } else {
471  crm_trace
472  ("Verified message %d: (dest=%s:%s, from=%s:%s.%u, compressed=%d, size=%d, total=%d)",
473  msg->id, ais_dest(&(msg->host)), msg_type2text(dest), ais_dest(&(msg->sender)),
474  msg_type2text(msg->sender.type), msg->sender.pid, msg->is_compressed,
475  ais_data_len(msg), msg->header.size);
476  }
477 
478  return sane;
479 }
480 
481 enum cluster_type_e
483 {
484  int rc = CS_OK;
485  cmap_handle_t handle;
486 
487  rc = cmap_initialize(&handle);
488 
489  switch(rc) {
490  case CS_OK:
491  break;
492  case CS_ERR_SECURITY:
493  crm_debug("Failed to initialize the cmap API: Permission denied (%d)", rc);
494  /* It's there, we just can't talk to it.
495  * Good enough for us to identify as 'corosync'
496  */
497  return pcmk_cluster_corosync;
498 
499  default:
500  crm_info("Failed to initialize the cmap API: %s (%d)",
501  ais_error2text(rc), rc);
502  return pcmk_cluster_unknown;
503  }
504 
505  cmap_finalize(handle);
506  return pcmk_cluster_corosync;
507 }
508 
509 gboolean
511 {
512  if (node == NULL) {
513  crm_trace("NULL");
514  return FALSE;
515 
516  } else if (safe_str_neq(node->state, CRM_NODE_MEMBER)) {
517  crm_trace("%s: state=%s", node->uname, node->state);
518  return FALSE;
519 
520  } else if ((node->processes & crm_proc_cpg) == 0) {
521  crm_trace("%s: processes=%.16x", node->uname, node->processes);
522  return FALSE;
523  }
524  return TRUE;
525 }
526 
527 gboolean
528 corosync_initialize_nodelist(void *cluster, gboolean force_member, xmlNode * xml_parent)
529 {
530  int lpc = 0;
531  cs_error_t rc = CS_OK;
532  int retries = 0;
533  gboolean any = FALSE;
534  cmap_handle_t cmap_handle;
535  int fd = -1;
536  uid_t found_uid = 0;
537  gid_t found_gid = 0;
538  pid_t found_pid = 0;
539  int rv;
540 
541  do {
542  rc = cmap_initialize(&cmap_handle);
543  if (rc != CS_OK) {
544  retries++;
545  crm_debug("API connection setup failed: %s. Retrying in %ds", cs_strerror(rc),
546  retries);
547  sleep(retries);
548  }
549 
550  } while (retries < 5 && rc != CS_OK);
551 
552  if (rc != CS_OK) {
553  crm_warn("Could not connect to Cluster Configuration Database API, error %d", rc);
554  return FALSE;
555  }
556 
557  rc = cmap_fd_get(cmap_handle, &fd);
558  if (rc != CS_OK) {
559  crm_err("Could not obtain the CMAP API connection: %s (%d)",
560  cs_strerror(rc), rc);
561  goto bail;
562  }
563 
564  /* CMAP provider run as root (in given user namespace, anyway)? */
565  if (!(rv = crm_ipc_is_authentic_process(fd, (uid_t) 0,(gid_t) 0, &found_pid,
566  &found_uid, &found_gid))) {
567  crm_err("CMAP provider is not authentic:"
568  " process %lld (uid: %lld, gid: %lld)",
569  (long long) PCMK__SPECIAL_PID_AS_0(found_pid),
570  (long long) found_uid, (long long) found_gid);
571  goto bail;
572  } else if (rv < 0) {
573  crm_err("Could not verify authenticity of CMAP provider: %s (%d)",
574  strerror(-rv), -rv);
575  goto bail;
576  }
577 
578  crm_peer_init();
579  crm_trace("Initializing corosync nodelist");
580  for (lpc = 0; TRUE; lpc++) {
581  uint32_t nodeid = 0;
582  char *name = NULL;
583  char *key = NULL;
584 
585  key = crm_strdup_printf("nodelist.node.%d.nodeid", lpc);
586  rc = cmap_get_uint32(cmap_handle, key, &nodeid);
587  free(key);
588 
589  if (rc != CS_OK) {
590  break;
591  }
592 
593  name = corosync_node_name(cmap_handle, nodeid);
594  if (name != NULL) {
595  GHashTableIter iter;
596  crm_node_t *node = NULL;
597 
598  g_hash_table_iter_init(&iter, crm_peer_cache);
599  while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &node)) {
600  if(node && node->uname && strcasecmp(node->uname, name) == 0) {
601  if (node->id && node->id != nodeid) {
602  crm_crit("Nodes %u and %u share the same name '%s': shutting down", node->id,
603  nodeid, name);
605  }
606  }
607  }
608  }
609 
610  if (nodeid > 0 || name != NULL) {
611  crm_trace("Initializing node[%d] %u = %s", lpc, nodeid, name);
612  crm_get_peer(nodeid, name);
613  }
614 
615  if (nodeid > 0 && name != NULL) {
616  any = TRUE;
617 
618  if (xml_parent) {
619  xmlNode *node = create_xml_node(xml_parent, XML_CIB_TAG_NODE);
620 
621  crm_xml_set_id(node, "%u", nodeid);
622  crm_xml_add(node, XML_ATTR_UNAME, name);
623  if (force_member) {
625  }
626  }
627  }
628 
629  free(name);
630  }
631 bail:
632  cmap_finalize(cmap_handle);
633  return any;
634 }
635 
636 char *
638 {
639  cmap_handle_t handle;
640  char *cluster_name = NULL;
641  cs_error_t rc = CS_OK;
642  int fd = -1;
643  uid_t found_uid = 0;
644  gid_t found_gid = 0;
645  pid_t found_pid = 0;
646  int rv;
647 
648  rc = cmap_initialize(&handle);
649  if (rc != CS_OK) {
650  crm_info("Failed to initialize the cmap API: %s (%d)",
651  cs_strerror(rc), rc);
652  return NULL;
653  }
654 
655  rc = cmap_fd_get(handle, &fd);
656  if (rc != CS_OK) {
657  crm_err("Could not obtain the CMAP API connection: %s (%d)",
658  cs_strerror(rc), rc);
659  goto bail;
660  }
661 
662  /* CMAP provider run as root (in given user namespace, anyway)? */
663  if (!(rv = crm_ipc_is_authentic_process(fd, (uid_t) 0,(gid_t) 0, &found_pid,
664  &found_uid, &found_gid))) {
665  crm_err("CMAP provider is not authentic:"
666  " process %lld (uid: %lld, gid: %lld)",
667  (long long) PCMK__SPECIAL_PID_AS_0(found_pid),
668  (long long) found_uid, (long long) found_gid);
669  goto bail;
670  } else if (rv < 0) {
671  crm_err("Could not verify authenticity of CMAP provider: %s (%d)",
672  strerror(-rv), -rv);
673  goto bail;
674  }
675 
676  rc = cmap_get_string(handle, "totem.cluster_name", &cluster_name);
677  if (rc != CS_OK) {
678  crm_info("Cannot get totem.cluster_name: %s (%d)", cs_strerror(rc), rc);
679 
680  } else {
681  crm_debug("cmap totem.cluster_name = '%s'", cluster_name);
682  }
683 
684 bail:
685  cmap_finalize(handle);
686  return cluster_name;
687 }
688 
689 int
690 corosync_cmap_has_config(const char *prefix)
691 {
692  cs_error_t rc = CS_OK;
693  int retries = 0;
694  static int found = -1;
695  cmap_handle_t cmap_handle;
696  cmap_iter_handle_t iter_handle;
697  char key_name[CMAP_KEYNAME_MAXLEN + 1];
698  int fd = -1;
699  uid_t found_uid = 0;
700  gid_t found_gid = 0;
701  pid_t found_pid = 0;
702  int rv;
703 
704  if(found != -1) {
705  return found;
706  }
707 
708  do {
709  rc = cmap_initialize(&cmap_handle);
710  if (rc != CS_OK) {
711  retries++;
712  crm_debug("API connection setup failed: %s. Retrying in %ds", cs_strerror(rc),
713  retries);
714  sleep(retries);
715  }
716 
717  } while (retries < 5 && rc != CS_OK);
718 
719  if (rc != CS_OK) {
720  crm_warn("Could not connect to Cluster Configuration Database API: %s (rc=%d)",
721  cs_strerror(rc), rc);
722  return -1;
723  }
724 
725  rc = cmap_fd_get(cmap_handle, &fd);
726  if (rc != CS_OK) {
727  crm_err("Could not obtain the CMAP API connection: %s (%d)",
728  cs_strerror(rc), rc);
729  goto bail;
730  }
731 
732  /* CMAP provider run as root (in given user namespace, anyway)? */
733  if (!(rv = crm_ipc_is_authentic_process(fd, (uid_t) 0,(gid_t) 0, &found_pid,
734  &found_uid, &found_gid))) {
735  crm_err("CMAP provider is not authentic:"
736  " process %lld (uid: %lld, gid: %lld)",
737  (long long) PCMK__SPECIAL_PID_AS_0(found_pid),
738  (long long) found_uid, (long long) found_gid);
739  goto bail;
740  } else if (rv < 0) {
741  crm_err("Could not verify authenticity of CMAP provider: %s (%d)",
742  strerror(-rv), -rv);
743  goto bail;
744  }
745 
746  rc = cmap_iter_init(cmap_handle, prefix, &iter_handle);
747  if (rc != CS_OK) {
748  crm_warn("Failed to initialize iteration for corosync cmap '%s': %s (rc=%d)",
749  prefix, cs_strerror(rc), rc);
750  goto bail;
751  }
752 
753  found = 0;
754  while ((rc = cmap_iter_next(cmap_handle, iter_handle, key_name, NULL, NULL)) == CS_OK) {
755  crm_trace("'%s' is configured in corosync cmap: %s", prefix, key_name);
756  found++;
757  break;
758  }
759  cmap_iter_finalize(cmap_handle, iter_handle);
760 
761 bail:
762  cmap_finalize(cmap_handle);
763 
764  return found;
765 }
enum crm_ais_msg_types type
Definition: internal.h:38
gboolean check_message_sanity(const AIS_Message *msg, const char *data)
Definition: corosync.c:419
#define crm_notice(fmt, args...)
Definition: logging.h:276
gboolean is_compressed
Definition: internal.h:47
uint32_t size
Definition: internal.h:52
#define crm_crit(fmt, args...)
Definition: logging.h:273
gboolean safe_str_neq(const char *a, const char *b)
Definition: strings.c:182
mainloop_io_t * mainloop_add_fd(const char *name, int priority, int fd, void *userdata, struct mainloop_fd_callbacks *callbacks)
Definition: mainloop.c:886
uint32_t nodeid
Definition: cluster.h:97
quorum_callbacks_t quorum_callbacks
Definition: corosync.c:264
void crm_reap_unseen_nodes(uint64_t ring_id)
Definition: membership.c:1102
quorum_handle_t pcmk_quorum_handle
Definition: corosync.c:36
uint32_t quorate
Definition: internal.h:80
#define XML_ATTR_TYPE
Definition: msg_xml.h:105
void(* destroy)(gpointer userdata)
Definition: mainloop.h:105
gboolean crm_have_quorum
Definition: membership.c:67
char * get_corosync_uuid(crm_node_t *peer)
Definition: cluster.c:106
void terminate_cs_connection(crm_cluster_t *cluster)
Definition: corosync.c:160
void crm_peer_init(void)
Definition: membership.c:421
gboolean cluster_connect_quorum(gboolean(*dispatch)(unsigned long long, gboolean), void(*destroy)(gpointer))
Definition: corosync.c:269
#define PCMK__SPECIAL_PID_AS_0(p)
Definition: ipc_internal.h:34
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
Definition: nvpair.c:216
crm_node_t * crm_get_peer(unsigned int id, const char *uname)
Definition: membership.c:689
crm_node_t * crm_update_peer_state(const char *source, crm_node_t *node, const char *state, uint64_t membership)
Update a node&#39;s state and membership information.
Definition: membership.c:1090
char * uuid
Definition: cluster.h:95
char * get_node_name(uint32_t nodeid)
Definition: cluster.c:301
char * strerror(int errnum)
Wrappers for and extensions to glib mainloop.
gboolean init_cs_connection(crm_cluster_t *cluster)
Definition: corosync.c:354
gboolean crm_is_corosync_peer_active(const crm_node_t *node)
Definition: corosync.c:510
void cluster_disconnect_cpg(crm_cluster_t *cluster)
Definition: cpg.c:51
int(* dispatch)(gpointer userdata)
Definition: mainloop.h:104
#define crm_warn(fmt, args...)
Definition: logging.h:275
uint32_t processes
Definition: cluster.h:79
char * corosync_cluster_name(void)
Definition: corosync.c:637
#define crm_debug(fmt, args...)
Definition: logging.h:279
cluster_type_e
Definition: cluster.h:210
gboolean(* quorum_app_callback)(unsigned long long seq, gboolean quorate)
Definition: corosync.c:38
#define crm_trace(fmt, args...)
Definition: logging.h:280
AIS_Host sender
Definition: internal.h:50
uint32_t id
Definition: internal.h:46
#define XML_ATTR_UNAME
Definition: msg_xml.h:130
xmlNode * create_xml_node(xmlNode *parent, const char *name)
Definition: xml.c:1977
struct crm_ais_msg_s AIS_Message
Definition: internal.h:32
char * corosync_node_name(uint64_t cmap_handle, uint32_t nodeid)
Definition: corosync.c:45
#define ais_data_len(msg)
Definition: internal.h:208
int corosync_cmap_has_config(const char *prefix)
Definition: corosync.c:690
#define CRM_NODE_MEMBER
Definition: cluster.h:44
enum cluster_type_e find_corosync_variant(void)
Definition: corosync.c:482
gboolean ais_membership_force
Definition: corosync.c:179
int ais_membership_timer
Definition: corosync.c:178
#define XML_CIB_TAG_NODE
Definition: msg_xml.h:179
const char * name_for_cluster_type(enum cluster_type_e type)
Definition: cluster.c:468
#define DAEMON_RESPAWN_STOP
Definition: crm.h:55
gboolean init_cs_connection_once(crm_cluster_t *cluster)
Definition: corosync.c:381
#define CRM_XS
Definition: logging.h:42
char * uname
Definition: cluster.h:96
uint32_t get_local_nodeid(cpg_handle_t handle)
Definition: cpg.c:65
gboolean node_name_is_valid(const char *key, const char *name)
Definition: cluster.c:651
#define crm_err(fmt, args...)
Definition: logging.h:274
void crm_xml_set_id(xmlNode *xml, const char *format,...) __attribute__((__format__(__printf__
#define uint32_t
Definition: stdint.in.h:158
char data[0]
Definition: internal.h:86
int crm_exit(int rc)
Definition: utils.c:74
char * state
Definition: cluster.h:84
#define U64T
Definition: config.h:765
Wrappers for and extensions to libqb IPC.
uint32_t pid
Definition: internal.h:36
char * uname
Definition: cluster.h:82
AIS_Host host
Definition: internal.h:49
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
GHashTable * crm_peer_cache
Definition: membership.c:44
#define crm_info(fmt, args...)
Definition: logging.h:277
gboolean corosync_initialize_nodelist(void *cluster, gboolean force_member, xmlNode *xml_parent)
Definition: corosync.c:528
gboolean cluster_connect_cpg(crm_cluster_t *cluster)
Definition: cpg.c:559
enum cluster_type_e get_cluster_type(void)
Definition: cluster.c:513
int crm_ipc_is_authentic_process(int sock, uid_t refuid, gid_t refgid, pid_t *gotpid, uid_t *gotuid, gid_t *gotgid)
Check the authenticity of the IPC socket peer process.
Definition: ipc.c:1422