Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heartbeat 3.0.6 compatibility #637

Merged
merged 17 commits into from Feb 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 0 additions & 8 deletions Makefile.am
Expand Up @@ -64,14 +64,6 @@ if BUILD_CS_PLUGIN
rm -f $(DESTDIR)$(LCRSODIR)/pacemaker.lcrso $(DESTDIR)$(LCRSODIR)/service_crm.so
cp $(DESTDIR)$(libdir)/service_crm.so $(DESTDIR)$(LCRSODIR)/pacemaker.lcrso
endif
if BUILD_HEARTBEAT_SUPPORT
$(INSTALL) -d $(DESTDIR)/$(HB_DAEMON_DIR)
ln -sf $(CRM_DAEMON_DIR)/attrd $(DESTDIR)$(HB_DAEMON_DIR)/
ln -sf $(CRM_DAEMON_DIR)/cib $(DESTDIR)$(HB_DAEMON_DIR)/
ln -sf $(CRM_DAEMON_DIR)/crmd $(DESTDIR)$(HB_DAEMON_DIR)/
ln -sf $(CRM_DAEMON_DIR)/pengine $(DESTDIR)$(HB_DAEMON_DIR)/
ln -sf $(CRM_DAEMON_DIR)/stonithd $(DESTDIR)$(HB_DAEMON_DIR)/
endif
# Use chown because the user/group may not exist

clean-generic:
Expand Down
12 changes: 10 additions & 2 deletions cib/callbacks.c
Expand Up @@ -1358,6 +1358,14 @@ cib_client_status_callback(const char *node, const char *client, const char *sta
crm_node_t *peer = NULL;

if (safe_str_eq(client, CRM_SYSTEM_CIB)) {
peer = crm_get_peer(0, node);
if (safe_str_neq(peer->state, CRM_NODE_MEMBER)) {
crm_warn("This peer is not a ccm member (yet). "
"Status ignored: Client %s/%s announced status [%s]",
node, client, status);
return;
}

crm_info("Status update: Client %s/%s now has status [%s]", node, client, status);

if (safe_str_eq(status, JOINSTATUS)) {
Expand All @@ -1367,7 +1375,6 @@ cib_client_status_callback(const char *node, const char *client, const char *sta
status = OFFLINESTATUS;
}

peer = crm_get_peer(0, node);
crm_update_peer_proc(__FUNCTION__, peer, crm_proc_cib, status);
}
return;
Expand Down Expand Up @@ -1446,9 +1453,10 @@ cib_ccm_msg_callback(oc_ed_t event, void *cookie, size_t size, const void *data)
}

for (lpc = 0; lpc < membership->m_n_member; lpc++) {
crm_update_ccm_node(membership, lpc + membership->m_memb_idx, CRM_NODE_ACTIVE,
crm_update_ccm_node(membership, lpc + membership->m_memb_idx, CRM_NODE_MEMBER,
current_instance);
}
heartbeat_cluster->llc_ops->client_status(heartbeat_cluster, NULL, crm_system_name, 0);
}

if (ccm_api_callback_done == NULL) {
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Expand Up @@ -1823,6 +1823,7 @@ coverage.sh \
cts/Makefile \
cts/CTSvars.py \
cts/LSBDummy \
cts/HBDummy \
cts/benchmark/Makefile \
cts/benchmark/clubench \
cts/lxc_autogen.sh \
Expand Down
22 changes: 20 additions & 2 deletions crmd/control.c
Expand Up @@ -152,6 +152,24 @@ do_ha_control(long long action,
}
}

static bool
need_spawn_pengine_from_crmd(void)
{
static int result = -1;

if (result != -1)
return result;
if (!is_heartbeat_cluster()) {
result = 0;
return result;
}

/* NULL, or "strange" value: rather spawn from here. */
result = TRUE;
crm_str_to_boolean(daemon_option("crmd_spawns_pengine"), &result);
return result;
}

/* A_SHUTDOWN */
void
do_shutdown(long long action,
Expand All @@ -161,7 +179,7 @@ do_shutdown(long long action,
/* just in case */
set_bit(fsa_input_register, R_SHUTDOWN);

if (is_heartbeat_cluster()) {
if (need_spawn_pengine_from_crmd()) {
if (is_set(fsa_input_register, pe_subsystem->flag_connected)) {
crm_info("Terminating the %s", pe_subsystem->name);
if (stop_subsystem(pe_subsystem, TRUE) == FALSE) {
Expand Down Expand Up @@ -634,7 +652,7 @@ do_startup(long long action,
was_error = TRUE;
}

if (was_error == FALSE && is_heartbeat_cluster()) {
if (was_error == FALSE && need_spawn_pengine_from_crmd()) {
if (start_subsystem(pe_subsystem) == FALSE) {
was_error = TRUE;
}
Expand Down
23 changes: 20 additions & 3 deletions crmd/heartbeat.c
Expand Up @@ -246,8 +246,9 @@ do_ccm_update_cache(enum crmd_fsa_cause cause, enum crmd_fsa_state cur_state,

/*--*-- All Member Nodes --*--*/
for (lpc = 0; lpc < oc->m_n_member; lpc++) {
crm_update_ccm_node(oc, lpc + oc->m_memb_idx, CRM_NODE_ACTIVE, instance);
crm_update_ccm_node(oc, lpc + oc->m_memb_idx, CRM_NODE_MEMBER, instance);
}
heartbeat_cluster->llc_ops->client_status(heartbeat_cluster, NULL, crm_system_name, 0);
}

if (event == OC_EV_MS_EVICTED) {
Expand Down Expand Up @@ -393,7 +394,7 @@ crmd_ha_status_callback(const char *node, const char *status, void *private)

if (safe_str_eq(status, DEADSTATUS)) {
/* this node is toast */
crm_update_peer_proc(__FUNCTION__, peer, crm_proc_heartbeat, OFFLINESTATUS);
crm_update_peer_proc(__FUNCTION__, peer, crm_proc_crmd|crm_proc_heartbeat, OFFLINESTATUS);

} else {
crm_update_peer_proc(__FUNCTION__, peer, crm_proc_heartbeat, ONLINESTATUS);
Expand All @@ -419,12 +420,28 @@ crmd_client_status_callback(const char *node, const char *client, const char *st
return;
}

peer = crm_get_peer(0, node);

if (safe_str_neq(peer->state, CRM_NODE_MEMBER)) {
crm_warn("This peer is not a ccm member (yet). "
"Status ignored: Client %s/%s announced status [%s] (DC=%s)",
node, client, status, AM_I_DC ? "true" : "false");
return;
}

set_bit(fsa_input_register, R_PEER_DATA);

crm_notice("Status update: Client %s/%s now has status [%s] (DC=%s)",
node, client, status, AM_I_DC ? "true" : "false");

peer = crm_get_peer(0, node);
/* rest of the code, especially crm_update_peer_proc,
* does not know about JOINSTATUS, but expects ONLINESTATUS.
* See also cib/callbacks.c */
if (safe_str_eq(status, JOINSTATUS)) {
status = ONLINESTATUS;
} else if (safe_str_eq(status, LEAVESTATUS)) {
status = OFFLINESTATUS;
}

if (safe_str_eq(status, ONLINESTATUS)) {
/* remove the cached value in case it changed */
Expand Down
2 changes: 1 addition & 1 deletion crmd/membership.c
Expand Up @@ -155,7 +155,7 @@ do_update_node_cib(crm_node_t * node, int flags, xmlNode * parent, const char *s
crm_xml_add(node_state, XML_ATTR_UNAME, node->uname);

if (flags & node_update_cluster) {
if (safe_str_eq(node->state, CRM_NODE_ACTIVE)) {
if (safe_str_eq(node->state, CRM_NODE_MEMBER)) {
value = XML_BOOLEAN_YES;
} else if (node->state) {
value = XML_BOOLEAN_NO;
Expand Down
8 changes: 6 additions & 2 deletions crmd/te_utils.c
Expand Up @@ -295,8 +295,12 @@ te_connect_stonith(gpointer user_data)
}

if (user_data != NULL) {
crm_err("Sign-in failed: triggered a retry");
mainloop_set_trigger(stonith_reconnect);
if (is_set(fsa_input_register, R_ST_REQUIRED)) {
crm_err("Sign-in failed: triggered a retry");
mainloop_set_trigger(stonith_reconnect);
} else {
crm_info("Sign-in failed, but no longer required");
}
return TRUE;
}

Expand Down
127 changes: 127 additions & 0 deletions cts/HBDummy.in
@@ -0,0 +1,127 @@
#!/bin/sh
#
#
# Dummy Heartbeat RA. Does nothing but touch and remove a state file
#
# Copyright (c) 2015 Lars Ellenberg
#
# Based on LSBDummy,
# Copyright (c) 2010 Andrew Beekhof
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Further, this software is distributed without any warranty that it is
# free of the rightful claim of any third person regarding infringement
# or the like. Any license provided herein, whether implied or
# otherwise, applies only to this software file. Patent licenses, if
# any, provided herein do not apply to combinations of this program with
# other software, or any other product whatsoever.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
#

#######################################################################
# Initialization:

desc="Dummy Heartbeat service"
. @OCF_ROOT_DIR@/resource.d/heartbeat/.ocf-directories
: ${HA_VARRUN=/tmp} # Backup in case .ocf-directories doesn't exist

#######################################################################

success()
{
echo -ne "[ OK ]\r"
}

failure()
{
echo -ne "[FAILED]\r"
}

# rpm based distros
if [ -d @sysconfdir@/sysconfig ]; then
[ -f @INITDIR@/functions ] && . @INITDIR@/functions
[ -f @sysconfdir@/sysconfig/pacemaker ] && . @sysconfdir@/sysconfig/pacemaker
[ -z "$LOCK_FILE" ] && LOCK_FILE="@localstatedir@/lock/subsys/pacemaker"
fi

# deb based distros
if [ -d @sysconfdir@/default ]; then
[ -f @sysconfdir@/default/pacemaker ] && . @sysconfdir@/default/pacemaker
[ -z "$LOCK_FILE" ] && LOCK_FILE="@localstatedir@/lock/pacemaker"
fi

dummy_usage() {
cat <<END
usage: $0 dummyarg1 dummyarg2 {start|stop|status}

Dummy Heartbeat resource
END
}

dummy_start() {
echo -n "Starting $desc: "
touch ${state}
if [ -f ${state} ]; then
success
return 0
fi

failure
return 1
}

dummy_stop() {
echo -n "Stopping $desc: "
rm -f ${state}
if [ ! -f ${state} ]; then
success
return 0
fi

failure
return 1
}

dummy_monitor() {
if [ -f ${state} ]; then
echo "Running OK"
return 0
fi
echo "$desc is stopped"
return 3
}

# Positional arguments. Action is last. D'oh.

case $# in
3) dummy_arg_1=$1 dummy_arg_2=$2 action=$3 ;;
*)
dummy_usage
exit 1
;;
esac

state="${HA_VARRUN}/Dummy-`basename $0`-"$dummy_arg_1"-"$dummy_arg_2".state"

case $action in
start) dummy_start;;
stop) dummy_stop;;
status) dummy_monitor;;
*) dummy_usage
exit 1
;;
esac
rc=$?
echo "`basename $0` $1 : $rc"
exit $rc
3 changes: 2 additions & 1 deletion cts/Makefile.am
Expand Up @@ -19,7 +19,7 @@
#
MAINTAINERCLEANFILES = Makefile.in

CLEANFILES = LSBDummy
CLEANFILES = LSBDummy HBDummy

EXTRA_DIST = $(cts_SCRIPTS) $(cts_DATA)

Expand Down Expand Up @@ -48,6 +48,7 @@ cts_SCRIPTS = cts \
CTSlab.py \
lxc_autogen.sh \
LSBDummy \
HBDummy \
$(top_srcdir)/fencing/fence_dummy

SUBDIRS = benchmark
3 changes: 2 additions & 1 deletion cts/cts
Expand Up @@ -106,8 +106,9 @@ EOF
chmod +x $cts_root/crm_report

cp $cts_root/LSBDummy.in $cts_root/LSBDummy
cp $cts_root/HBDummy.in $cts_root/HBDummy
chmod +x $local_root/fencing/fence_*
sed -i.sed s:@OCF_ROOT_DIR@:/usr/lib/ocf: $cts_root/LSBDummy
sed -i.sed s:@OCF_ROOT_DIR@:/usr/lib/ocf: $cts_root/LSBDummy $cts_root/HBDummy

echo "Make sure you add $cts_root to your PATH and set a value for \$cluster_name in .bashrc"
exit 0
Expand Down
2 changes: 1 addition & 1 deletion doc/Clusters_from_Scratch/ro-RO/Ch-Apache.po
Expand Up @@ -205,7 +205,7 @@ msgstr "Actualizarea Configurației"
#. Tag: para
#, fuzzy, no-c-format
msgid "At this point, Apache is ready to go, all that needs to be done is to add it to the cluster. Lets call the resource WebSite. We need to use an OCF script called apache in the heartbeat namespace <footnote><para>Compare the key used here ocf:heartbeat:apache with the one we used earlier for the IP address: ocf:heartbeat:IPaddr2</para></footnote> , the only required parameter is the path to the main Apache configuration file and we’ll tell the cluster to check once a minute that apache is still running."
msgstr "La acest punct, Apache este gata de pornire, tot ce trebuie făcut este să îl adăugăm la cluster. Să denumim resursa WebSite. Avem nevoie să folosim un script OCF numit apache din namespace-ul <footnote> <para> Comparați cheia folosită aici, ocf:heartbeart:apache, cu cea folosită anterior pentru adresa IP: ocf:heartbeat:IPaddr2 </para> </footnote> heartbeat, singurul parametru necesar este calea către fișierul principal de configurare al Apache și vom spune clusterului să verifice o dată pe minut că apache încă funcționează."
msgstr "La acest punct, Apache este gata de pornire, tot ce trebuie făcut este să îl adăugăm la cluster. Să denumim resursa WebSite. Avem nevoie să folosim un script OCF numit apache din namespace-ul <footnote> <para> Comparați cheia folosită aici, ocf:heartbeat:apache, cu cea folosită anterior pentru adresa IP: ocf:heartbeat:IPaddr2 </para> </footnote> heartbeat, singurul parametru necesar este calea către fișierul principal de configurare al Apache și vom spune clusterului să verifice o dată pe minut că apache încă funcționează."

#. Tag: screen
#, no-c-format
Expand Down
21 changes: 21 additions & 0 deletions fencing/main.c
Expand Up @@ -1369,6 +1369,27 @@ main(int argc, char **argv)
stonith_our_uname = cluster.uname;
stonith_our_uuid = cluster.uuid;

#if SUPPORT_HEARTBEAT
if (is_heartbeat_cluster()) {
/* crm_cluster_connect() registered us for crm_system_name, which
* usually is the only F_TYPE used by the respective sub system.
* Stonith needs to register two additional F_TYPE callbacks,
* because it can :-/ */
if (HA_OK !=
cluster.hb_conn->llc_ops->set_msg_callback(cluster.hb_conn, T_STONITH_NOTIFY,
cluster.hb_dispatch, cluster.hb_conn)) {
crm_crit("Cannot set msg callback %s: %s", T_STONITH_NOTIFY, cluster.hb_conn->llc_ops->errmsg(cluster.hb_conn));
crm_exit(DAEMON_RESPAWN_STOP);
}
if (HA_OK !=
cluster.hb_conn->llc_ops->set_msg_callback(cluster.hb_conn, T_STONITH_TIMEOUT_VALUE,
cluster.hb_dispatch, cluster.hb_conn)) {
crm_crit("Cannot set msg callback %s: %s", T_STONITH_TIMEOUT_VALUE, cluster.hb_conn->llc_ops->errmsg(cluster.hb_conn));
crm_exit(DAEMON_RESPAWN_STOP);
}
}
#endif

if (no_cib_connect == FALSE) {
setup_cib();
}
Expand Down
3 changes: 2 additions & 1 deletion include/crm/cluster/internal.h
Expand Up @@ -107,7 +107,8 @@ peer2text(enum crm_proc_flag proc)
{
const char *text = "unknown";

if (proc == (crm_proc_cpg | crm_proc_crmd)) {
if (proc == (crm_proc_cpg | crm_proc_crmd)
|| proc == (crm_proc_heartbeat | crm_proc_crmd)) {
return "peer";
}

Expand Down