Bug 1328018

Summary: garbd resource-agent
Product: Red Hat Enterprise Linux 7 Reporter: Damien Ciabrini <dciabrin>
Component: resource-agentsAssignee: Damien Ciabrini <dciabrin>
Status: CLOSED ERRATA QA Contact: Asaf Hirshberg <ahirshbe>
Severity: high Docs Contact:
Priority: high    
Version: 7.3CC: agk, cfeist, cluster-maint, fdinitto, mkrcmari, snagar
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: resource-agents-3.9.5-72.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1344225 (view as bug list) Environment:
Last Closed: 2016-11-04 00:02:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1296673, 1344225    

Description Damien Ciabrini 2016-04-18 08:52:46 UTC
Description of problem:

We need a resource-agent to manage garbd, the arbitrator for galera clusters.

Comment 4 Damien Ciabrini 2016-06-03 08:35:01 UTC
pull request upstream: https://github.com/ClusterLabs/resource-agents/pull/819

Comment 5 Damien Ciabrini 2016-06-03 10:37:49 UTC
Instruction for testing:

1. create a 3-node pacemaker cluster

pcs cluster setup --name garbd node1 node2 node3
pcs property set stonith-enabled=false

2. we'll run a 2-node galera + 1 garbd. choose a name for the galera
cluster and set in /etc/my.cnf.d/galera.cnf

# grep wsrep_cluster_name /etc/my.cnf.d/galera.cnf
wsrep_cluster_name="galeracluster"

3. the galera and garbd resource need coordination,they must start on
specific nodes and one after the other. prepare the commands in a file

pcs cluster cib garbd.xml

3.a. create the galera and garbd resources. the port number in
wsrep_cluster_address is mandatory, so is the galera cluster name

pcs -f garbd.xml resource create galera galera enable_creation=true wsrep_cluster_address='gcomm://node1,node2' meta master-max=2 ordered=true --master --disabled
pcs -f garbd.xml resource create garbd garbd wsrep_cluster_address='gcomm://node1:4567,node2:4567' wsrep_cluster_name="galeracluster"

3.b. prevent galera to run on node3, it will be for garbd garbd

pcs -f garbd.xml property set --node node3 arbitrator=1
pcs -f garbd.xml constraint location galera-master rule resource-discovery=exclusive score=0 not_defined arbitrator

3.c. make sure garbd starts after galera and do not run where galera runs

pcs -f garbd.xml constraint order promote galera-master then start garbd
pcs -f garbd.xml constraint colocation add garbd with galera-master -INFINITY

5. import the commands and start galera, garbd will start in sequence

pcs cluster cib-push garbd.xml
pcs resource enable galera-master

Once started, you can verify that the galera cluster includes the arbitrator

# mysql -e "show status like 'wsrep_cluster_size';"
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| wsrep_cluster_size | 3     |
+--------------------+-------+

Comment 8 Asaf Hirshberg 2016-06-13 03:17:24 UTC
Verified on RHEL-OSP director 9.0 puddle - 2016-06-03.1 
Using resource-agents-3.9.5-72.el7.x86_64

[heat-admin@overcloud-controller-0 ~]$ cat /usr/lib/ocf/resource.d/heartbeat/garbd 
#!/bin/sh
#
# Copyright (c) 2015 Damien Ciabrini <dciabrin>
#                    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.
#

##
# README.
#
# Resource agent for garbd, the Galera arbitrator
#
# You can use this agent if you run an even number of galera nodes,
# and you want an additional node to avoid split-brain situations.
#
# garbd requires that a Galera cluster is running, so make sure to
# add a proper ordering constraint to the cluster, e.g.:
#
#   pcs constraint order galera-master then garbd
#
# If you add garbd to the cluster while Galera is not running, you
# might want to disable it before setting up ordering constraint, e.g.:
#
#   pcs resource create garbd garbd \
#      wsrep_cluster_address=gcomm://node1:4567,node2:4567 \
#      meta target-role=stopped
#
# Use location constraints to avoid running galera and garbd on
# the same node, e.g.:
#
#   pcs constraint colocation add garbd with galera-master -INFINITY
#   pcs constraint location garbd prefers node3=INFINITY
#
##

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

: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs

#######################################################################
# Set default paramenter values

OCF_RESKEY_binary_default="/usr/sbin/garbd"
OCF_RESKEY_log_default="/var/log/garbd.log"
OCF_RESKEY_pid_default="/var/run/garbd.pid"
OCF_RESKEY_user_default="mysql"
if [ "X${HOSTOS}" = "XOpenBSD" ];then
    OCF_RESKEY_group_default="_mysql"
else
    OCF_RESKEY_group_default="mysql"
fi

: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_log=${OCF_RESKEY_log_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_group=${OCF_RESKEY_group_default}}

usage() {
  cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)

$0 manages a Galera arbitrator.
...
...
# What kind of method was invoked?
case "$1" in
  start)    garbd_start;;
  stop)     garbd_stop;;
  status)   garbd_status err;;
  monitor)  garbd_monitor err;;
  promote)  garbd_promote;;
  demote)   garbd_demote;;
  validate-all) exit $OCF_SUCCESS;;

 *)     usage
        exit $OCF_ERR_UNIMPLEMENTED;;
esac
[heat-admin@overcloud-controller-0 ~]$ 
[heat-admin@overcloud-controller-0 ~]$ rpm -qa |grep resource-agent
resource-agents-3.9.5-72.el7.x86_64

Comment 10 errata-xmlrpc 2016-11-04 00:02:42 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2174.html