This commit is contained in:
committed by
Git OBS Bridge
parent
9e89303148
commit
de22f16263
+31
-2
@@ -1,9 +1,38 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Feb 6 19:14:34 CET 2009 - abeekhof@suse.de
|
||||
|
||||
- Switch to stand-alone libdlm code-base
|
||||
- Update to upstream: af52b7bb26a05a8f73d1076254e178b02ed192cd
|
||||
- Update to patch-level: a85c21afc4c99dc2aee8f7e7e356f25133c4d4ad
|
||||
- Implement fencing hooks for Pacemaker based clusters
|
||||
- Leverage more funcaitonality from Pacemaker libraries
|
||||
- Add pkgconfig entries
|
||||
- dlm_controld/gfs_controld: read lockless resources from ckpts
|
||||
- dlm_controld/gfs_controld: dump unused resources
|
||||
- dlm_controld/gfs_controld: fix plock rate limiting
|
||||
- dlm_controld/gfs_controld: plock config paths
|
||||
- dlm_controld/gfs_controld: plock dump display resource owner
|
||||
- dlm_controld: recv error checking
|
||||
- dlm_controld: clear plock syncing flags
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Nov 11 11:22:14 CET 2008 - abeekhof@suse.de
|
||||
|
||||
- Update to upstream bd261c8e51f3b5406f22bbb00b76f6da8722412d
|
||||
- fix plock dump
|
||||
- fix fencing checks which weren't happening
|
||||
- fix confchg/message processing, must be done after each individual confchg/message
|
||||
- init logging after fork to avoid ugly interaction with logging threads
|
||||
- fix usage of the query thread mutex
|
||||
- fix usage of realloc in deadlock code
|
||||
- join should return error without fence domain
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Oct 9 10:23:42 CEST 2008 - abeekhof@suse.de
|
||||
|
||||
- Update to upstream b6d73f5752306d635f306036438af1fcf26f4332
|
||||
- Adds protocol negotiation which important for future compatability
|
||||
- Miscelaneous bug fixes
|
||||
- Adds protocol negotiation which important for future compatability
|
||||
- Miscelaneous bug fixes
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Sep 15 16:22:42 CEST 2008 - abeekhof@suse.de
|
||||
|
||||
+34
-10
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package libdlm (Version 2.99.08)
|
||||
#
|
||||
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@@ -32,12 +32,11 @@
|
||||
Name: libdlm
|
||||
Summary: Application interface to the kernel's distributed lock manager
|
||||
Version: 2.99.08
|
||||
Release: 4
|
||||
Release: 5
|
||||
License: GPL v2 only; GPL v2 or later; LGPL v2.1 or later
|
||||
Url: http://sources.redhat.com/cluster/wiki
|
||||
Group: Productivity/Clustering/HA
|
||||
Source: libdlm.tar.gz
|
||||
Source1: pacemaker.c
|
||||
Patch1: pacemaker.diff
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
AutoReqProv: on
|
||||
@@ -176,7 +175,6 @@ Authors:
|
||||
###########################################################
|
||||
%setup -n libdlm
|
||||
%patch1 -p1
|
||||
cp $RPM_SOURCE_DIR/pacemaker.c ./group/dlm_controld
|
||||
###########################################################
|
||||
|
||||
%build
|
||||
@@ -203,9 +201,9 @@ CFLAGS="$CFLAGS -fgnu89-inline"
|
||||
export CFLAGS
|
||||
./configure --prefix=%{_prefix} \
|
||||
--mandir=%{_mandir} --libdir=%{_libdir} \
|
||||
--libexecdir=%{_libexecdir} \
|
||||
--without_cman --without_fence --without_gfs --without_gfs2 --without_gnbd --without_rgmanager --without_bindings --without_kernel_modules --disable_kernel_check \
|
||||
--enable_pacemaker --without_config
|
||||
--without_bindings \
|
||||
--disable_kernel_check \
|
||||
--corosynclibdir=%{_libdir}/openais --enable_pacemaker
|
||||
export MAKE="make %{?jobs:-j%jobs}"
|
||||
make %{?jobs:-j%jobs}
|
||||
###########################################################
|
||||
@@ -248,9 +246,9 @@ fi
|
||||
%{_sbindir}/dlm_controld.pcmk
|
||||
%{_sbindir}/dlm_tool
|
||||
%{_datadir}/man/man8/dlm_tool.8.gz
|
||||
%{_datadir}/man/man8/dlm_controld.8.gz
|
||||
%{_datadir}/doc/packages/libdlm-%{version}
|
||||
%exclude %{_datadir}/doc/cluster
|
||||
%exclude %{_sysconfdir}/logrotate.d/cluster
|
||||
|
||||
%files -n libdlm2
|
||||
%defattr(-,root,root)
|
||||
@@ -262,16 +260,42 @@ fi
|
||||
###########################################################
|
||||
%defattr(-,root,root)
|
||||
%{_libdir}/libdlm*.so
|
||||
%{_libdir}/pkgconfig/libdlm.pc
|
||||
%{_libdir}/pkgconfig/libdlm_lt.pc
|
||||
%{_libdir}/pkgconfig/libdlmcontrol.pc
|
||||
%{_includedir}/libdlm.h
|
||||
%{_includedir}/libdlmcontrol.h
|
||||
%{_datadir}/man/man3/dlm_*.3.gz
|
||||
%{_datadir}/man/man3/libdlm.3.gz
|
||||
|
||||
%changelog
|
||||
* Fri Feb 06 2009 abeekhof@suse.de
|
||||
- Switch to stand-alone libdlm code-base
|
||||
- Update to upstream: af52b7bb26a05a8f73d1076254e178b02ed192cd
|
||||
- Update to patch-level: a85c21afc4c99dc2aee8f7e7e356f25133c4d4ad
|
||||
- Implement fencing hooks for Pacemaker based clusters
|
||||
- Leverage more funcaitonality from Pacemaker libraries
|
||||
- Add pkgconfig entries
|
||||
- dlm_controld/gfs_controld: read lockless resources from ckpts
|
||||
- dlm_controld/gfs_controld: dump unused resources
|
||||
- dlm_controld/gfs_controld: fix plock rate limiting
|
||||
- dlm_controld/gfs_controld: plock config paths
|
||||
- dlm_controld/gfs_controld: plock dump display resource owner
|
||||
- dlm_controld: recv error checking
|
||||
- dlm_controld: clear plock syncing flags
|
||||
* Tue Nov 11 2008 abeekhof@suse.de
|
||||
- Update to upstream bd261c8e51f3b5406f22bbb00b76f6da8722412d
|
||||
- fix plock dump
|
||||
- fix fencing checks which weren't happening
|
||||
- fix confchg/message processing, must be done after each individual confchg/message
|
||||
- init logging after fork to avoid ugly interaction with logging threads
|
||||
- fix usage of the query thread mutex
|
||||
- fix usage of realloc in deadlock code
|
||||
- join should return error without fence domain
|
||||
* Thu Oct 09 2008 abeekhof@suse.de
|
||||
- Update to upstream b6d73f5752306d635f306036438af1fcf26f4332
|
||||
- Adds protocol negotiation which important for future compatability
|
||||
- Miscelaneous bug fixes
|
||||
- Adds protocol negotiation which important for future compatability
|
||||
- Miscelaneous bug fixes
|
||||
* Mon Sep 15 2008 abeekhof@suse.de
|
||||
- Reference newly created shared library packages as build dependancies
|
||||
* Mon Sep 08 2008 abeekhof@suse.de
|
||||
|
||||
LFS
BIN
Binary file not shown.
-398
@@ -1,398 +0,0 @@
|
||||
#include <syslog.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "dlm_daemon.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <bzlib.h>
|
||||
#include <heartbeat/ha_msg.h>
|
||||
|
||||
#include <pacemaker/crm_config.h>
|
||||
|
||||
#include <pacemaker/crm/crm.h>
|
||||
#include <pacemaker/crm/ais.h>
|
||||
/* heartbeat support is irrelevant here */
|
||||
#undef SUPPORT_HEARTBEAT
|
||||
#define SUPPORT_HEARTBEAT 0
|
||||
#include <pacemaker/crm/common/cluster.h>
|
||||
|
||||
#define COMMS_DIR "/sys/kernel/config/dlm/cluster/comms"
|
||||
|
||||
int setup_ccs(void)
|
||||
{
|
||||
/* To avoid creating an additional place for the dlm to be configured,
|
||||
* only allow configuration from the command-line until CoroSync is stable
|
||||
* enough to be used with Pacemaker
|
||||
*/
|
||||
cfgd_groupd_compat = 0; /* always use libcpg and disable backward compatability */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void close_ccs(void) { return; }
|
||||
int get_weight(int nodeid, char *lockspace) { return 1; }
|
||||
|
||||
/* TODO: Make this configurable
|
||||
* Can't use logging.c as-is as whitetank exposes a different logging API
|
||||
*/
|
||||
void init_logging(void) {
|
||||
openlog("cluster-dlm", LOG_PERROR|LOG_PID|LOG_CONS|LOG_NDELAY, LOG_DAEMON);
|
||||
/* cl_log_enable_stderr(TRUE); */
|
||||
}
|
||||
|
||||
void setup_logging(void) { return; }
|
||||
void close_logging(void) {
|
||||
closelog();
|
||||
}
|
||||
|
||||
extern int ais_fd_async;
|
||||
|
||||
int local_node_id = 0;
|
||||
char *local_node_uname = NULL;
|
||||
void dlm_process_node(gpointer key, gpointer value, gpointer user_data);
|
||||
|
||||
int setup_cluster(void)
|
||||
{
|
||||
int retries = 0;
|
||||
int rc = SA_AIS_OK;
|
||||
struct utsname name;
|
||||
|
||||
crm_peer_init();
|
||||
|
||||
if(local_node_uname == NULL) {
|
||||
if(uname(&name) < 0) {
|
||||
cl_perror("uname(2) call failed");
|
||||
exit(100);
|
||||
}
|
||||
local_node_uname = crm_strdup(name.nodename);
|
||||
log_debug("Local node name: %s", local_node_uname);
|
||||
}
|
||||
|
||||
/* 16 := CRM_SERVICE */
|
||||
retry:
|
||||
log_debug("Creating connection to our AIS plugin");
|
||||
rc = saServiceConnect (&ais_fd_sync, &ais_fd_async, CRM_SERVICE);
|
||||
if (rc != SA_AIS_OK) {
|
||||
log_error("Connection to our AIS plugin (%d) failed: %s (%d)", CRM_SERVICE, ais_error2text(rc), rc);
|
||||
}
|
||||
|
||||
switch(rc) {
|
||||
case SA_AIS_OK:
|
||||
break;
|
||||
case SA_AIS_ERR_TRY_AGAIN:
|
||||
if(retries < 30) {
|
||||
sleep(1);
|
||||
retries++;
|
||||
goto retry;
|
||||
}
|
||||
log_error("Retry count exceeded");
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
log_debug("AIS connection established");
|
||||
|
||||
{
|
||||
int pid = getpid();
|
||||
char *pid_s = crm_itoa(pid);
|
||||
send_ais_text(0, pid_s, TRUE, NULL, crm_msg_ais);
|
||||
crm_free(pid_s);
|
||||
}
|
||||
|
||||
/* Sign up for membership updates */
|
||||
send_ais_text(crm_class_notify, "true", TRUE, NULL, crm_msg_ais);
|
||||
|
||||
/* Requesting the current list of known nodes */
|
||||
send_ais_text(crm_class_members, __FUNCTION__, TRUE, NULL, crm_msg_ais);
|
||||
|
||||
our_nodeid = get_ais_nodeid();
|
||||
log_debug("Local node id: %d", our_nodeid);
|
||||
|
||||
return ais_fd_async;
|
||||
}
|
||||
|
||||
static void statechange(void)
|
||||
{
|
||||
static uint64_t last_membership = 0;
|
||||
cluster_quorate = crm_have_quorum;
|
||||
if(last_membership < crm_peer_seq) {
|
||||
log_debug("Processing membership %llu", crm_peer_seq);
|
||||
g_hash_table_foreach(crm_peer_cache, dlm_process_node, &last_membership);
|
||||
last_membership = crm_peer_seq;
|
||||
}
|
||||
}
|
||||
|
||||
void update_cluster(void)
|
||||
{
|
||||
statechange();
|
||||
}
|
||||
|
||||
void process_cluster(int ci)
|
||||
{
|
||||
/* ci ::= client number */
|
||||
char *data = NULL;
|
||||
char *uncompressed = NULL;
|
||||
|
||||
AIS_Message *msg = NULL;
|
||||
SaAisErrorT rc = SA_AIS_OK;
|
||||
mar_res_header_t *header = NULL;
|
||||
static int header_len = sizeof(mar_res_header_t);
|
||||
|
||||
header = malloc(header_len);
|
||||
memset(header, 0, header_len);
|
||||
|
||||
errno = 0;
|
||||
rc = saRecvRetry(ais_fd_async, header, header_len);
|
||||
if (rc != SA_AIS_OK) {
|
||||
cl_perror("Receiving message header failed: (%d) %s", rc, ais_error2text(rc));
|
||||
goto bail;
|
||||
|
||||
} else if(header->size == header_len) {
|
||||
log_error("Empty message: id=%d, size=%d, error=%d, header_len=%d",
|
||||
header->id, header->size, header->error, header_len);
|
||||
goto done;
|
||||
|
||||
} else if(header->size == 0 || header->size < header_len) {
|
||||
log_error("Mangled header: size=%d, header=%d, error=%d",
|
||||
header->size, header_len, header->error);
|
||||
goto done;
|
||||
|
||||
} else if(header->error != 0) {
|
||||
log_error("Header contined error: %d", header->error);
|
||||
}
|
||||
|
||||
header = realloc(header, header->size);
|
||||
/* Use a char* so we can store the remainder into an offset */
|
||||
data = (char*)header;
|
||||
|
||||
errno = 0;
|
||||
rc = saRecvRetry(ais_fd_async, data+header_len, header->size - header_len);
|
||||
msg = (AIS_Message*)data;
|
||||
|
||||
if (rc != SA_AIS_OK) {
|
||||
cl_perror("Receiving message body failed: (%d) %s", rc, ais_error2text(rc));
|
||||
goto bail;
|
||||
}
|
||||
|
||||
data = msg->data;
|
||||
if(msg->is_compressed && msg->size > 0) {
|
||||
int rc = BZ_OK;
|
||||
unsigned int new_size = msg->size;
|
||||
|
||||
if(check_message_sanity(msg, NULL) == FALSE) {
|
||||
goto badmsg;
|
||||
}
|
||||
|
||||
log_debug("Decompressing message data");
|
||||
uncompressed = malloc(new_size);
|
||||
memset(uncompressed, 0, new_size);
|
||||
|
||||
rc = BZ2_bzBuffToBuffDecompress(
|
||||
uncompressed, &new_size, data, msg->compressed_size, 1, 0);
|
||||
|
||||
if(rc != BZ_OK) {
|
||||
log_error("Decompression failed: %d", rc);
|
||||
goto badmsg;
|
||||
}
|
||||
|
||||
CRM_ASSERT(rc == BZ_OK);
|
||||
CRM_ASSERT(new_size == msg->size);
|
||||
|
||||
data = uncompressed;
|
||||
|
||||
} else if(check_message_sanity(msg, data) == FALSE) {
|
||||
goto badmsg;
|
||||
|
||||
} else if(safe_str_eq("identify", data)) {
|
||||
int pid = getpid();
|
||||
char *pid_s = crm_itoa(pid);
|
||||
send_ais_text(0, pid_s, TRUE, NULL, crm_msg_ais);
|
||||
crm_free(pid_s);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if(msg->header.id == crm_class_members) {
|
||||
xmlNode *xml = string2xml(data);
|
||||
|
||||
if(xml != NULL) {
|
||||
const char *value = crm_element_value(xml, "id");
|
||||
if(value) {
|
||||
crm_peer_seq = crm_int_helper(value, NULL);
|
||||
}
|
||||
|
||||
log_debug("Updating membership %llu", crm_peer_seq);
|
||||
/* crm_log_xml_info(xml, __PRETTY_FUNCTION__); */
|
||||
xml_child_iter(xml, node, crm_update_ais_node(node, crm_peer_seq));
|
||||
crm_calculate_quorum();
|
||||
statechange();
|
||||
free_xml(xml);
|
||||
|
||||
} else {
|
||||
log_error("Invalid peer update: %s", data);
|
||||
}
|
||||
|
||||
} else {
|
||||
log_error("Unexpected AIS message type: %d", msg->header.id);
|
||||
}
|
||||
|
||||
done:
|
||||
free(uncompressed);
|
||||
free(msg);
|
||||
return;
|
||||
|
||||
badmsg:
|
||||
log_error("Invalid message (id=%d, dest=%s:%s, from=%s:%s.%d):"
|
||||
" min=%d, total=%d, size=%d, bz2_size=%d",
|
||||
msg->id, ais_dest(&(msg->host)), msg_type2text(msg->host.type),
|
||||
ais_dest(&(msg->sender)), msg_type2text(msg->sender.type),
|
||||
msg->sender.pid, (int)sizeof(AIS_Message),
|
||||
msg->header.size, msg->size, msg->compressed_size);
|
||||
goto done;
|
||||
|
||||
bail:
|
||||
log_error("AIS connection failed");
|
||||
return;
|
||||
}
|
||||
|
||||
void close_cluster(void) {
|
||||
/* TODO: Implement something for this */
|
||||
return;
|
||||
}
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <openais/totem/totemip.h>
|
||||
|
||||
void dlm_process_node(gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
int rc = 0;
|
||||
struct stat tmp;
|
||||
char path[PATH_MAX];
|
||||
crm_node_t *node = value;
|
||||
uint64_t *last = user_data;
|
||||
const char *action = "Skipped";
|
||||
|
||||
gboolean do_add = FALSE;
|
||||
gboolean do_remove = FALSE;
|
||||
gboolean is_active = FALSE;
|
||||
|
||||
memset(path, 0, PATH_MAX);
|
||||
snprintf(path, PATH_MAX, "%s/%d", COMMS_DIR, node->id);
|
||||
|
||||
rc = stat(path, &tmp);
|
||||
is_active = crm_is_member_active(node);
|
||||
|
||||
if(rc == 0 && is_active) {
|
||||
/* nothing to do?
|
||||
* maybe the node left and came back...
|
||||
*/
|
||||
} else if(rc == 0) {
|
||||
do_remove = TRUE;
|
||||
|
||||
} else if(is_active) {
|
||||
do_add = TRUE;
|
||||
}
|
||||
|
||||
if(do_remove) {
|
||||
action = "Removed";
|
||||
del_configfs_node(node->id);
|
||||
}
|
||||
|
||||
if(do_add) {
|
||||
char *addr_copy = strdup(node->addr);
|
||||
char *addr_top = addr_copy;
|
||||
char *addr = NULL;
|
||||
|
||||
if(do_remove) {
|
||||
action = "Re-added";
|
||||
} else {
|
||||
action = "Added";
|
||||
}
|
||||
|
||||
if(local_node_id == 0) {
|
||||
crm_node_t *local_node = g_hash_table_lookup(
|
||||
crm_peer_cache, local_node_uname);
|
||||
local_node_id = local_node->id;
|
||||
}
|
||||
|
||||
do {
|
||||
char ipaddr[1024];
|
||||
int addr_family = AF_INET;
|
||||
int cna_len = 0, rc = 0;
|
||||
struct sockaddr_storage cna_addr;
|
||||
struct totem_ip_address totem_addr;
|
||||
|
||||
addr = strsep(&addr_copy, " ");
|
||||
if(addr == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* do_cmd_get_node_addrs */
|
||||
if(strstr(addr, "ip(") == NULL) {
|
||||
continue;
|
||||
|
||||
} else if(strchr(addr, ':')) {
|
||||
rc = sscanf(addr, "ip(%[0-9A-Fa-f:])", ipaddr);
|
||||
if(rc != 1) {
|
||||
log_error("Could not extract IPv6 address from '%s'", addr);
|
||||
continue;
|
||||
}
|
||||
addr_family = AF_INET6;
|
||||
|
||||
} else {
|
||||
rc = sscanf(addr, "ip(%[0-9.]) ", ipaddr);
|
||||
if(rc != 1) {
|
||||
log_error("Could not extract IPv4 address from '%s'", addr);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
rc = inet_pton(addr_family, ipaddr, &totem_addr);
|
||||
if(rc != 1) {
|
||||
log_error("Could not parse '%s' as in IPv%c address", ipaddr, (addr_family==AF_INET)?'4':'6');
|
||||
continue;
|
||||
}
|
||||
|
||||
rc = totemip_parse(&totem_addr, ipaddr, addr_family);
|
||||
if(rc != 0) {
|
||||
log_error("Could not convert '%s' into a totem address", ipaddr);
|
||||
continue;
|
||||
}
|
||||
|
||||
rc = totemip_totemip_to_sockaddr_convert(&totem_addr, 0, &cna_addr, &cna_len);
|
||||
if(rc != 0) {
|
||||
log_error("Could not convert totem address for '%s' into sockaddr", ipaddr);
|
||||
continue;
|
||||
}
|
||||
|
||||
log_debug("Adding address %s to configfs for node %u/%s ", addr, node->id, node->uname);
|
||||
add_configfs_node(node->id, ((char*)&cna_addr), cna_len, (node->id == local_node_id));
|
||||
|
||||
} while(addr != NULL);
|
||||
free(addr_top);
|
||||
}
|
||||
|
||||
log_debug("%s %sctive node %u '%s': born-on=%llu, last-seen=%llu, this-event=%llu, last-event=%llu",
|
||||
action, crm_is_member_active(value)?"a":"ina",
|
||||
node->id, node->uname, node->born, node->last_seen,
|
||||
crm_peer_seq, (unsigned long long)*last);
|
||||
}
|
||||
|
||||
int is_cluster_member(int nodeid)
|
||||
{
|
||||
crm_node_t *node = crm_get_peer(nodeid, NULL);
|
||||
return crm_is_member_active(node);
|
||||
}
|
||||
|
||||
char *nodeid2name(int nodeid) {
|
||||
crm_node_t *node = crm_get_peer(nodeid, NULL);
|
||||
if(node->uname == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return strdup(node->uname);
|
||||
}
|
||||
|
||||
void kick_node_from_cluster(int nodeid)
|
||||
{
|
||||
log_error("%s not yet implemented", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
+475
-203
@@ -1,218 +1,490 @@
|
||||
Only in dev: .DS_Store
|
||||
Only in dev: .hgtags
|
||||
--- cluster-rh/configure 2008-09-01 13:51:56.000000000 +0200
|
||||
+++ dev/configure 2008-09-01 13:57:26.000000000 +0200
|
||||
@@ -88,6 +88,7 @@ my %options = (
|
||||
enable_legacy_code => \$enable_legacy_code,
|
||||
enable_contrib => \$enable_contrib,
|
||||
enable_virt => \$enable_virt,
|
||||
+ enable_pacemaker => \$enable_pacemaker,
|
||||
somajor => \$somajor,
|
||||
sominor => \$sominor,
|
||||
release_version => \$release_version,
|
||||
@@ -178,6 +179,7 @@ my $err = &GetOptions (\%options,
|
||||
'enable_legacy_code',
|
||||
'enable_contrib',
|
||||
'enable_virt',
|
||||
+ 'enable_pacemaker',
|
||||
'without_config',
|
||||
'without_cman',
|
||||
'without_dlm',
|
||||
@@ -271,6 +273,7 @@ if ($help || !$err) {
|
||||
print "--enable_contrib\tEnable build of community contributed code/tools. (Default: no)\n";
|
||||
print "--enable_legacy_code\tEnable build of old/obsolete/unsupported code/tools. (Default: no)\n";
|
||||
print "--enable_virt\tEnable building of virtualization code (Default: disabled\n";
|
||||
+ print "--enable_pacemaker\tEnable building of Pacemaker-specific pieces\n";
|
||||
print "--without_config\tDisable config building (Default: enabled)\n";
|
||||
print "--without_cman\tDisable cman building (Default: enabled)\n";
|
||||
print "--without_dlm\tDisable dlm building (Default: enabled)\n";
|
||||
@@ -613,6 +616,9 @@ if (!$enable_legacy_code) {
|
||||
if (!$enable_virt) {
|
||||
$enable_virt="";
|
||||
}
|
||||
+if (!$enable_pacemaker) {
|
||||
+ $enable_pacemaker=""
|
||||
+}
|
||||
if (!$without_config) {
|
||||
$without_config="";
|
||||
}
|
||||
@@ -756,6 +762,7 @@ while (<IFILE>) {
|
||||
$_ =~ s/\@ENABLE_LEGACY_CODE\@/$enable_legacy_code/;
|
||||
$_ =~ s/\@ENABLE_CONTRIB\@/$enable_contrib/;
|
||||
$_ =~ s/\@ENABLE_VIRT\@/$enable_virt/;
|
||||
+ $_ =~ s/\@ENABLE_PACEMAKER\@/$enable_pacemaker/;
|
||||
$_ =~ s/\@DISABLE_CONFIG\@/$without_config/;
|
||||
$_ =~ s/\@DISABLE_CMAN\@/$without_cman/;
|
||||
$_ =~ s/\@DISABLE_DLM\@/$without_dlm/;
|
||||
Only in dev/gfs: make
|
||||
Only in dev/gfs-kernel: make
|
||||
Only in dev/group: .DS_Store
|
||||
--- cluster-rh/group/Makefile 2008-08-13 22:24:12.000000000 +0200
|
||||
+++ dev/group/Makefile 2008-09-01 14:19:18.000000000 +0200
|
||||
@@ -1,4 +1,12 @@
|
||||
include ../make/defines.mk
|
||||
include $(OBJDIR)/make/passthrough.mk
|
||||
|
||||
-SUBDIRS=lib libgfscontrol daemon tool dlm_controld gfs_control gfs_controld man
|
||||
+SUBDIRS = lib dlm_controld
|
||||
+
|
||||
+ifndef without_gfs
|
||||
+SUBDIRS += libgfscontrol gfs_control gfs_controld
|
||||
+endif
|
||||
+
|
||||
+ifndef enable_pacemaker
|
||||
+SUBDIRS += tool daemon man
|
||||
+endif
|
||||
--- cluster-rh/group/daemon/gd_internal.h 2008-10-01 14:27:52.000000000 +0200
|
||||
+++ dev/group/daemon/gd_internal.h 2008-10-09 09:06:43.000000000 +0200
|
||||
@@ -21,8 +21,13 @@
|
||||
#include <sys/poll.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
+
|
||||
+#ifdef ENABLE_PACEMAKER
|
||||
+# define log_printf(level, format, args...) syslog(level, "%s:%d " format "\n", __FILE__, __LINE__, ##args)
|
||||
+#else
|
||||
#include <corosync/cpg.h>
|
||||
#include <corosync/engine/logsys.h>
|
||||
+#endif
|
||||
|
||||
#include "list.h"
|
||||
#include "linux_endian.h"
|
||||
--- cluster-rh/group/dlm_controld/Makefile 2008-08-13 22:24:12.000000000 +0200
|
||||
+++ dev/group/dlm_controld/Makefile 2008-08-25 09:33:29.000000000 +0200
|
||||
@@ -1,26 +1,31 @@
|
||||
-TARGET= dlm_controld
|
||||
+TARGET=
|
||||
+SBINDIRT=
|
||||
|
||||
-SBINDIRT=$(TARGET)
|
||||
+include ../../make/defines.mk
|
||||
+
|
||||
+ifdef enable_pacemaker
|
||||
+TARGET += dlm_controld.pcmk
|
||||
+SBINDIRT += dlm_controld.pcmk
|
||||
+else
|
||||
+TARGET += dlm_controld.cman
|
||||
+SBINDIRT += dlm_controld.cman
|
||||
+endif
|
||||
|
||||
all: depends ${TARGET}
|
||||
|
||||
-include ../../make/defines.mk
|
||||
include $(OBJDIR)/make/cobj.mk
|
||||
include $(OBJDIR)/make/clean.mk
|
||||
include $(OBJDIR)/make/install.mk
|
||||
include $(OBJDIR)/make/uninstall.mk
|
||||
|
||||
OBJS= action.o \
|
||||
- config.o \
|
||||
cpg.o \
|
||||
crc.o \
|
||||
deadlock.o \
|
||||
main.o \
|
||||
- member_cman.o \
|
||||
netlink.o \
|
||||
plock.o \
|
||||
- group.o \
|
||||
- logging.o
|
||||
+ group.o
|
||||
|
||||
CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${dlmincdir} -I${dlmcontrolincdir}
|
||||
CFLAGS += -I${corosyncincdir} -I${openaisincdir}
|
||||
@@ -29,19 +34,36 @@ CFLAGS += -I${KERNEL_SRC}/include/
|
||||
CFLAGS += -I$(S)/../lib/ -I$(S)/../include/
|
||||
diff --git a/group/dlm_controld/Makefile b/group/dlm_controld/Makefile
|
||||
--- a/group/dlm_controld/Makefile
|
||||
+++ b/group/dlm_controld/Makefile
|
||||
@@ -45,7 +45,7 @@ endif
|
||||
CFLAGS += -I${incdir}
|
||||
|
||||
-LDFLAGS += -L${ccslibdir} -L${cmanlibdir} -lccs -lcman
|
||||
LDFLAGS += -L${dlmlibdir} -ldlm
|
||||
-LDFLAGS += -L${corosynclibdir} -lcpg -llogsys -lpthread
|
||||
LDFLAGS += -L${openaislibdir} -lSaCkpt
|
||||
-LDFLAGS += -L../../fence/libfenced/ -lfenced
|
||||
LDFLAGS += -L../lib -lgroup
|
||||
LDFLAGS += -L${dlmlibdir} -ldlm
|
||||
-LDFLAGS += -L${logtlibdir} -llogthread
|
||||
+#LDFLAGS += -L${logtlibdir} -llogthread
|
||||
LDFLAGS += -L${openaislibdir} -lSaCkpt
|
||||
LDFLAGS += -L${corosynclibdir} -lcpg
|
||||
LDFLAGS += -L${libdir}
|
||||
|
||||
-LDDEPS += ../../fence/libfenced/libfenced.a
|
||||
LDDEPS += ../lib/libgroup.a
|
||||
|
||||
-${TARGET}: ${OBJS} ${LDDEPS}
|
||||
- $(CC) -o $@ $^ $(LDFLAGS)
|
||||
+ifdef enable_pacemaker
|
||||
+CFLAGS += -I${incdir}/heartbeat -I${incdir}/pacemaker
|
||||
+CFLAGS += `pkg-config glib-2.0 --cflags`
|
||||
+CFLAGS += `xml2-config --cflags`
|
||||
+endif
|
||||
+
|
||||
+PCMK_OBJS = pacemaker.o
|
||||
+PCMK_LDFLAGS += -lcib -lcrmcommon -lcrmcluster -ltotem_pg
|
||||
+PCMK_LDFLAGS += -L${openaislibdir} -lcpg -lSaCkpt -lpthread
|
||||
+PCMK_LDFLAGS += `pkg-config glib-2.0 --libs`
|
||||
+PCMK_LDFLAGS += `xml2-config --libs`
|
||||
+
|
||||
+CMAN_OBJS = config.o member_cman.o logger.o
|
||||
+CMAN_LDFLAGS += -L${ccslibdir} -L${cmanlibdir} -lccs -lcman
|
||||
+CMAN_LDFLAGS += -L${corosynclibdir} -lcpg -llogsys -lpthread
|
||||
+CMAN_LDFLAGS += -L../../fence/libfenced/ -lfenced
|
||||
+CMAN_LDDEPS += ../../fence/libfenced/libfenced.a
|
||||
+
|
||||
+dlm_controld.cman: ${OBJS} ${CMAN_OBJS} ${LDDEPS} ${CMAN_LDDEPS}
|
||||
+ $(CC) -o $@ $^ $(LDFLAGS) $(CMAN_LDFLAGS)
|
||||
+
|
||||
+dlm_controld.pcmk: ${OBJS} ${PCMK_OBJS} ${LDDEPS} ${PCMK_LDDEPS}
|
||||
+ $(CC) -o $@ $^ $(LDFLAGS) $(PCMK_LDFLAGS)
|
||||
|
||||
depends:
|
||||
$(MAKE) -C ../lib all
|
||||
--- cluster-rh/group/dlm_controld/cpg.c 2008-10-09 09:04:47.000000000 +0200
|
||||
+++ dev/group/dlm_controld/cpg.c 2008-10-09 09:06:43.000000000 +0200
|
||||
@@ -418,6 +418,7 @@ static void node_history_fail(struct loc
|
||||
|
||||
static int check_fencing_done(struct lockspace *ls)
|
||||
{
|
||||
+#ifndef ENABLE_PACEMAKER
|
||||
struct node *node;
|
||||
uint64_t last_fenced_time;
|
||||
int in_progress, wait_count = 0;
|
||||
@@ -462,6 +463,7 @@ static int check_fencing_done(struct loc
|
||||
|
||||
if (in_progress)
|
||||
return 0;
|
||||
+#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
--- cluster-rh/group/dlm_controld/dlm_daemon.h 2008-10-09 09:04:47.000000000 +0200
|
||||
+++ dev/group/dlm_controld/dlm_daemon.h 2008-10-09 09:06:44.000000000 +0200
|
||||
@@ -32,8 +32,13 @@
|
||||
#include <dirent.h>
|
||||
diff --git a/group/dlm_controld/dlm_daemon.h b/group/dlm_controld/dlm_daemon.h
|
||||
--- a/group/dlm_controld/dlm_daemon.h
|
||||
+++ b/group/dlm_controld/dlm_daemon.h
|
||||
@@ -33,8 +33,14 @@
|
||||
#include <openais/saAis.h>
|
||||
#include <openais/saCkpt.h>
|
||||
|
||||
+#ifdef ENABLE_PACEMAKER
|
||||
+#include <openais/cpg.h>
|
||||
+#define log_printf(level, format, args...) syslog(level, "%s:%d " format "\n", __FILE__, __LINE__, ##args)
|
||||
+#define log_printf(level, format, args...) syslog(level, "%s: " format "\n", __FUNCTION__, ##args)
|
||||
+#define logt_print(level, format, args...) syslog(level, "%s: " format "\n", __FUNCTION__, ##args)
|
||||
+#else
|
||||
#include <corosync/cpg.h>
|
||||
#include <corosync/engine/logsys.h>
|
||||
#include <liblogthread.h>
|
||||
+#endif
|
||||
|
||||
#include <linux/dlmconstants.h>
|
||||
#include "libdlmcontrol.h"
|
||||
Only in dev/group/dlm_controld: pacemaker.c
|
||||
--- cluster-rh/make/defines.mk.input 2008-09-01 13:51:56.000000000 +0200
|
||||
+++ dev/make/defines.mk.input 2008-09-01 13:59:25.000000000 +0200
|
||||
@@ -22,6 +22,7 @@ RANLIB = ranlib
|
||||
diff --git a/group/dlm_controld/pacemaker.c b/group/dlm_controld/pacemaker.c
|
||||
--- a/group/dlm_controld/pacemaker.c
|
||||
+++ b/group/dlm_controld/pacemaker.c
|
||||
@@ -11,10 +11,15 @@
|
||||
|
||||
CFLAGS += @CFLAGS@ -I@SRCDIR@/make
|
||||
CFLAGS += -DDEFAULT_CONFIG_DIR=\"@CONFDIR@\" -DDEFAULT_CONFIG_FILE=\"@CONFFILE@\"
|
||||
+CFLAGS += -DENABLE_PACEMAKER=@ENABLE_PACEMAKER@
|
||||
CFLAGS += -DLOGDIR=\"@LOGDIR@\" -DSYSLOGFACILITY=@SYSLOGFACILITY@ -DSYSLOGLEVEL=@SYSLOGLEVEL@
|
||||
LDFLAGS += @LDFLAGS@
|
||||
#include <pacemaker/crm/crm.h>
|
||||
#include <pacemaker/crm/ais.h>
|
||||
+#include <pacemaker/crm/attrd.h>
|
||||
/* heartbeat support is irrelevant here */
|
||||
#undef SUPPORT_HEARTBEAT
|
||||
#define SUPPORT_HEARTBEAT 0
|
||||
#include <pacemaker/crm/common/cluster.h>
|
||||
+#include <pacemaker/crm/common/stack.h>
|
||||
+#include <pacemaker/crm/common/ipc.h>
|
||||
+#include <pacemaker/crm/msg_xml.h>
|
||||
+#include <pacemaker/crm/cib.h>
|
||||
|
||||
@@ -71,6 +72,7 @@ experimental_build ?= @ENABLE_CRACK_OF_T
|
||||
legacy_code ?= @ENABLE_LEGACY_CODE@
|
||||
contrib_code ?= @ENABLE_CONTRIB@
|
||||
enable_virt ?= @ENABLE_VIRT@
|
||||
+enable_pacemaker ?= @ENABLE_PACEMAKER@
|
||||
without_gnbd-kernel/src ?= @DISABLE_GNBDKERNEL@
|
||||
without_gfs-kernel/src/gfs ?= @DISABLE_GFSKERNEL@
|
||||
without_config ?= @DISABLE_CONFIG@
|
||||
#define COMMS_DIR "/sys/kernel/config/dlm/cluster/comms"
|
||||
|
||||
@@ -24,7 +29,6 @@ int setup_ccs(void)
|
||||
* only allow configuration from the command-line until CoroSync is stable
|
||||
* enough to be used with Pacemaker
|
||||
*/
|
||||
- cfgd_groupd_compat = 0; /* always use libcpg and disable backward compatability */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -52,51 +56,12 @@ void dlm_process_node(gpointer key, gpointer value, gpointer user_data);
|
||||
|
||||
int setup_cluster(void)
|
||||
{
|
||||
- int retries = 0;
|
||||
- int rc = SA_AIS_OK;
|
||||
- struct utsname name;
|
||||
-
|
||||
- crm_peer_init();
|
||||
-
|
||||
- if(local_node_uname == NULL) {
|
||||
- if(uname(&name) < 0) {
|
||||
- cl_perror("uname(2) call failed");
|
||||
- exit(100);
|
||||
- }
|
||||
- local_node_uname = crm_strdup(name.nodename);
|
||||
- log_debug("Local node name: %s", local_node_uname);
|
||||
- }
|
||||
+ ais_fd_async = -1;
|
||||
+ crm_log_init("cluster-dlm", LOG_INFO, FALSE, TRUE, 0, NULL);
|
||||
|
||||
- /* 16 := CRM_SERVICE */
|
||||
- retry:
|
||||
- log_debug("Creating connection to our AIS plugin");
|
||||
- rc = saServiceConnect (&ais_fd_sync, &ais_fd_async, CRM_SERVICE);
|
||||
- if (rc != SA_AIS_OK) {
|
||||
- log_error("Connection to our AIS plugin (%d) failed: %s (%d)", CRM_SERVICE, ais_error2text(rc), rc);
|
||||
- }
|
||||
-
|
||||
- switch(rc) {
|
||||
- case SA_AIS_OK:
|
||||
- break;
|
||||
- case SA_AIS_ERR_TRY_AGAIN:
|
||||
- if(retries < 30) {
|
||||
- sleep(1);
|
||||
- retries++;
|
||||
- goto retry;
|
||||
- }
|
||||
- log_error("Retry count exceeded");
|
||||
- return 0;
|
||||
- default:
|
||||
- return 0;
|
||||
- }
|
||||
-
|
||||
- log_debug("AIS connection established");
|
||||
-
|
||||
- {
|
||||
- int pid = getpid();
|
||||
- char *pid_s = crm_itoa(pid);
|
||||
- send_ais_text(0, pid_s, TRUE, NULL, crm_msg_ais);
|
||||
- crm_free(pid_s);
|
||||
+ if(init_ais_connection(NULL, NULL, NULL, &local_node_uname, &our_nodeid) == FALSE) {
|
||||
+ log_printf(LOG_ERR, "Connection to our AIS plugin (%d) failed", CRM_SERVICE);
|
||||
+ return -1;
|
||||
}
|
||||
|
||||
/* Sign up for membership updates */
|
||||
@@ -105,162 +70,32 @@ int setup_cluster(void)
|
||||
/* Requesting the current list of known nodes */
|
||||
send_ais_text(crm_class_members, __FUNCTION__, TRUE, NULL, crm_msg_ais);
|
||||
|
||||
- our_nodeid = get_ais_nodeid();
|
||||
- log_debug("Local node id: %d", our_nodeid);
|
||||
-
|
||||
return ais_fd_async;
|
||||
}
|
||||
|
||||
-static void statechange(void)
|
||||
+void update_cluster(void)
|
||||
{
|
||||
static uint64_t last_membership = 0;
|
||||
cluster_quorate = crm_have_quorum;
|
||||
if(last_membership < crm_peer_seq) {
|
||||
- log_debug("Processing membership %llu", crm_peer_seq);
|
||||
+ log_printf(LOG_INFO, "Processing membership %llu", crm_peer_seq);
|
||||
g_hash_table_foreach(crm_peer_cache, dlm_process_node, &last_membership);
|
||||
last_membership = crm_peer_seq;
|
||||
}
|
||||
}
|
||||
|
||||
-void update_cluster(void)
|
||||
-{
|
||||
- statechange();
|
||||
-}
|
||||
-
|
||||
void process_cluster(int ci)
|
||||
{
|
||||
-/* ci ::= client number */
|
||||
- char *data = NULL;
|
||||
- char *uncompressed = NULL;
|
||||
-
|
||||
- AIS_Message *msg = NULL;
|
||||
- SaAisErrorT rc = SA_AIS_OK;
|
||||
- mar_res_header_t *header = NULL;
|
||||
- static int header_len = sizeof(mar_res_header_t);
|
||||
-
|
||||
- header = malloc(header_len);
|
||||
- memset(header, 0, header_len);
|
||||
-
|
||||
- errno = 0;
|
||||
- rc = saRecvRetry(ais_fd_async, header, header_len);
|
||||
- if (rc != SA_AIS_OK) {
|
||||
- cl_perror("Receiving message header failed: (%d) %s", rc, ais_error2text(rc));
|
||||
- goto bail;
|
||||
-
|
||||
- } else if(header->size == header_len) {
|
||||
- log_error("Empty message: id=%d, size=%d, error=%d, header_len=%d",
|
||||
- header->id, header->size, header->error, header_len);
|
||||
- goto done;
|
||||
-
|
||||
- } else if(header->size == 0 || header->size < header_len) {
|
||||
- log_error("Mangled header: size=%d, header=%d, error=%d",
|
||||
- header->size, header_len, header->error);
|
||||
- goto done;
|
||||
-
|
||||
- } else if(header->error != 0) {
|
||||
- log_error("Header contined error: %d", header->error);
|
||||
- }
|
||||
-
|
||||
- header = realloc(header, header->size);
|
||||
- /* Use a char* so we can store the remainder into an offset */
|
||||
- data = (char*)header;
|
||||
-
|
||||
- errno = 0;
|
||||
- rc = saRecvRetry(ais_fd_async, data+header_len, header->size - header_len);
|
||||
- msg = (AIS_Message*)data;
|
||||
-
|
||||
- if (rc != SA_AIS_OK) {
|
||||
- cl_perror("Receiving message body failed: (%d) %s", rc, ais_error2text(rc));
|
||||
- goto bail;
|
||||
- }
|
||||
-
|
||||
- data = msg->data;
|
||||
- if(msg->is_compressed && msg->size > 0) {
|
||||
- int rc = BZ_OK;
|
||||
- unsigned int new_size = msg->size;
|
||||
-
|
||||
- if(check_message_sanity(msg, NULL) == FALSE) {
|
||||
- goto badmsg;
|
||||
- }
|
||||
-
|
||||
- log_debug("Decompressing message data");
|
||||
- uncompressed = malloc(new_size);
|
||||
- memset(uncompressed, 0, new_size);
|
||||
-
|
||||
- rc = BZ2_bzBuffToBuffDecompress(
|
||||
- uncompressed, &new_size, data, msg->compressed_size, 1, 0);
|
||||
-
|
||||
- if(rc != BZ_OK) {
|
||||
- log_error("Decompression failed: %d", rc);
|
||||
- goto badmsg;
|
||||
- }
|
||||
-
|
||||
- CRM_ASSERT(rc == BZ_OK);
|
||||
- CRM_ASSERT(new_size == msg->size);
|
||||
-
|
||||
- data = uncompressed;
|
||||
-
|
||||
- } else if(check_message_sanity(msg, data) == FALSE) {
|
||||
- goto badmsg;
|
||||
-
|
||||
- } else if(safe_str_eq("identify", data)) {
|
||||
- int pid = getpid();
|
||||
- char *pid_s = crm_itoa(pid);
|
||||
- send_ais_text(0, pid_s, TRUE, NULL, crm_msg_ais);
|
||||
- crm_free(pid_s);
|
||||
- goto done;
|
||||
- }
|
||||
-
|
||||
- if(msg->header.id == crm_class_members) {
|
||||
- xmlNode *xml = string2xml(data);
|
||||
-
|
||||
- if(xml != NULL) {
|
||||
- const char *value = crm_element_value(xml, "id");
|
||||
- if(value) {
|
||||
- crm_peer_seq = crm_int_helper(value, NULL);
|
||||
- }
|
||||
-
|
||||
- log_debug("Updating membership %llu", crm_peer_seq);
|
||||
- /* crm_log_xml_info(xml, __PRETTY_FUNCTION__); */
|
||||
- xml_child_iter(xml, node, crm_update_ais_node(node, crm_peer_seq));
|
||||
- crm_calculate_quorum();
|
||||
- statechange();
|
||||
- free_xml(xml);
|
||||
-
|
||||
- } else {
|
||||
- log_error("Invalid peer update: %s", data);
|
||||
- }
|
||||
-
|
||||
- } else {
|
||||
- log_error("Unexpected AIS message type: %d", msg->header.id);
|
||||
- }
|
||||
-
|
||||
- done:
|
||||
- free(uncompressed);
|
||||
- free(msg);
|
||||
- return;
|
||||
-
|
||||
- badmsg:
|
||||
- log_error("Invalid message (id=%d, dest=%s:%s, from=%s:%s.%d):"
|
||||
- " min=%d, total=%d, size=%d, bz2_size=%d",
|
||||
- msg->id, ais_dest(&(msg->host)), msg_type2text(msg->host.type),
|
||||
- ais_dest(&(msg->sender)), msg_type2text(msg->sender.type),
|
||||
- msg->sender.pid, (int)sizeof(AIS_Message),
|
||||
- msg->header.size, msg->size, msg->compressed_size);
|
||||
- goto done;
|
||||
-
|
||||
- bail:
|
||||
- log_error("AIS connection failed");
|
||||
- return;
|
||||
+ ais_dispatch(ais_fd_async, NULL);
|
||||
+ update_cluster();
|
||||
}
|
||||
|
||||
void close_cluster(void) {
|
||||
- /* TODO: Implement something for this */
|
||||
- return;
|
||||
+ terminate_ais_connection();
|
||||
}
|
||||
|
||||
#include <arpa/inet.h>
|
||||
-#include <corosync/totem/totemip.h>
|
||||
+#include <openais/totem/totemip.h>
|
||||
|
||||
void dlm_process_node(gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
@@ -333,7 +168,7 @@ void dlm_process_node(gpointer key, gpointer value, gpointer user_data)
|
||||
} else if(strchr(addr, ':')) {
|
||||
rc = sscanf(addr, "ip(%[0-9A-Fa-f:])", ipaddr);
|
||||
if(rc != 1) {
|
||||
- log_error("Could not extract IPv6 address from '%s'", addr);
|
||||
+ log_printf(LOG_ERR, "Could not extract IPv6 address from '%s'", addr);
|
||||
continue;
|
||||
}
|
||||
addr_family = AF_INET6;
|
||||
@@ -341,26 +176,26 @@ void dlm_process_node(gpointer key, gpointer value, gpointer user_data)
|
||||
} else {
|
||||
rc = sscanf(addr, "ip(%[0-9.]) ", ipaddr);
|
||||
if(rc != 1) {
|
||||
- log_error("Could not extract IPv4 address from '%s'", addr);
|
||||
+ log_printf(LOG_ERR, "Could not extract IPv4 address from '%s'", addr);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
rc = inet_pton(addr_family, ipaddr, &totem_addr);
|
||||
if(rc != 1) {
|
||||
- log_error("Could not parse '%s' as in IPv%c address", ipaddr, (addr_family==AF_INET)?'4':'6');
|
||||
+ log_printf(LOG_ERR, "Could not parse '%s' as in IPv%c address", ipaddr, (addr_family==AF_INET)?'4':'6');
|
||||
continue;
|
||||
}
|
||||
|
||||
rc = totemip_parse(&totem_addr, ipaddr, addr_family);
|
||||
if(rc != 0) {
|
||||
- log_error("Could not convert '%s' into a totem address", ipaddr);
|
||||
+ log_printf(LOG_ERR, "Could not convert '%s' into a totem address", ipaddr);
|
||||
continue;
|
||||
}
|
||||
|
||||
rc = totemip_totemip_to_sockaddr_convert(&totem_addr, 0, &cna_addr, &cna_len);
|
||||
if(rc != 0) {
|
||||
- log_error("Could not convert totem address for '%s' into sockaddr", ipaddr);
|
||||
+ log_printf(LOG_ERR, "Could not convert totem address for '%s' into sockaddr", ipaddr);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -371,10 +206,10 @@ void dlm_process_node(gpointer key, gpointer value, gpointer user_data)
|
||||
free(addr_top);
|
||||
}
|
||||
|
||||
- log_debug("%s %sctive node %u '%s': born-on=%llu, last-seen=%llu, this-event=%llu, last-event=%llu",
|
||||
- action, crm_is_member_active(value)?"a":"ina",
|
||||
- node->id, node->uname, node->born, node->last_seen,
|
||||
- crm_peer_seq, (unsigned long long)*last);
|
||||
+ log_printf(LOG_INFO, "%s %sctive node %u '%s': born-on=%llu, last-seen=%llu, this-event=%llu, last-event=%llu",
|
||||
+ action, crm_is_member_active(value)?"a":"ina",
|
||||
+ node->id, node->uname, node->born, node->last_seen,
|
||||
+ crm_peer_seq, (unsigned long long)*last);
|
||||
}
|
||||
|
||||
int is_cluster_member(int nodeid)
|
||||
@@ -391,19 +226,147 @@ char *nodeid2name(int nodeid) {
|
||||
return strdup(node->uname);
|
||||
}
|
||||
|
||||
+static IPC_Channel *attrd = NULL;
|
||||
+
|
||||
+static void attrd_deadfn(int ci)
|
||||
+{
|
||||
+ log_printf(LOG_ERR, "Lost connection to attrd");
|
||||
+ attrd = NULL;
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
void kick_node_from_cluster(int nodeid)
|
||||
{
|
||||
- log_error("%s not yet implemented", __FUNCTION__);
|
||||
+ gboolean rc = FALSE;
|
||||
+ xmlNode *update = NULL;
|
||||
+ time_t now = time(NULL);
|
||||
+ crm_node_t *node = crm_get_peer(nodeid, NULL);
|
||||
+
|
||||
+ if(node == NULL || node->uname == NULL) {
|
||||
+ log_printf(LOG_ERR, "%s: Don't know how to kick node %d/%p", __FUNCTION__, nodeid, node);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if(attrd == NULL) {
|
||||
+ log_printf(LOG_INFO, "Connecting to attrd...");
|
||||
+ attrd = init_client_ipc_comms_nodispatch(T_ATTRD);
|
||||
+ if(attrd) {
|
||||
+ client_add(attrd->ops->get_recv_select_fd(attrd), NULL, attrd_deadfn);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if(attrd != NULL) {
|
||||
+ update = create_xml_node(NULL, __FUNCTION__);
|
||||
+ crm_xml_add(update, F_TYPE, T_ATTRD);
|
||||
+ crm_xml_add(update, F_ORIG, crm_system_name);
|
||||
+
|
||||
+ crm_xml_add(update, F_ATTRD_TASK, "update");
|
||||
+ crm_xml_add(update, F_ATTRD_SECTION, XML_CIB_TAG_STATUS);
|
||||
+ crm_xml_add(update, F_ATTRD_ATTRIBUTE, "terminate");
|
||||
+ crm_xml_add_int(update, F_ATTRD_VALUE, now);
|
||||
+ crm_xml_add(update, F_ATTRD_HOST, node->uname);
|
||||
+
|
||||
+ rc = send_ipc_message(attrd, update);
|
||||
+ free_xml(update);
|
||||
+ }
|
||||
+
|
||||
+ if(rc) {
|
||||
+ log_printf(LOG_INFO, "Requested that node %d/%s be kicked from the cluster", nodeid, node->uname);
|
||||
+ } else {
|
||||
+ log_printf(LOG_ERR, "Could not kick node %d/%s from the cluster", nodeid, node->uname);
|
||||
+ }
|
||||
+
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+cib_t *cib = NULL;
|
||||
+
|
||||
+static void cib_deadfn(int ci)
|
||||
+{
|
||||
+ log_printf(LOG_ERR, "Lost connection to the cib");
|
||||
+ cib = NULL; /* TODO: memory leak in unlikely error path */
|
||||
return;
|
||||
}
|
||||
|
||||
-int fence_node_time(int nodeid, uint64_t *last_fenced_time)
|
||||
+static cib_t *cib_connect(void)
|
||||
{
|
||||
- return 0;
|
||||
+ int rc = 0;
|
||||
+ int cib_fd = 0;
|
||||
+ if(cib) {
|
||||
+ return cib;
|
||||
+ }
|
||||
+
|
||||
+ cib = cib_new();
|
||||
+ rc = cib->cmds->signon_raw(cib, crm_system_name, cib_command, &cib_fd, NULL);
|
||||
+ if(rc != cib_ok) {
|
||||
+ log_printf(LOG_ERR, "Signon to cib failed: %s", cib_error2string(rc));
|
||||
+ cib = NULL; /* TODO: memory leak in unlikely error path */
|
||||
+
|
||||
+ } else {
|
||||
+ client_add(cib_fd, NULL, cib_deadfn);
|
||||
+ }
|
||||
+ return cib;
|
||||
}
|
||||
|
||||
-int fence_in_progress(int *count)
|
||||
+
|
||||
+int fence_in_progress(int *unused)
|
||||
{
|
||||
+ int rc = 0;
|
||||
+ xmlNode *xpath_data;
|
||||
+
|
||||
+ cib_connect();
|
||||
+ if(cib == NULL) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ /* TODO: Not definitive - but a good approximation */
|
||||
+ rc = cib->cmds->query(cib, "//nvpar[@name='terminate']", &xpath_data,
|
||||
+ cib_xpath|cib_scope_local|cib_sync_call);
|
||||
+
|
||||
+ log_printf(LOG_INFO, "Fencing in progress: %s", xpath_data?"true":"false");
|
||||
+
|
||||
+ if(xpath_data == NULL) {
|
||||
return 0;
|
||||
+ }
|
||||
+
|
||||
+ free_xml(xpath_data);
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
+#define XPATH_MAX 1024
|
||||
+
|
||||
+int fence_node_time(int nodeid, uint64_t *last_fenced_time)
|
||||
+{
|
||||
+ int rc = 0;
|
||||
+ xmlNode *xpath_data;
|
||||
+ char xpath_query[XPATH_MAX];
|
||||
+ crm_node_t *node = crm_get_peer(nodeid, NULL);
|
||||
+
|
||||
+ if(last_fenced_time) {
|
||||
+ *last_fenced_time = 0;
|
||||
+ }
|
||||
+
|
||||
+ if(node == NULL || node->uname == NULL) {
|
||||
+ log_printf(LOG_ERR, "Nothing known about node %d", nodeid);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ cib_connect();
|
||||
+ if(cib == NULL) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ snprintf(xpath_query, XPATH_MAX, "//lrm[@id='%s']", node->uname);
|
||||
+ rc = cib->cmds->query(
|
||||
+ cib, xpath_query, &xpath_data, cib_xpath|cib_scope_local|cib_sync_call);
|
||||
+
|
||||
+ if(xpath_data == NULL) {
|
||||
+ /* the node has been shot - return 'now' */
|
||||
+ log_printf(LOG_INFO, "Node %d/%s was last shot 'now'", nodeid, node->uname);
|
||||
+ *last_fenced_time = time(NULL);
|
||||
+ }
|
||||
+
|
||||
+ free_xml(xpath_data);
|
||||
+ log_printf(LOG_INFO, "It does not appear node %d/%s has been shot", nodeid, node->uname);
|
||||
+ return 0;
|
||||
+}
|
||||
|
||||
Reference in New Issue
Block a user