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

Mailing List Archive: Linux-HA: Dev

Firebird 2.5 Resource Agent

 

 

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


flazzarini at gmail

Nov 24, 2010, 4:38 AM

Post #1 of 9 (1098 views)
Permalink
Firebird 2.5 Resource Agent

Hi all,

I've written a Resource Agent for Firebird 2.5 Superclassic Server. The
RA has the common switches meta-data, start, stop, monitor, reload,
validate-all, usage|help. I've written the RA with the default values as
if you would install Firebird 2.5 manually using the packages available
at http://www.firebirdsql.org/index.php?op=files&id=engine_250 . I've
chosen these defaults as there are no debian/ubuntu packages that I know
of of Firebird 2.5 so far.

OCF_RESKEY_binary_default="/opt/firebird/bin/fbguard"
OCF_RESKEY_pid_default="/var/run/firebird/firebird.pid"
OCF_RESKEY_user_default="firebird"

For the RA to work all you need to do is to create a folder called
firebird readable/writeable by OCF_RESKEY_user in /var/run.


I hope that the RA meets the requirements, and does the job as
convenient as possible for most people.

Thanks
Attachments: firebird25 (5.45 KB)


florian.haas at linbit

Nov 24, 2010, 4:53 AM

Post #2 of 9 (1145 views)
Permalink
Re: Firebird 2.5 Resource Agent [In reply to]

Hi Frank,

Great contribution, thanks! RA looks pretty good overall; a few comments
inline:

On 2010-11-24 13:38, Frank Lazzarini wrote:
> #!/bin/sh
> #
> #
> # Firebird 2.5 OCF RA. Start Firebird 2.5 Superclassic server
> #
> #
> # Author: Frank Lazzarini
> #
> # Support: linux-ha [at] lists
> # License: GNU General Public License (GPL)
> # Copyright: (C) 2010 SitaSoftware S.A.
> #
> # See usage() function below for more details...
> #
> # OCF instance parameters:
> # OCF_RESKEY_binary
> # OCF_RESKEY_pid
> # OCF_RESKEY_user
> #
> #######################################################################
> # Initialization:
>
> : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/heartbeat}
> . ${OCF_FUNCTIONS_DIR}/.ocf-shellfuncs
>
> #######################################################################
>
> OCF_RESKEY_binary_default="/opt/firebird/bin/fbguard"
> OCF_RESKEY_pid_default="/var/run/firebird/firebird.pid"
> OCF_RESKEY_user_default="firebird"
>
> : ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
> : ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
> : ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
>
>
> meta_data() {
> cat <<END
> <?xml version="1.0"?>
> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
> <resource-agent name="firebird25" version="0.1">
> <version>1.0</version>

I realize the fact that we can specify the RA version twice is
redundant, but the version numbers should match. :)

> <longdesc lang="en">
> This is a Resource Agent for Firebird 2.5 Superclassic server. The resource agent
> simply starts fbguard with a few options. Fbguard is a process which starts the
> Firebird 2.5 Superclassic server namely fb_snmp_server process and guards this
> process.
> </longdesc>
> <shortdesc lang="en">Firebird 2.5 Superclassic Server Resource Agent.</shortdesc>
> <parameters>
> <parameter name="binary" unique="0" required="0">
> <shortdesc lang="en">Firebird 2.5 Guardian binary</shortdesc>
> <longdesc lang="en">Destination of the Firebird 2.5 Superclassic Guardian binary. (default: /opt/firebird/bin/fb_snmp_server)</longdesc>

You can just use:

<longdesc lang="en">Destination of the Firebird 2.5 Superclassic
Guardian binary. (default: $OCF_RESKEY_binary_default)</longdesc>

> <content type="string" default="$OCF_RESKEY_binary_default" />
> </parameter>
>
> <parameter name="pid" unique="0" required="0">
> <shortdesc lang="en">Firebird pid file</shortdesc>
> <longdesc lang="en">The pidfile to be used for fbguard (default: /var/run/firebird/firebird.pid)</longdesc>

As above.

> <content type="string" default="$OCF_RESKEY_pid_default" />
> </parameter>
>
> <parameter name="user" unique="0" required="0">
> <shortdesc lang="en">Firebird User</shortdesc>
> <longdesc lang="en">User running Firebird daemon (default: firebird)</longdesc>

As above.

> <content type="string" default="$OCF_RESKEY_user_default" />
> </parameter>
> </parameters>
>
> <actions>
> <action name="start" timeout="20" />
> <action name="stop" timeout="20" />

I assume you've tested that the agent really has the capability of
starting and stopping its daemon within 20 seconds?

> <action name="monitor" timeout="20" interval="10" depth="0" />
> <action name="reload" timeout="20" />
> <action name="migrate_to" timeout="20" />
> <action name="migrate_from" timeout="20" />

The RA does not support migrate_to and migrate_from, so you shouldn't be
advertising these.

> <action name="meta-data" timeout="5" />
> <action name="validate-all" timeout="20" />
> </actions>
> </resource-agent>
> END
> exit $OCF_SUCCESS
> }
>
> #######################################################################
>
> firebird25_usage() {
> cat <<END
> usage: $0 {start|stop|monitor|meta-data}
>
> END
> }
>
> firebird25_start() {
> # exit immediately if configuration is not valid
> firebird25_validate_all || exit $?
>
> # if resource is already running, bail out early
> if firebird25_monitor; then
> ocf_log info "Resource is already running"
> fi
>
> start-stop-daemon --start --quiet --oknodo --chuid $OCF_RESKEY_user --exec $OCF_RESKEY_binary -- -pidfile $OCF_RESKEY_pid -daemon -forever

Unfortunately start-stop-daemon is a Debian/Ubuntu-ism (it comes with
dpkg), so you'll have to change this to a distro independent invocation.

>
> return $OCF_SUCCESS
> }
>
> firebird25_stop() {
> local rc
>
> # exit immediately if configuration is not valid
> firebird25_validate_all || exit $?
>
> # check if firebird is running
> firebird25_monitor
> rc=$?
>
> case "$rc" in
> "$OCF_SUCCESS")
> ocf_log debug "Resource is currently running"
> ;;
> "$OCF_NOT_RUNNING")
> ocf_log info "Resource is already stopped"
> ;;
> esac
>
> if [ -f $OCF_RESKEY_pid ]
> then
> kill `cat $OCF_RESKEY_pid`
> if [ $? = 0 ]; then
> return $OCF_SUCCESS
> fi
> fi
>
> while firebird25_monitor; do
> ocf_log debug "Resource has not stopped yet, waiting"
> sleep 1
> done
>
> return $OCF_SUCCESS
> }
>
> firebird25_monitor() {
> local rc
> firebird25_validate_all

Sure you don't want to exit here if validation fails?

>
> # Return OCF_NOT_RUNNING if no pid was found
> if [ ! -e $OCF_RESKEY_pid ]; then
> ocf_log debug "Firebird is not running"
> return $OCF_NOT_RUNNING
> fi
>
> # Check if firebird is running
> # first get the pid from the pidfile and check with
> # kill -0 pid if the process is running with the right pid
> pid=`cat $OCF_RESKEY_pid`
> kill -0 $pid >/dev/null 2>&1

Minor bashism here, the generic way to do this is to use kill -s 0 $pid.

> rc=$?
>
> # Return OCF_SUCCESS if process is running
> # Return OCF_NOT_RUNNING if process is not running but pid exists
> if [ $rc -eq 0 ]; then
> return $OCF_SUCCESS
> else
> ocf_log debug "Firebird is not running: removing old PID file"
> rm -f $OCF_RESKEY_pid
> return $OCF_NOT_RUNNING
> fi
> }
>
> firebird25_validate_all() {
> # Checking the parameters
> # check if binary exists and is executable
> if [ ! -x $OCF_RESKEY_binary ]; then
> ocf_log err "fbguard binary $OCF_RESKEY_binary does not exist or is not executable"
> return $OCF_ERR_INSTALLED

No need to return the $OCF_ERR status; you can just exit and leave it to
Pacemaker to recover.

> fi
>
> # check if user exits
> getent passwd $OCF_RESKEY_user >/dev/null 2>&1
> if [ ! $? -eq 0 ]; then
> ocf_log err "User $OCF_RESKEY_user doesn't exist"
> return $OCF_ERR_INSTALLED

Same here.

> fi
> true
> }
>
> case $__OCF_ACTION in
> meta-data) meta_data
> exit $OCF_SUCCESS
> ;;
> start) firebird25_start;;
> stop) firebird25_stop;;
> monitor) firebird25_monitor;;
> reload) ocf_log err "Reloading..."
> firebird25_start
> ;;
> validate-all) firebird25_validate_all;;
> usage|help) firebird25_usage
> exit $OCF_SUCCESS
> ;;
> *) firebird25_usage
> exit $OCF_ERR_UNIMPLEMENTED
> ;;
> esac
> rc=$?
> ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
> exit $rc

Thanks again -- keep up the good work!

Cheers,
Florian
Attachments: signature.asc (0.26 KB)


flazzarini at gmail

Nov 24, 2010, 8:33 AM

Post #3 of 9 (1109 views)
Permalink
Re: Firebird 2.5 Resource Agent [In reply to]

Hi Florian,

thanks a lot for your quick reply, I fixed those little errors and added
a little feature that checks if the /var/run/firebird directory is
writeable by the OCF_RESKEY_user or not.

Hope this is better :)

Frank

On 24.11.2010 13:53, Florian Haas wrote:
> Hi Frank,
>
> Great contribution, thanks! RA looks pretty good overall; a few comments
> inline:
>
> On 2010-11-24 13:38, Frank Lazzarini wrote:
>> #!/bin/sh
>> #
>> #
>> # Firebird 2.5 OCF RA. Start Firebird 2.5 Superclassic server
>> #
>> #
>> # Author: Frank Lazzarini
>> #
>> # Support: linux-ha [at] lists
>> # License: GNU General Public License (GPL)
>> # Copyright: (C) 2010 SitaSoftware S.A.
>> #
>> # See usage() function below for more details...
>> #
>> # OCF instance parameters:
>> # OCF_RESKEY_binary
>> # OCF_RESKEY_pid
>> # OCF_RESKEY_user
>> #
>> #######################################################################
>> # Initialization:
>>
>> : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/heartbeat}
>> . ${OCF_FUNCTIONS_DIR}/.ocf-shellfuncs
>>
>> #######################################################################
>>
>> OCF_RESKEY_binary_default="/opt/firebird/bin/fbguard"
>> OCF_RESKEY_pid_default="/var/run/firebird/firebird.pid"
>> OCF_RESKEY_user_default="firebird"
>>
>> : ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
>> : ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
>> : ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
>>
>>
>> meta_data() {
>> cat<<END
>> <?xml version="1.0"?>
>> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
>> <resource-agent name="firebird25" version="0.1">
>> <version>1.0</version>
> I realize the fact that we can specify the RA version twice is
> redundant, but the version numbers should match. :)
>
>> <longdesc lang="en">
>> This is a Resource Agent for Firebird 2.5 Superclassic server. The resource agent
>> simply starts fbguard with a few options. Fbguard is a process which starts the
>> Firebird 2.5 Superclassic server namely fb_snmp_server process and guards this
>> process.
>> </longdesc>
>> <shortdesc lang="en">Firebird 2.5 Superclassic Server Resource Agent.</shortdesc>
>> <parameters>
>> <parameter name="binary" unique="0" required="0">
>> <shortdesc lang="en">Firebird 2.5 Guardian binary</shortdesc>
>> <longdesc lang="en">Destination of the Firebird 2.5 Superclassic Guardian binary. (default: /opt/firebird/bin/fb_snmp_server)</longdesc>
> You can just use:
>
> <longdesc lang="en">Destination of the Firebird 2.5 Superclassic
> Guardian binary. (default: $OCF_RESKEY_binary_default)</longdesc>
>
>> <content type="string" default="$OCF_RESKEY_binary_default" />
>> </parameter>
>>
>> <parameter name="pid" unique="0" required="0">
>> <shortdesc lang="en">Firebird pid file</shortdesc>
>> <longdesc lang="en">The pidfile to be used for fbguard (default: /var/run/firebird/firebird.pid)</longdesc>
> As above.
>
>> <content type="string" default="$OCF_RESKEY_pid_default" />
>> </parameter>
>>
>> <parameter name="user" unique="0" required="0">
>> <shortdesc lang="en">Firebird User</shortdesc>
>> <longdesc lang="en">User running Firebird daemon (default: firebird)</longdesc>
> As above.
>
>> <content type="string" default="$OCF_RESKEY_user_default" />
>> </parameter>
>> </parameters>
>>
>> <actions>
>> <action name="start" timeout="20" />
>> <action name="stop" timeout="20" />
> I assume you've tested that the agent really has the capability of
> starting and stopping its daemon within 20 seconds?
>
>> <action name="monitor" timeout="20" interval="10" depth="0" />
>> <action name="reload" timeout="20" />
>> <action name="migrate_to" timeout="20" />
>> <action name="migrate_from" timeout="20" />
> The RA does not support migrate_to and migrate_from, so you shouldn't be
> advertising these.
>
>> <action name="meta-data" timeout="5" />
>> <action name="validate-all" timeout="20" />
>> </actions>
>> </resource-agent>
>> END
>> exit $OCF_SUCCESS
>> }
>>
>> #######################################################################
>>
>> firebird25_usage() {
>> cat<<END
>> usage: $0 {start|stop|monitor|meta-data}
>>
>> END
>> }
>>
>> firebird25_start() {
>> # exit immediately if configuration is not valid
>> firebird25_validate_all || exit $?
>>
>> # if resource is already running, bail out early
>> if firebird25_monitor; then
>> ocf_log info "Resource is already running"
>> fi
>>
>> start-stop-daemon --start --quiet --oknodo --chuid $OCF_RESKEY_user --exec $OCF_RESKEY_binary -- -pidfile $OCF_RESKEY_pid -daemon -forever
> Unfortunately start-stop-daemon is a Debian/Ubuntu-ism (it comes with
> dpkg), so you'll have to change this to a distro independent invocation.
>
>> return $OCF_SUCCESS
>> }
>>
>> firebird25_stop() {
>> local rc
>>
>> # exit immediately if configuration is not valid
>> firebird25_validate_all || exit $?
>>
>> # check if firebird is running
>> firebird25_monitor
>> rc=$?
>>
>> case "$rc" in
>> "$OCF_SUCCESS")
>> ocf_log debug "Resource is currently running"
>> ;;
>> "$OCF_NOT_RUNNING")
>> ocf_log info "Resource is already stopped"
>> ;;
>> esac
>>
>> if [ -f $OCF_RESKEY_pid ]
>> then
>> kill `cat $OCF_RESKEY_pid`
>> if [ $? = 0 ]; then
>> return $OCF_SUCCESS
>> fi
>> fi
>>
>> while firebird25_monitor; do
>> ocf_log debug "Resource has not stopped yet, waiting"
>> sleep 1
>> done
>>
>> return $OCF_SUCCESS
>> }
>>
>> firebird25_monitor() {
>> local rc
>> firebird25_validate_all
> Sure you don't want to exit here if validation fails?
>
>> # Return OCF_NOT_RUNNING if no pid was found
>> if [ ! -e $OCF_RESKEY_pid ]; then
>> ocf_log debug "Firebird is not running"
>> return $OCF_NOT_RUNNING
>> fi
>>
>> # Check if firebird is running
>> # first get the pid from the pidfile and check with
>> # kill -0 pid if the process is running with the right pid
>> pid=`cat $OCF_RESKEY_pid`
>> kill -0 $pid>/dev/null 2>&1
> Minor bashism here, the generic way to do this is to use kill -s 0 $pid.
>
>> rc=$?
>>
>> # Return OCF_SUCCESS if process is running
>> # Return OCF_NOT_RUNNING if process is not running but pid exists
>> if [ $rc -eq 0 ]; then
>> return $OCF_SUCCESS
>> else
>> ocf_log debug "Firebird is not running: removing old PID file"
>> rm -f $OCF_RESKEY_pid
>> return $OCF_NOT_RUNNING
>> fi
>> }
>>
>> firebird25_validate_all() {
>> # Checking the parameters
>> # check if binary exists and is executable
>> if [ ! -x $OCF_RESKEY_binary ]; then
>> ocf_log err "fbguard binary $OCF_RESKEY_binary does not exist or is not executable"
>> return $OCF_ERR_INSTALLED
> No need to return the $OCF_ERR status; you can just exit and leave it to
> Pacemaker to recover.
>
>> fi
>>
>> # check if user exits
>> getent passwd $OCF_RESKEY_user>/dev/null 2>&1
>> if [ ! $? -eq 0 ]; then
>> ocf_log err "User $OCF_RESKEY_user doesn't exist"
>> return $OCF_ERR_INSTALLED
> Same here.
>
>> fi
>> true
>> }
>>
>> case $__OCF_ACTION in
>> meta-data) meta_data
>> exit $OCF_SUCCESS
>> ;;
>> start) firebird25_start;;
>> stop) firebird25_stop;;
>> monitor) firebird25_monitor;;
>> reload) ocf_log err "Reloading..."
>> firebird25_start
>> ;;
>> validate-all) firebird25_validate_all;;
>> usage|help) firebird25_usage
>> exit $OCF_SUCCESS
>> ;;
>> *) firebird25_usage
>> exit $OCF_ERR_UNIMPLEMENTED
>> ;;
>> esac
>> rc=$?
>> ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
>> exit $rc
> Thanks again -- keep up the good work!
>
> Cheers,
> Florian
>
>
>
> _______________________________________________________
> Linux-HA-Dev: Linux-HA-Dev [at] lists
> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/
Attachments: firebird25 (5.59 KB)


florian.haas at linbit

Nov 24, 2010, 8:38 AM

Post #4 of 9 (1077 views)
Permalink
Re: Firebird 2.5 Resource Agent [In reply to]

Thanks. One more minor issue: does it have to be named "firebird25"? If
it's called just "firebird", then it's fine for it to support version
only 2.5 forward -- but you won't need to rename when 2.x for x>5 comes out.

An additional option would be to package this with Firebird, of course.

Cheers,
Florian

On 2010-11-24 17:33, Frank Lazzarini wrote:
> Hi Florian,
>
> thanks a lot for your quick reply, I fixed those little errors and added
> a little feature that checks if the /var/run/firebird directory is
> writeable by the OCF_RESKEY_user or not.
>
> Hope this is better :)
>
> Frank
Attachments: signature.asc (0.26 KB)


flazzarini at gmail

Nov 24, 2010, 10:46 AM

Post #5 of 9 (1086 views)
Permalink
Re: Firebird 2.5 Resource Agent [In reply to]

Hi,

sure no problem we can name it firebird. Packaging it with the firebird
packages I don't really find a good idea, because not every user that needs
firebird 2.5 will use it in a cluster. Therefore I would appreciate it if it
would be packages with the pacemaker package, if that package includes all
the ocf RA's.

Thanks again for the support.

On Wed, Nov 24, 2010 at 5:38 PM, Florian Haas <florian.haas [at] linbit>wrote:

> Thanks. One more minor issue: does it have to be named "firebird25"? If
> it's called just "firebird", then it's fine for it to support version
> only 2.5 forward -- but you won't need to rename when 2.x for x>5 comes
> out.
>
> An additional option would be to package this with Firebird, of course.
>
> Cheers,
> Florian
>
> On 2010-11-24 17:33, Frank Lazzarini wrote:
> > Hi Florian,
> >
> > thanks a lot for your quick reply, I fixed those little errors and added
> > a little feature that checks if the /var/run/firebird directory is
> > writeable by the OCF_RESKEY_user or not.
> >
> > Hope this is better :)
> >
> > Frank
>
>
> _______________________________________________________
> Linux-HA-Dev: Linux-HA-Dev [at] lists
> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/
>
>


florian.haas at linbit

Nov 25, 2010, 12:31 AM

Post #6 of 9 (1080 views)
Permalink
Re: Firebird 2.5 Resource Agent [In reply to]

On 2010-11-24 19:46, Frank Lazzarini wrote:
> Hi,
>
> sure no problem we can name it firebird.

OK, firebird it is.

> Packaging it with the firebird
> packages I don't really find a good idea, because not every user that
> needs firebird 2.5 will use it in a cluster.

That's why there would typically be a subpackage RPM named
firebird-resource-agent or whatever, and no-one would be obliged to
install that.

> Therefore I would
> appreciate it if it would be packages with the pacemaker package, if
> that package includes all the ocf RA's.

It's not pacemaker, it's the resource-agents (on Debian: cluster-agents)
package, but sure, we can ship it.

> Thanks again for the support.

A few more issues I noticed:

1. you use sudo, any particular reason why you're not doing "su -c" like
all the other RAs do? Besides, you should add a check_binary test (for
either sudo or su) to your validate function.


2. Even if starting the daemon fails, you still pretend it succeeded:

> # start fbguard with the specified user
> sudo -u $OCF_RESKEY_user $OCF_RESKEY_binary -pidfile $OCF_RESKEY_pid -daemon -forever
>
> return $OCF_SUCCESS

You can either exit on error after sudo (with "|| exit
$OCF_ERR_GENERIC"), or spin on monitor after start, or both.


3. This too looks fishy:

>
> if [ -f $OCF_RESKEY_pid ]
> then
> kill `cat $OCF_RESKEY_pid`
> if [ $? = 0 ]; then
> return $OCF_SUCCESS
> fi

All that $? tells you is whether you were able to _send_ the signal. It
says nothing about whether the process did the right thing with the
signal, and it _certainly_ does not imply that the process shut down
completely. Returning successfully here is premature. Ditch that if
block. Because just below:

> fi
>
> while firebird25_monitor; do
> ocf_log debug "Resource has not stopped yet, waiting"
> sleep 1
> done

... you're doing the right thing and ask your monitor function to see if
the daemon is in fact dead (and if it's not, you wait till it is).


4. In monitor, you do this:

> pid=`cat $OCF_RESKEY_pid`
> kill -s 0 $pid >/dev/null 2>&1
> rc=$?

... and then test based on $rc. Now, kill -s 0 is generally fine to test
whether a process with that pid is currently running, but the problem
with that approach is that it _will_ succeed on a process that is a
zombie, which really is a failed resource. Thus, it's often a good idea
to combine this with an additional test, preferably one where you can
ask the daemon, or a client, whether the application is really
operational. Does Firebird offer such a facility?


5. There's an easier way to do this:

> if [ ! -x $OCF_RESKEY_binary ]; then
> ocf_log err "fbguard binary $OCF_RESKEY_binary does not exist or is not executable"
> exit $OCF_ERR_INSTALLED
> fi

You just replace those 4 lines with "check_binary $OCF_RESKEY_binary".


6. Also,
> getent passwd $OCF_RESKEY_user >/dev/null 2>&1
> if [ ! $? -eq 0 ]; then

can just be replaced with
if ! getent passwd $OCF_RESKEY_user >/dev/null 2>&1; then

...for additional brevity.

As far as I'm concerned, once you submit a version with these issues
fixed, this RA is in good shape to be merged. Lars, Dejan, and the other
usual suspects, if you have any objections to pushing this, please let
me know.

Cheers,
Florian
Attachments: signature.asc (0.26 KB)


flazzarini at gmail

Nov 25, 2010, 12:52 AM

Post #7 of 9 (1101 views)
Permalink
Re: Firebird 2.5 Resource Agent [In reply to]

Hi Florian,

I will have a look into this today, and fix these things. Thx for all
your comments.

Some comments inline...

On 25.11.2010 09:31, Florian Haas wrote:
> On 2010-11-24 19:46, Frank Lazzarini wrote:
>> Hi,
>>
>> sure no problem we can name it firebird.
> OK, firebird it is.
>
>> Packaging it with the firebird
>> packages I don't really find a good idea, because not every user that
>> needs firebird 2.5 will use it in a cluster.
> That's why there would typically be a subpackage RPM named
> firebird-resource-agent or whatever, and no-one would be obliged to
> install that.
>
Yes this would be an idea but I would really appreciate beeing in the
cluster-agents package.

>> Therefore I would
>> appreciate it if it would be packages with the pacemaker package, if
>> that package includes all the ocf RA's.
> It's not pacemaker, it's the resource-agents (on Debian: cluster-agents)
> package, but sure, we can ship it.
>
>> Thanks again for the support.
> A few more issues I noticed:
>
> 1. you use sudo, any particular reason why you're not doing "su -c" like
> all the other RAs do? Besides, you should add a check_binary test (for
> either sudo or su) to your validate function.
>
>
I had some problems using "su -c" but I think it was because the pidfile
couldn't be written,
the fbguard process isn't that clever on giving out some error messages
it just exits. Gonna
go and change that to su, or like you say check wether su or sudo exists.

> 2. Even if starting the daemon fails, you still pretend it succeeded:
>
>> # start fbguard with the specified user
>> sudo -u $OCF_RESKEY_user $OCF_RESKEY_binary -pidfile $OCF_RESKEY_pid -daemon -forever
>>
>> return $OCF_SUCCESS
> You can either exit on error after sudo (with "|| exit
> $OCF_ERR_GENERIC"), or spin on monitor after start, or both.
>
>
> 3. This too looks fishy:
>
>> if [ -f $OCF_RESKEY_pid ]
>> then
>> kill `cat $OCF_RESKEY_pid`
>> if [ $? = 0 ]; then
>> return $OCF_SUCCESS
>> fi
> All that $? tells you is whether you were able to _send_ the signal. It
> says nothing about whether the process did the right thing with the
> signal, and it _certainly_ does not imply that the process shut down
> completely. Returning successfully here is premature. Ditch that if
> block. Because just below:
>
>> fi
>>
>> while firebird25_monitor; do
>> ocf_log debug "Resource has not stopped yet, waiting"
>> sleep 1
>> done
> ... you're doing the right thing and ask your monitor function to see if
> the daemon is in fact dead (and if it's not, you wait till it is).
>
>
> 4. In monitor, you do this:
>
>> pid=`cat $OCF_RESKEY_pid`
>> kill -s 0 $pid>/dev/null 2>&1
>> rc=$?
> ... and then test based on $rc. Now, kill -s 0 is generally fine to test
> whether a process with that pid is currently running, but the problem
> with that approach is that it _will_ succeed on a process that is a
> zombie, which really is a failed resource. Thus, it's often a good idea
> to combine this with an additional test, preferably one where you can
> ask the daemon, or a client, whether the application is really
> operational. Does Firebird offer such a facility?
>
>
I am not really sure about this, the only thing I can think of is
something similar than the mysql
resource agent does, which is doing a sql on some Database system
tables, but Firebird
doesn't really offer that possibility as those tables only exist in the
databases it self, so if there
is no database currently attached to the firebird server I wouldn't have
these system tables. But
I will have a look into this, and maybe figure out a way to check this.


> 5. There's an easier way to do this:
>
>> if [ ! -x $OCF_RESKEY_binary ]; then
>> ocf_log err "fbguard binary $OCF_RESKEY_binary does not exist or is not executable"
>> exit $OCF_ERR_INSTALLED
>> fi
> You just replace those 4 lines with "check_binary $OCF_RESKEY_binary".
>
Alrighty didn't know of that function. Hmm this just gives me an idea,
remember I use a function to check wether the pid
directory is writable or not, wouldn't that be an idea to add to
.ocf-binaries ? Like I say just an idea.

> 6. Also,
>> getent passwd $OCF_RESKEY_user>/dev/null 2>&1
>> if [ ! $? -eq 0 ]; then
> can just be replaced with
> if ! getent passwd $OCF_RESKEY_user>/dev/null 2>&1; then
>
> ...for additional brevity.
>
> As far as I'm concerned, once you submit a version with these issues
> fixed, this RA is in good shape to be merged. Lars, Dejan, and the other
> usual suspects, if you have any objections to pushing this, please let
> me know.
>

I will get to it, this afternoon to correct these things :), once again
thx for all your comments.

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

Frank


florian.haas at linbit

Dec 14, 2010, 3:20 AM

Post #8 of 9 (999 views)
Permalink
Re: Firebird 2.5 Resource Agent [In reply to]

On 2010-11-25 09:52, Frank Lazzarini wrote:
> Hi Florian,
>
> I will have a look into this today, and fix these things. Thx for all
> your comments.

Frank,

is there an update for the resource agent you submitted?

Cheers,
Florian
Attachments: signature.asc (0.26 KB)


flazzarini at gmail

Dec 14, 2010, 3:36 AM

Post #9 of 9 (979 views)
Permalink
Re: Firebird 2.5 Resource Agent [In reply to]

Hey Florian,

no I actually haven't had time to finish up the updates that I did. The
last 2 weeks were a bit .... stressed at work. Gonna try to continue to
finish the RA during the upcoming weekend. At work I just don't have
time to do this, which sucks ... but yeah.

Sorry for not posting anything during a long time.

Cya
Frank

On 14.12.2010 12:20, Florian Haas wrote:
> On 2010-11-25 09:52, Frank Lazzarini wrote:
>> Hi Florian,
>>
>> I will have a look into this today, and fix these things. Thx for all
>> your comments.
> Frank,
>
> is there an update for the resource agent you submitted?
>
> Cheers,
> Florian
>
>
>
> _______________________________________________________
> 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.