Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux-HA: Dev

Re: [Pacemaker] bacula-fd resource agent available

 

 

Linux-HA dev RSS feed   Index | Next | Previous | View Threaded


dejanmm at fastmail

Dec 30, 2010, 10:03 AM

Post #1 of 2 (477 views)
Permalink
Re: [Pacemaker] bacula-fd resource agent available

Hi,

On Wed, Dec 29, 2010 at 07:39:58PM -0700, Devin Reade wrote:
> I've got an RA available for bacula-fd if anyone needs it. It's
> GPL'd, and if anyone wants to incorporate it into the resource-agents

Any chance to get this RA into the bacula repository and
distribute it along with that software?

> RPM, they are welcome to do so. (The 'anything' RA isn't quite sufficient
> for bacula-fd.) It is available at:
>
> ftp://ftp.gno.org/pub/tools/bacula-contrib
>
> See the README for details.

I'll review the RA next week.

Thanks,

Dejan

P.S. Moving the discussion to linux-ha-dev.

> Devin
>
>
> _______________________________________________
> Pacemaker mailing list: Pacemaker [at] oss
> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
>
> Project Home: http://www.clusterlabs.org
> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev [at] lists
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


dejanmm at fastmail

Jan 18, 2011, 10:10 AM

Post #2 of 2 (433 views)
Permalink
Re: [Pacemaker] bacula-fd resource agent available [In reply to]

Hi again,

On Thu, Dec 30, 2010 at 07:03:37PM +0100, Dejan Muhamedagic wrote:
> Hi,
>
> On Wed, Dec 29, 2010 at 07:39:58PM -0700, Devin Reade wrote:
> > I've got an RA available for bacula-fd if anyone needs it. It's
> > GPL'd, and if anyone wants to incorporate it into the resource-agents
>
> Any chance to get this RA into the bacula repository and
> distribute it along with that software?
>
> > RPM, they are welcome to do so. (The 'anything' RA isn't quite sufficient
> > for bacula-fd.) It is available at:
> >
> > ftp://ftp.gno.org/pub/tools/bacula-contrib
> >
> > See the README for details.
>
> I'll review the RA next week.

It took a while. Sorry for the delay. Here's the review:

> #!/bin/sh
> #
> # Resource script for the bacula file (client) daemon
> #
> # Description: Manages the bacula file daemon as an OCF resource in
> # an High Availability setup.
> #
> # Author: Devin Reade <gdr [at] gno>
> # Based on the rsync RA by Dhairesh Oza <odhairesh [at] novell>
> # License: GNU General Public License (GPL)
> #
> # usage: $0 {start|stop|status|monitor|validate-all|meta-data}
> #
> # The "start" arg starts bacula-fd.
> #
> # The "stop" arg stops it.
> #
> # OCF parameters:
> # OCF_RESKEY_binpath
> # OCF_RESKEY_conffile
> # OCF_RESKEY_user
> # OCF_RESKEY_group
> # OCF_RESKEY_pidfile
> #
> # Note:This RA requires that the bacula-fd config files are consistent
> # in their setup so that the PID file matches, and that the
> # "Pid Directory", "WorkingDirectory", and "FDPort" or "FDAddresses"
> # parameters are different from other bacula instances on the
> # cluster nodes.
> #
> ##########################################################################
> # Initialization:
>
> : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/heartbeat}
> . ${OCF_FUNCTIONS_DIR}/.ocf-shellfuncs
>
> USAGE="Usage: $0 {start|stop|status|monitor|validate-all|meta-data}";
>
> ##########################################################################
>
> usage()
> {
> echo $USAGE >&2
> }
>
> meta_data()
> {
> cat <<END
> <?xml version="1.0"?>
> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
> <resource-agent name="bacula-fd">
> <version>1.0</version>
> <longdesc lang="en">
> This script manages the bacula file (client) backup daemon
> </longdesc>
> <shortdesc lang="en">Manages a bacula file daemon</shortdesc>
>
> <parameters>
>
> <parameter name="binpath">
> <longdesc lang="en">
> The bacula-fd binary path.
> For example, /usr/sbin/bacula-fd
> </longdesc>
> <shortdesc lang="en">Full path to the bacula-fd binary</shortdesc>
> <content type="string" default="/usr/sbin/bacula-fd"/>
> </parameter>
>
> <parameter name="conffile">
> <longdesc lang="en">
> The bacula file daemon configuration file name with full path.
> For example, /etc/bacula/bacula-fd.conf
> </longdesc>
> <shortdesc lang="en">Configuration file name with full path</shortdesc>
> <content type="string" default="/etc/bacula/bacula-fd.conf" />
> </parameter>
>
> <parameter name="user">
> <longdesc lang="en">
> The effective user for running the daemon.
> </longdesc>
> <shortdesc lang="en">The effective user for running the daemon.</shortdesc>
> <content type="string" default="root"/>
> </parameter>
>
> <parameter name="group">
> <longdesc lang="en">
> The effective group for running the daemon.
> </longdesc>
> <shortdesc lang="en">The effective group for running the daemon.</shortdesc>
> <content type="string" default="bacula"/>
> </parameter>
>
> <parameter name="pidfile">
> <longdesc lang="en">
> The file containing the process ID. The filename will normally have
> the port number as part of the name, so ensure that this is consistent
> with your configuration file.
> </longdesc>
> <shortdesc lang="en">The PID file.</shortdesc>
> <content type="string" default="bacula"/>
> </parameter>
>
> </parameters>
>
> <actions>
> <action name="start" timeout="20s"/>
> <action name="stop" timeout="20s"/>
> <action name="monitor" depth="0" timeout="20s" interval="60s" />
> <action name="validate-all" timeout="20s"/>
> <action name="meta-data" timeout="5s"/>
> </actions>
> </resource-agent>
> END
> exit $OCF_SUCCESS
> }
>
> get_pid_and_conf_file()
> {
> if [ -n "$OCF_RESKEY_conffile" ]; then
> CONF_FILE=$OCF_RESKEY_conffile
> else
> CONF_FILE="/etc/bacula/bacula-fd.conf"
> fi

Stuff like this could be reduced to:

CONF_FILE=${OCF_RESKEY_conffile-"/etc/bacula/bacula-fd.conf"}

> if [ -n "$OCF_RESKEY_user" ]; then
> BACULA_USER=$OCF_RESKEY_user
> else
> BACULA_USER="root"
> fi
>
> if [ -n "$OCF_RESKEY_group" ]; then
> BACULA_GROUP=$OCF_RESKEY_group
> else
> BACULA_GROUP="bacula"
> fi
>
> if [ -n "$OCF_RESKEY_pidfile" ]; then
> PIDFILE=$OCF_RESKEY_pidfile
> else
> PIDFILE="/var/run/bacula-fd.9102.pid"
> fi
> }
>
> bacula_status()
> {
> if [ -n "$PIDFILE" -a -f $PIDFILE ]; then
> # bacula is probably running
> PID=`cat $PIDFILE`
> if [ -n "$PID" ]; then
> if ps -p $PID | grep bacula-fd >/dev/null ; then
> ocf_log info "bacula-fd daemon running"
> return $OCF_SUCCESS
> else
> ocf_log info "bacula-fd daemon is not running but pid file exists"
> return $OCF_ERR_GENERIC
> fi
> else
> ocf_log err "PID file empty!"
> return $OCF_ERR_GENERIC
> fi
> fi
>
> # bacula-fd is not running
> ocf_log info "bacula-fd daemon is not running"
> return $OCF_NOT_RUNNING

Does it ever happen that the daemon leaves without removing the
PID file? If so and if that shouldn't be considered an abnormal
condition then this code should change too. That could also
happen if the node was previously fenced. So, care should be
taken at least in case this is a probe (ocf_is_probe can help
here).

Also, someone/something removing the PID file is going to wreak
havoc. Perhaps better not to rely only on the PID file, but on
the process list.

> }
>
> bacula_start()
> {
> # if bacula-fd is running return success
> bacula_status
> retVal=$?
> if [ $retVal -eq $OCF_SUCCESS ]; then
> exit $OCF_SUCCESS
> elif [ $retVal -ne $OCF_NOT_RUNNING ]; then
> ocf_log err "Error. Unknown status."
> exit $OCF_ERR_GENERIC
> fi
>
> if [ -n "$OCF_RESKEY_binpath" ]; then
> COMMAND="$OCF_RESKEY_binpath"
> else
> COMMAND="/usr/sbin/bacula-fd"
> fi
>
> if [ -z "$CONF_FILE" ]; then
> echo "CONF_FILE not set"
> exit $OCF_ERR_GENERIC
> fi
> if [ -z "$BACULA_USER" ]; then
> echo "BACULA_USER not set"
> exit $OCF_ERR_GENERIC
> fi
> if [ -z "$BACULA_GROUP" ]; then
> echo "BACULA_GROUP not set"
> exit $OCF_ERR_GENERIC
> fi

This should go into validate_all function. The error should be
OCF_ERR_CONFIGURED.

> COMMAND="$COMMAND -c $CONF_FILE -u $BACULA_USER -g $BACULA_GROUP"
>
> if [ -r /etc/sysconfig/bacula ]; then
> . /etc/sysconfig/bacula
> fi

This is distribution specific. There are probably other distros
keeping defaults elsewhere (e.g. Debian). The resource agent
should support all distributions. The best practice for resource
agents is not to source these defaults, but to rely completely on
the configuration provided through parameters.

> # Disable Glibc malloc checks, it doesn't help and it keeps from
> # getting good dumps
> MALLOC_CHECK_=0
> export MALLOC_CHECK_
>
> OS=`uname -s`
>
> # if /lib/tls exists, force Bacula to use the glibc pthreads instead
> if [. -d "/lib/tls" -a $OS = "Linux" -a `uname -r | cut -c1-3` = "2.4" ] ; then
> LD_ASSUME_KERNEL=2.4.19
> export LD_ASSUME_KERNEL
> fi

Ugh. Is this necessary? Does it apply to _all_
distributions/releases/kernel_versions/what_have_you? Shouldn't
that be done elsewhere is it really Bacula specific?

> $COMMAND
> if [ $? -ne 0 ]; then
> ocf_log err "Error. bacula-fd daemon returned error $?."

This won't work. You need to save $? after $COMMAND.

> exit $OCF_ERR_GENERIC
> fi
>
> ocf_log info "Started bacula-fd daemon."
> exit $OCF_SUCCESS
> }
>
>
> bacula_stop()
> {
> if bacula_status ; then
> PID=`cat $PIDFILE`
> if [ -n "$PID" ] ; then
> kill $PID
> if [ $? -ne 0 ]; then
> kill -SIGKILL $PID
> if [ $? -ne 0 ]; then
> ocf_log err "Error. Could not stop bacula-fd daemon."
> return $OCF_ERR_GENERIC
> fi
> fi
> rm $PIDFILE 2>/dev/null
> fi
> fi
> ocf_log info "Stopped bacula-fd daemon."
> exit $OCF_SUCCESS

This should look different. After sending signal, there should be
a bacula_status loop until the daemon really exits.

> }
>
> bacula_monitor()
> {
> bacula_status
> }
>
> bacula_validate_all()
> {
> if [ -n "$OCF_RESKEY_binpath" -a ! -x "$OCF_RESKEY_binpath" ]; then
> ocf_log err "Binary path $OCF_RESKEY_binpath does not exist."
> exit $OCF_ERR_ARGS
> fi
> if [ -n "$OCF_RESKEY_conffile" -a ! -f "$OCF_RESKEY_conffile" ]; then
> ocf_log err "Config file $OCF_RESKEY_conffile does not exist."
> exit $OCF_ERR_ARGS
> fi
>
> if egrep -s -e "^$BACULA_USER:" /etc/passwd > /dev/null ; then
> :
> else
> ocf_log err "Error. Configured user \"$BACULA_USER\" does not exist in /etc/passwd."
> return $OCF_ERR_GENERIC
> fi
>
> if egrep -s -e "^$BACULA_GROUP:" /etc/group > /dev/null ; then
> :
> else
> ocf_log err "Error. Configured group \"$BACULA_GROUP\" does not exist in /etc/group."
> return $OCF_ERR_GENERIC
> fi

Use for all OCF_ERR_INSTALLED. It'd be better to exit with
OCF_ERR_CONFIGURED in case a required parameter is not set.
Though I see now that there are no required parameters, so just
use OCF_ERR_INSTALLED.

> return $OCF_SUCCESS
> }
>
>
> #
> # Main
> #
>
> if [ $# -ne 1 ]; then
> usage
> exit $OCF_ERR_ARGS
> fi
>
> case $1 in
> start) get_pid_and_conf_file
> bacula_start
> ;;
>
> stop) get_pid_and_conf_file
> bacula_stop
> ;;
>
> status) get_pid_and_conf_file
> bacula_status
> ;;
>
> monitor)get_pid_and_conf_file
> bacula_monitor
> ;;
>
> validate-all) get_pid_and_conf_file
> bacula_validate_all
> ;;
>
> meta-data) meta_data
> ;;
>
> usage) usage
> exit $OCF_SUCCESS
> ;;
>
> *) usage
> exit $OCF_ERR_UNIMPLEMENTED
> ;;
> esac

It would really be great if you can talk to bacula maintainers
and put the RA into their distribution. We already have a number
of resource agents and have difficulties to handle all of them
timely.

Cheers,

Dejan
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev [at] lists
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Linux-HA dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.