pacemaker  1.1.14-70404b0
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_notice("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 
177 gboolean ais_membership_force = FALSE;
178 
179 
180 static int
181 pcmk_quorum_dispatch(gpointer user_data)
182 {
183  int rc = 0;
184 
185  rc = quorum_dispatch(pcmk_quorum_handle, CS_DISPATCH_ALL);
186  if (rc < 0) {
187  crm_err("Connection to the Quorum API failed: %d", rc);
188  pcmk_quorum_handle = 0;
189  return -1;
190  }
191  return 0;
192 }
193 
194 static void
195 pcmk_quorum_notification(quorum_handle_t handle,
197  uint64_t ring_id, uint32_t view_list_entries, uint32_t * view_list)
198 {
199  int i;
200  GHashTableIter iter;
201  crm_node_t *node = NULL;
202  static gboolean init_phase = TRUE;
203 
204  if (quorate != crm_have_quorum) {
205  crm_notice("Membership " U64T ": quorum %s (%lu)", ring_id,
206  quorate ? "acquired" : "lost", (long unsigned int)view_list_entries);
208 
209  } else {
210  crm_info("Membership " U64T ": quorum %s (%lu)", ring_id,
211  quorate ? "retained" : "still lost", (long unsigned int)view_list_entries);
212  }
213 
214  if (view_list_entries == 0 && init_phase) {
215  crm_info("Corosync membership is still forming, ignoring");
216  return;
217  }
218 
219  init_phase = FALSE;
220 
221  /* Reset last_seen for all cached nodes so we can tell which ones aren't
222  * in the view list */
223  g_hash_table_iter_init(&iter, crm_peer_cache);
224  while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &node)) {
225  node->last_seen = 0;
226  }
227 
228  /* Update the peer cache for each node in view list */
229  for (i = 0; i < view_list_entries; i++) {
230  uint32_t id = view_list[i];
231 
232  crm_debug("Member[%d] %u ", i, id);
233 
234  /* Get this node's peer cache entry (adding one if not already there) */
235  node = crm_get_peer(id, NULL);
236  if (node->uname == NULL) {
237  char *name = corosync_node_name(0, id);
238 
239  crm_info("Obtaining name for new node %u", id);
240  node = crm_get_peer(id, name);
241  free(name);
242  }
243 
244  /* Update the node state (including updating last_seen to ring_id) */
245  crm_update_peer_state(__FUNCTION__, node, CRM_NODE_MEMBER, ring_id);
246  }
247 
248  /* Remove any peer cache entries we didn't update */
249  crm_reap_unseen_nodes(ring_id);
250 
251  if (quorum_app_callback) {
252  quorum_app_callback(ring_id, quorate);
253  }
254 }
255 
256 quorum_callbacks_t quorum_callbacks = {
257  .quorum_notify_fn = pcmk_quorum_notification,
258 };
259 
260 gboolean
261 cluster_connect_quorum(gboolean(*dispatch) (unsigned long long, gboolean),
262  void (*destroy) (gpointer))
263 {
264  cs_error_t rc;
265  int fd = 0;
266  int quorate = 0;
267  uint32_t quorum_type = 0;
268  struct mainloop_fd_callbacks quorum_fd_callbacks;
269  uid_t found_uid = 0;
270  gid_t found_gid = 0;
271  pid_t found_pid = 0;
272  int rv;
273 
274  quorum_fd_callbacks.dispatch = pcmk_quorum_dispatch;
275  quorum_fd_callbacks.destroy = destroy;
276 
277  crm_debug("Configuring Pacemaker to obtain quorum from Corosync");
278 
279  rc = quorum_initialize(&pcmk_quorum_handle, &quorum_callbacks, &quorum_type);
280  if (rc != CS_OK) {
281  crm_err("Could not connect to the Quorum API: %s (%d)",
282  cs_strerror(rc), rc);
283  goto bail;
284 
285  } else if (quorum_type != QUORUM_SET) {
286  crm_err("Corosync quorum is not configured\n");
287  goto bail;
288  }
289 
290  rc = quorum_fd_get(pcmk_quorum_handle, &fd);
291  if (rc != CS_OK) {
292  crm_err("Could not obtain the Quorum API connection: %s (%d)\n",
293  strerror(rc), rc);
294  goto bail;
295  }
296 
297  /* Quorum provider run as root (in given user namespace, anyway)? */
298  if (!(rv = crm_ipc_is_authentic_process(fd, (uid_t) 0,(gid_t) 0, &found_pid,
299  &found_uid, &found_gid))) {
300  crm_err("Quorum provider is not authentic:"
301  " process %lld (uid: %lld, gid: %lld)",
302  (long long) PCMK__SPECIAL_PID_AS_0(found_pid),
303  (long long) found_uid, (long long) found_gid);
304  rc = CS_ERR_ACCESS;
305  goto bail;
306  } else if (rv < 0) {
307  crm_err("Could not verify authenticity of Quorum provider: %s (%d)",
308  strerror(-rv), -rv);
309  rc = CS_ERR_ACCESS;
310  goto bail;
311  }
312 
313  rc = quorum_getquorate(pcmk_quorum_handle, &quorate);
314  if (rc != CS_OK) {
315  crm_err("Could not obtain the current Quorum API state: %d\n", rc);
316  goto bail;
317  }
318 
319  crm_notice("Quorum %s", quorate ? "acquired" : "lost");
322 
323  rc = quorum_trackstart(pcmk_quorum_handle, CS_TRACK_CHANGES | CS_TRACK_CURRENT);
324  if (rc != CS_OK) {
325  crm_err("Could not setup Quorum API notifications: %d\n", rc);
326  goto bail;
327  }
328 
329  mainloop_add_fd("quorum", G_PRIORITY_HIGH, fd, dispatch, &quorum_fd_callbacks);
330 
331  corosync_initialize_nodelist(NULL, FALSE, NULL);
332 
333  bail:
334  if (rc != CS_OK) {
335  quorum_finalize(pcmk_quorum_handle);
336  return FALSE;
337  }
338  return TRUE;
339 }
340 
341 gboolean
343 {
344  int retries = 0;
345 
346  while (retries < 5) {
347  int rc = init_cs_connection_once(cluster);
348 
349  retries++;
350 
351  switch (rc) {
352  case CS_OK:
353  return TRUE;
354  break;
355  case CS_ERR_TRY_AGAIN:
356  case CS_ERR_QUEUE_FULL:
357  sleep(retries);
358  break;
359  default:
360  return FALSE;
361  }
362  }
363 
364  crm_err("Could not connect to corosync after %d retries", retries);
365  return FALSE;
366 }
367 
368 gboolean
370 {
371  crm_node_t *peer = NULL;
372  enum cluster_type_e stack = get_cluster_type();
373 
374  crm_peer_init();
375 
376  /* Here we just initialize comms */
377  if (stack != pcmk_cluster_corosync) {
378  crm_err("Invalid cluster type: %s (%d)", name_for_cluster_type(stack), stack);
379  return FALSE;
380  }
381 
382  if (cluster_connect_cpg(cluster) == FALSE) {
383  return FALSE;
384  }
385  crm_info("Connection to '%s': established", name_for_cluster_type(stack));
386 
387  cluster->nodeid = get_local_nodeid(0);
388  if(cluster->nodeid == 0) {
389  crm_err("Could not establish local nodeid");
390  return FALSE;
391  }
392 
393  cluster->uname = get_node_name(0);
394  if(cluster->uname == NULL) {
395  crm_err("Could not establish local node name");
396  return FALSE;
397  }
398 
399  /* Ensure the local node always exists */
400  peer = crm_get_peer(cluster->nodeid, cluster->uname);
401  cluster->uuid = get_corosync_uuid(peer);
402 
403  return TRUE;
404 }
405 
406 gboolean
407 check_message_sanity(const AIS_Message * msg, const char *data)
408 {
409  gboolean sane = TRUE;
410  int dest = msg->host.type;
411  int tmp_size = msg->header.size - sizeof(AIS_Message);
412 
413  if (sane && msg->header.size == 0) {
414  crm_warn("Message with no size");
415  sane = FALSE;
416  }
417 
418  if (sane && msg->header.error != CS_OK) {
419  crm_warn("Message header contains an error: %d", msg->header.error);
420  sane = FALSE;
421  }
422 
423  if (sane && ais_data_len(msg) != tmp_size) {
424  crm_warn("Message payload size is incorrect: expected %d, got %d", ais_data_len(msg),
425  tmp_size);
426  sane = TRUE;
427  }
428 
429  if (sane && ais_data_len(msg) == 0) {
430  crm_warn("Message with no payload");
431  sane = FALSE;
432  }
433 
434  if (sane && data && msg->is_compressed == FALSE) {
435  int str_size = strlen(data) + 1;
436 
437  if (ais_data_len(msg) != str_size) {
438  int lpc = 0;
439 
440  crm_warn("Message payload is corrupted: expected %d bytes, got %d",
441  ais_data_len(msg), str_size);
442  sane = FALSE;
443  for (lpc = (str_size - 10); lpc < msg->size; lpc++) {
444  if (lpc < 0) {
445  lpc = 0;
446  }
447  crm_debug("bad_data[%d]: %d / '%c'", lpc, data[lpc], data[lpc]);
448  }
449  }
450  }
451 
452  if (sane == FALSE) {
453  crm_err("Invalid message %d: (dest=%s:%s, from=%s:%s.%u, compressed=%d, size=%d, total=%d)",
454  msg->id, ais_dest(&(msg->host)), msg_type2text(dest),
455  ais_dest(&(msg->sender)), msg_type2text(msg->sender.type),
456  msg->sender.pid, msg->is_compressed, ais_data_len(msg), msg->header.size);
457 
458  } else {
459  crm_trace
460  ("Verified message %d: (dest=%s:%s, from=%s:%s.%u, compressed=%d, size=%d, total=%d)",
461  msg->id, ais_dest(&(msg->host)), msg_type2text(dest), ais_dest(&(msg->sender)),
462  msg_type2text(msg->sender.type), msg->sender.pid, msg->is_compressed,
463  ais_data_len(msg), msg->header.size);
464  }
465 
466  return sane;
467 }
468 
469 enum cluster_type_e
471 {
472  int rc = CS_OK;
473  cmap_handle_t handle;
474 
475  rc = cmap_initialize(&handle);
476 
477  switch(rc) {
478  case CS_OK:
479  break;
480  case CS_ERR_SECURITY:
481  crm_debug("Failed to initialize the cmap API: Permission denied (%d)", rc);
482  /* It's there, we just can't talk to it.
483  * Good enough for us to identify as 'corosync'
484  */
485  return pcmk_cluster_corosync;
486 
487  default:
488  crm_info("Failed to initialize the cmap API: %s (%d)",
489  ais_error2text(rc), rc);
490  return pcmk_cluster_unknown;
491  }
492 
493  cmap_finalize(handle);
494  return pcmk_cluster_corosync;
495 }
496 
497 gboolean
499 {
500  if (node == NULL) {
501  crm_trace("NULL");
502  return FALSE;
503 
504  } else if (safe_str_neq(node->state, CRM_NODE_MEMBER)) {
505  crm_trace("%s: state=%s", node->uname, node->state);
506  return FALSE;
507 
508  } else if ((node->processes & crm_proc_cpg) == 0) {
509  crm_trace("%s: processes=%.16x", node->uname, node->processes);
510  return FALSE;
511  }
512  return TRUE;
513 }
514 
515 gboolean
516 corosync_initialize_nodelist(void *cluster, gboolean force_member, xmlNode * xml_parent)
517 {
518  int lpc = 0;
519  cs_error_t rc = CS_OK;
520  int retries = 0;
521  gboolean any = FALSE;
522  cmap_handle_t cmap_handle;
523  int fd = -1;
524  uid_t found_uid = 0;
525  gid_t found_gid = 0;
526  pid_t found_pid = 0;
527  int rv;
528 
529  do {
530  rc = cmap_initialize(&cmap_handle);
531  if (rc != CS_OK) {
532  retries++;
533  crm_debug("API connection setup failed: %s. Retrying in %ds", cs_strerror(rc),
534  retries);
535  sleep(retries);
536  }
537 
538  } while (retries < 5 && rc != CS_OK);
539 
540  if (rc != CS_OK) {
541  crm_warn("Could not connect to Cluster Configuration Database API, error %d", rc);
542  return FALSE;
543  }
544 
545  rc = cmap_fd_get(cmap_handle, &fd);
546  if (rc != CS_OK) {
547  crm_err("Could not obtain the CMAP API connection: %s (%d)",
548  cs_strerror(rc), rc);
549  goto bail;
550  }
551 
552  /* CMAP provider run as root (in given user namespace, anyway)? */
553  if (!(rv = crm_ipc_is_authentic_process(fd, (uid_t) 0,(gid_t) 0, &found_pid,
554  &found_uid, &found_gid))) {
555  crm_err("CMAP provider is not authentic:"
556  " process %lld (uid: %lld, gid: %lld)",
557  (long long) PCMK__SPECIAL_PID_AS_0(found_pid),
558  (long long) found_uid, (long long) found_gid);
559  goto bail;
560  } else if (rv < 0) {
561  crm_err("Could not verify authenticity of CMAP provider: %s (%d)",
562  strerror(-rv), -rv);
563  goto bail;
564  }
565 
566  crm_peer_init();
567  crm_trace("Initializing corosync nodelist");
568  for (lpc = 0;; lpc++) {
569  uint32_t nodeid = 0;
570  char *name = NULL;
571  char *key = NULL;
572 
573  key = crm_strdup_printf("nodelist.node.%d.nodeid", lpc);
574  rc = cmap_get_uint32(cmap_handle, key, &nodeid);
575  free(key);
576 
577  if (rc != CS_OK) {
578  break;
579  }
580 
581  name = corosync_node_name(cmap_handle, nodeid);
582  if (name != NULL) {
583  GHashTableIter iter;
584  crm_node_t *node = NULL;
585 
586  g_hash_table_iter_init(&iter, crm_peer_cache);
587  while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &node)) {
588  if(node && node->uname && strcasecmp(node->uname, name) == 0) {
589  if (node->id && node->id != nodeid) {
590  crm_crit("Nodes %u and %u share the same name '%s': shutting down", node->id,
591  nodeid, name);
593  }
594  }
595  }
596  }
597 
598  if (nodeid > 0 || name != NULL) {
599  crm_trace("Initializing node[%d] %u = %s", lpc, nodeid, name);
600  crm_get_peer(nodeid, name);
601  }
602 
603  if (nodeid > 0 && name != NULL) {
604  any = TRUE;
605 
606  if (xml_parent) {
607  char buffer[64];
608  xmlNode *node = create_xml_node(xml_parent, XML_CIB_TAG_NODE);
609 
610  if(snprintf(buffer, 63, "%u", nodeid) > 0) {
611  crm_xml_add(node, XML_ATTR_ID, buffer);
612  }
613  crm_xml_add(node, XML_ATTR_UNAME, name);
614  if (force_member) {
616  }
617  }
618  }
619 
620  free(name);
621  }
622 bail:
623  cmap_finalize(cmap_handle);
624  return any;
625 }
626 
627 char *
629 {
630  cmap_handle_t handle;
631  char *cluster_name = NULL;
632  cs_error_t rc = CS_OK;
633  int fd = -1;
634  uid_t found_uid = 0;
635  gid_t found_gid = 0;
636  pid_t found_pid = 0;
637  int rv;
638 
639  rc = cmap_initialize(&handle);
640  if (rc != CS_OK) {
641  crm_info("Failed to initialize the cmap API: %s (%d)",
642  cs_strerror(rc), rc);
643  return NULL;
644  }
645 
646  rc = cmap_fd_get(handle, &fd);
647  if (rc != CS_OK) {
648  crm_err("Could not obtain the CMAP API connection: %s (%d)",
649  cs_strerror(rc), rc);
650  goto bail;
651  }
652 
653  /* CMAP provider run as root (in given user namespace, anyway)? */
654  if (!(rv = crm_ipc_is_authentic_process(fd, (uid_t) 0,(gid_t) 0, &found_pid,
655  &found_uid, &found_gid))) {
656  crm_err("CMAP provider is not authentic:"
657  " process %lld (uid: %lld, gid: %lld)",
658  (long long) PCMK__SPECIAL_PID_AS_0(found_pid),
659  (long long) found_uid, (long long) found_gid);
660  goto bail;
661  } else if (rv < 0) {
662  crm_err("Could not verify authenticity of CMAP provider: %s (%d)",
663  strerror(-rv), -rv);
664  goto bail;
665  }
666 
667  rc = cmap_get_string(handle, "totem.cluster_name", &cluster_name);
668  if (rc != CS_OK) {
669  crm_info("Cannot get totem.cluster_name: %s (%d)", cs_strerror(rc), rc);
670 
671  } else {
672  crm_debug("cmap totem.cluster_name = '%s'", cluster_name);
673  }
674 
675 bail:
676  cmap_finalize(handle);
677  return cluster_name;
678 }
679 
680 int
681 corosync_cmap_has_config(const char *prefix)
682 {
683  cs_error_t rc = CS_OK;
684  int retries = 0;
685  static int found = -1;
686  cmap_handle_t cmap_handle;
687  cmap_iter_handle_t iter_handle;
688  char key_name[CMAP_KEYNAME_MAXLEN + 1];
689  int fd = -1;
690  uid_t found_uid = 0;
691  gid_t found_gid = 0;
692  pid_t found_pid = 0;
693  int rv;
694 
695  if(found != -1) {
696  return found;
697  }
698 
699  do {
700  rc = cmap_initialize(&cmap_handle);
701  if (rc != CS_OK) {
702  retries++;
703  crm_debug("API connection setup failed: %s. Retrying in %ds", cs_strerror(rc),
704  retries);
705  sleep(retries);
706  }
707 
708  } while (retries < 5 && rc != CS_OK);
709 
710  if (rc != CS_OK) {
711  crm_warn("Could not connect to Cluster Configuration Database API: %s (rc=%d)",
712  cs_strerror(rc), rc);
713  return -1;
714  }
715 
716  rc = cmap_fd_get(cmap_handle, &fd);
717  if (rc != CS_OK) {
718  crm_err("Could not obtain the CMAP API connection: %s (%d)",
719  cs_strerror(rc), rc);
720  goto bail;
721  }
722 
723  /* CMAP provider run as root (in given user namespace, anyway)? */
724  if (!(rv = crm_ipc_is_authentic_process(fd, (uid_t) 0,(gid_t) 0, &found_pid,
725  &found_uid, &found_gid))) {
726  crm_err("CMAP provider is not authentic:"
727  " process %lld (uid: %lld, gid: %lld)",
728  (long long) PCMK__SPECIAL_PID_AS_0(found_pid),
729  (long long) found_uid, (long long) found_gid);
730  goto bail;
731  } else if (rv < 0) {
732  crm_err("Could not verify authenticity of CMAP provider: %s (%d)",
733  strerror(-rv), -rv);
734  goto bail;
735  }
736 
737  rc = cmap_iter_init(cmap_handle, prefix, &iter_handle);
738  if (rc != CS_OK) {
739  crm_warn("Failed to initialize iteration for corosync cmap '%s': %s (rc=%d)",
740  prefix, cs_strerror(rc), rc);
741  goto bail;
742  }
743 
744  found = 0;
745  while ((rc = cmap_iter_next(cmap_handle, iter_handle, key_name, NULL, NULL)) == CS_OK) {
746  crm_trace("'%s' is configured in corosync cmap: %s", prefix, key_name);
747  found++;
748  break;
749  }
750  cmap_iter_finalize(cmap_handle, iter_handle);
751 
752 bail:
753  cmap_finalize(cmap_handle);
754 
755  return found;
756 }
enum crm_ais_msg_types type
Definition: internal.h:39
gboolean check_message_sanity(const AIS_Message *msg, const char *data)
Definition: corosync.c:407
#define crm_notice(fmt, args...)
Definition: logging.h:250
gboolean is_compressed
Definition: internal.h:48
uint32_t size
Definition: internal.h:53
#define crm_crit(fmt, args...)
Definition: logging.h:247
gboolean safe_str_neq(const char *a, const char *b)
Definition: utils.c:659
mainloop_io_t * mainloop_add_fd(const char *name, int priority, int fd, void *userdata, struct mainloop_fd_callbacks *callbacks)
Definition: mainloop.c:806
uint32_t nodeid
Definition: cluster.h:94
quorum_callbacks_t quorum_callbacks
Definition: corosync.c:256
void crm_reap_unseen_nodes(uint64_t ring_id)
Definition: membership.c:918
char * corosync_node_name(uint64_tcmap_handle, uint32_t nodeid)
Definition: corosync.c:45
quorum_handle_t pcmk_quorum_handle
Definition: corosync.c:36
uint32_t quorate
Definition: internal.h:52
uint32_t id
Definition: cluster.h:70
#define XML_ATTR_TYPE
Definition: msg_xml.h:103
void(* destroy)(gpointer userdata)
Definition: mainloop.h:91
gboolean crm_have_quorum
Definition: membership.c:38
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:262
gboolean cluster_connect_quorum(gboolean(*dispatch)(unsigned long long, gboolean), void(*destroy)(gpointer))
Definition: corosync.c:261
#define PCMK__SPECIAL_PID_AS_0(p)
Definition: ipc_internal.h:34
crm_node_t * crm_get_peer(unsigned int id, const char *uname)
Definition: membership.c:519
char * uuid
Definition: cluster.h:92
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:342
gboolean crm_is_corosync_peer_active(const crm_node_t *node)
Definition: corosync.c:498
void cluster_disconnect_cpg(crm_cluster_t *cluster)
Definition: cpg.c:51
int(* dispatch)(gpointer userdata)
Definition: mainloop.h:90
#define crm_warn(fmt, args...)
Definition: logging.h:249
uint32_t processes
Definition: cluster.h:76
char * corosync_cluster_name(void)
Definition: corosync.c:628
#define crm_debug(fmt, args...)
Definition: logging.h:253
#define XML_ATTR_ID
Definition: msg_xml.h:100
cluster_type_e
Definition: cluster.h:206
gboolean(* quorum_app_callback)(unsigned long long seq, gboolean quorate)
Definition: corosync.c:38
#define crm_trace(fmt, args...)
Definition: logging.h:254
AIS_Host sender
Definition: internal.h:51
uint32_t id
Definition: internal.h:47
#define XML_ATTR_UNAME
Definition: msg_xml.h:128
xmlNode * create_xml_node(xmlNode *parent, const char *name)
Definition: xml.c:2793
struct crm_ais_msg_s AIS_Message
Definition: internal.h:33
#define ais_data_len(msg)
Definition: internal.h:210
int corosync_cmap_has_config(const char *prefix)
Definition: corosync.c:681
#define CRM_NODE_MEMBER
Definition: cluster.h:44
enum cluster_type_e find_corosync_variant(void)
Definition: corosync.c:470
gboolean ais_membership_force
Definition: corosync.c:177
int ais_membership_timer
Definition: corosync.c:176
#define XML_CIB_TAG_NODE
Definition: msg_xml.h:167
const char * name_for_cluster_type(enum cluster_type_e type)
Definition: cluster.c:457
#define DAEMON_RESPAWN_STOP
Definition: crm.h:67
gboolean init_cs_connection_once(crm_cluster_t *cluster)
Definition: corosync.c:369
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Definition: xml.c:2695
crm_node_t * crm_update_peer_state(const char *source, crm_node_t *node, const char *state, int membership)
Update a node&#39;s state and membership information.
Definition: membership.c:906
char * uname
Definition: cluster.h:93
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:640
#define crm_err(fmt, args...)
Definition: logging.h:248
#define uint32_t
Definition: stdint.in.h:158
char data[0]
Definition: internal.h:58
int crm_exit(int rc)
Definition: utils.c:78
char * state
Definition: cluster.h:81
#define U64T
Definition: config.h:628
Wrappers for and extensions to libqb IPC.
uint32_t pid
Definition: internal.h:37
char * uname
Definition: cluster.h:79
uint64_t last_seen
Definition: cluster.h:72
AIS_Host host
Definition: internal.h:50
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
GHashTable * crm_peer_cache
Definition: membership.c:35
#define crm_info(fmt, args...)
Definition: logging.h:251
gboolean corosync_initialize_nodelist(void *cluster, gboolean force_member, xmlNode *xml_parent)
Definition: corosync.c:516
gboolean cluster_connect_cpg(crm_cluster_t *cluster)
Definition: cpg.c:537
enum cluster_type_e get_cluster_type(void)
Definition: cluster.c:502
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:1295