Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Plugin for running Bird route damon #170

Closed
wants to merge 4 commits into from

4 participants

@rafaltrojniak

This agnet supports running Bird route daemon with master-slave
architecture for managing IP failover using static routes

@rafaltrojniak rafaltrojniak Plugin for running Bird route damon
This agnet supports running Bird route daemon with master-slave
architecture for managing IP failover using static routes
52241bc
@fghaas

No need for this; we have ocf_is_ms.

@fghaas

Cut and paste error? Please update with a correct copyright notice.

@fghaas

Can you explain under what circumstances this should be run as a master/slave set, and under what it shouldn't? Most RAs either only make sense as primitives, or only as M/S sets.

@fghaas

Err, no. start shouldn't come back with $OCF_RUNNING_MASTER, only promote should.

@fghaas

Typo.

@fghaas

Nope. The config file may still be just fine on a different node; this has to return $OCF_ERR_INSTALLED.

@fghaas
Owner

Thanks for the submission. I wonder if you have taken a look at http://www.linux-ha.org/doc/dev-guides/ra-dev-guide.html -- if you haven't, please do so now and fix up the RA accordingly.

Note that we are just nearing a release, so this new addition may not get much attention until the release is cut. In that case, we will return to the review after that.

Looks like you're missing the point of validate_all. Also, the meaning of the various OCF exit codes, in particular OCF_ERR_CONFIGURED.

Please read the development guide, as already suggested by fghaas. If there's anything unclear, ask on the linux-ha-dev mailing list.

@rafaltrojniak

Thanks for your comments and feedback.
As suggested, I fixed most of the commented code. Also, there is more info on meta action when, and how to use this agent in master-slave mode.

To the comment on start action and RUNNING_MASTER state - I'm retturning OCF_SUCCESS, not RUNNING_MASTER, so it is as you worte.

I'm using dev-guide while developing this resource agents (this is my first one), but nothing in clear on the first-shot.

Thank you for your attention time and feedback.

@dmuhamedagic

OCF_ERR_CONFIGURED is used when a particular RA is not well configured (usually missing parameters). This should probably return "err_generic".

@dmuhamedagic

Again, OCF_ERR_CONFIGURED should be returned only in validate_all. It can be caused only by the static RA configuration, as defined by the user, not by the current system state.

@dmuhamedagic

Probably won't make any difference, but it would be correct to do "return $ret" here.

@dmuhamedagic

This comment is misleading.

@dmuhamedagic

This is the stop action. Update comment.

@dmuhamedagic

This comment seems to be misplaced.

@dmuhamedagic

Is this parameter supposed to be unique?

@dmuhamedagic

Hmm, why is this OCF_ERR_CONFIGURED? This check is superfluous. Isn't the RA supposed to also start the daemon?

@dmuhamedagic

This parameter is not required. It is only used iff the RA runs as ms.

@dmuhamedagic

This check doesn't belong here.

@dmuhamedagic

The next resource-agents release happens next week. Please fix the issues if you want it merged beforehand. Thanks!

@dmuhamedagic
Owner

@rafaltrojniak no news here for a long time. Do you want to bring this to a state in which it can be merged? Thanks!

@rafaltrojniak

Hey, thanks for the bumping this task up.
Currently it is not my priority to make this working, but I implement most of Your comments in some time.
This can take one or two months, after my current, urgent and high priority project will be completed.

@dmuhamedagic
Owner

@rafaltrojniak still no news. Note that there'll be a release mid January.

@rafaltrojniak

I'm sorry, but I am not able to test it with my current resources, or maintain this. It looks like I have to drop this project.

Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 6, 2012
  1. @rafaltrojniak

    Plugin for running Bird route damon

    rafaltrojniak authored
    This agnet supports running Bird route daemon with master-slave
    architecture for managing IP failover using static routes
Commits on Nov 7, 2012
  1. @rafaltrojniak
Commits on Sep 3, 2013
  1. @jkramarz

    typo fix in Bird

    jkramarz authored
Commits on Nov 30, 2013
  1. @rafaltrojniak

    Merge pull request #1 from jkramarz/patch-1

    rafaltrojniak authored
    typo fix in Bird
This page is out of date. Refresh to see the latest.
Showing with 297 additions and 0 deletions.
  1. +1 −0  doc/man/Makefile.am
  2. +295 −0 heartbeat/Bird
  3. +1 −0  heartbeat/Makefile.am
View
1  doc/man/Makefile.am
@@ -57,6 +57,7 @@ metadata-IPv6addr.xml: ../../heartbeat/IPv6addr
if BUILD_DOC
man_MANS = ocf_heartbeat_AoEtarget.7 \
ocf_heartbeat_AudibleAlarm.7 \
+ ocf_heartbeat_Bird.7 \
ocf_heartbeat_ClusterMon.7 \
ocf_heartbeat_CTDB.7 \
ocf_heartbeat_Delay.7 \
View
295 heartbeat/Bird
@@ -0,0 +1,295 @@
+#!/bin/sh
+#
+# OCF Resource Agent compliant resource script.
+#
+# Copyright (c) 2012 Rafał Trojniak resource-agents@trojniak.net
+#
+# 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.
+
+# History :
+# - Forked from anything plugin to Bird plugin
+#
+# Authors :
+# Rafał Trójniak resource-agents@trojniak.net
+# OCF instance parameters
+#
+
+# Initialization:
+: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/heartbeat}
+. ${OCF_FUNCTIONS_DIR}/.ocf-shellfuncs
+
+bird_ping() {
+ birdc "show protocols" >/dev/null
+}
+
+bird_static_configured() {
+ ! birdc "show protocols" |
+ awk "\$1==\"$OCF_RESKEY_name\" && \$2==\"Static\" {exit 1}"
+}
+
+bird_static_status() {
+ ! birdc "show protocols" |
+ awk "\$1==\"$OCF_RESKEY_name\" && \$2==\"Static\" && \$4==\"up\" {exit 1}"
+}
+
+# Returns:
+# OCF_RUNNING_MASTER - when bird_is_ms is true, and static route is up
+# OCF_SUCCESS - when bird_is_ms is false and bird pings, when bird_is_ms is true and static route is down
+# OCF_NOT_RUNNING - when bird doesn't pings
+# OCF_ERR_CONFIGURED - when bird pings and static route is not configured
+bird_status() {
+ if bird_ping
+ then
+ if ocf_is_ms ; then
+ if bird_static_configured
+ then
+ if bird_static_status
+ then
+ return $OCF_RUNNING_MASTER
+ else
+ return $OCF_SUCCESS
+ fi
+ else
+ return $OCF_ERR_CONFIGURED
+ fi
+ else
+ return $OCF_SUCCESS
+ fi
+ else
+ return $OCF_NOT_RUNNING
+ fi
+}
+
+
+bird_start() {
+ bird_status
+ ret=$?
+ [ $ret = $OCF_ERR_CONFIGURED ] && return $OCF_ERR_CONFIGURED
+ if [ $ret = $OCF_NOT_RUNNING ]
+ then
+ ocf_log info "Starting Bird"
+ # Execute the command as created above
+ ocf_run bird
+
+ # Waiting for start
+ while /bin/true ; do
+ bird_status
+ ret=$?
+ [ $ret = $OCF_ERR_CONFIGURED ] && return $OCF_ERR_CONFIGURED
+ [ $ret = $OCF_SUCCESS ] && return $OCF_SUCCESS
+ [ $ret = $OCF_RUNNING_MASTER ] && return $OCF_SUCCESS
+ [ $ret != $OCF_NOT_RUNNING ] && return $OCF_ERR_GENERIC
+ sleep 1
+ done
+ return $OCF_ERR_GENERIC
+ else
+ # If already running, consider start successful
+ ocf_log info "$process: $cmd is already running"
+ return $OCF_SUCCESS
+ fi
+}
+
+bird_stop() {
+ bird_status
+ ret=$?
+ [ $ret = $OCF_ERR_CONFIGURED ] && return $OCF_ERR_CONFIGURED
+ if [ $ret = $OCF_SUCCESS -o $ret = $OCF_RUNNING_MASTER ]
+ then
+ ocf_log info "Stopping Bird"
+ # Execute the command as created above
+ ocf_run birdc down
+
+ # Waiting for stopping bird
+ while /bin/true ; do
+ bird_status
+ ret=$?
+ [ $ret = $OCF_NOT_RUNNING ] && return $OCF_SUCCESS
+ [ $ret = $OCF_ERR_CONFIGURED ] && return $OCF_ERR_CONFIGURED
+ [ $ret != $OCF_SUCCESS -a $ret != $OCF_RUNNING_MASTER ] && return $OCF_ERR_GENERIC
+ sleep 1
+ done
+ return $OCF_ERR_GENERIC
+ else
+ # If already running, consider start successful
+ ocf_log info "$process: $cmd is already stopped"
+ return $OCF_SUCCESS
+ fi
+}
+
+bird_promote() {
+ bird_status
+ ret=$?
+ [ $ret = $OCF_RUNNING_MASTER ] && return $OCF_SUCCESS
+ [ $ret = $OCF_NOT_RUNNING ] && return $OCF_NOT_RUNNING
+ [ $ret = $OCF_ERR_CONFIGURED ] && return $OCF_ERR_CONFIGURED
+ if [ $ret = $OCF_SUCCESS ]
+ then
+ ocf_log info "BIRD: Enabling static route '$OCF_RESKEY_name'"
+ ocf_run birdc "enable $OCF_RESKEY_name"
+
+ # Waiting for stopping bird
+ while /bin/true ; do
+ bird_status
+ ret=$?
+ [ $ret = $OCF_NOT_RUNNING ] && return $OCF_NOT_RUNNING
+ [ $ret = $OCF_ERR_CONFIGURED ] && return $OCF_ERR_CONFIGURED
+ [ $ret = $OCF_RUNNING_MASTER ] && return $OCF_SUCCESS
+ [ $ret != $OCF_SUCCESS ] && return $OCF_ERR_GENERIC
+ sleep 1
+ done
+ else
+ # If already running, consider start successful
+ ocf_log err "Unknown error - got $ret from status"
+ return $OCF_ERR_GENERIC
+ fi
+}
+
+bird_demote() {
+ bird_status
+ ret=$?
+ [ $ret = $OCF_SUCCESS ] && return $OCF_SUCCESS
+ [ $ret = $OCF_NOT_RUNNING ] && return $OCF_NOT_RUNNING
+ [ $ret = $OCF_ERR_CONFIGURED ] && return $OCF_ERR_CONFIGURED
+ if [ $ret = $OCF_RUNNING_MASTER ]
+ then
+ ocf_log info "BIRD: Disabling static route '$OCF_RESKEY_name'"
+ ocf_run birdc "disable $OCF_RESKEY_name"
+
+ # Waiting for stopping bird
+ while /bin/true ; do
+ bird_status
+ ret=$?
+ [ $ret = $OCF_NOT_RUNNING ] && return $OCF_NOT_RUNNING
+ [ $ret = $OCF_ERR_CONFIGURED ] && return $OCF_ERR_CONFIGURED
+ [ $ret = $OCF_SUCCESS ] && return $OCF_SUCCESS
+ [ $ret != $OCF_RUNNING_MASTER ] && return $OCF_ERR_GENERIC
+ sleep 1
+ done
+ else
+ # If already running, consider start successful
+ ocf_log err "Unknown error - got $ret from status"
+ return $OCF_ERR_GENERIC
+ fi
+}
+
+bird_validate() {
+
+ if ! have_binary bird ; then
+ ocf_log err "Failed to find bird"
+ return $OCF_ERR_INSTALLED
+ fi
+
+ if ! bird -p ; then
+ ocf_log err "Bird configuration file seems to be broken"
+ return $OCF_ERR_INSTALLED
+ fi
+
+ if [ -z "$OCF_RESKEY_name" ] ; then
+ ocf_log err "No name parameter configured"
+ return $OCF_ERR_CONFIGURED
+ fi
+
+ if ! have_binary birdc ; then
+ ocf_log err "Failed to find birdc"
+ return $OCF_ERR_INSTALLED
+ fi
+
+ if ! bird_ping ; then
+ ocf_log err "Failed to get status using birdc"
+ return $OCF_ERR_CONFIGURED
+ fi
+
+ if ! bird_static_configured ; then
+ ocf_log err "Failed to get status of static '$OCF_RESKEY_name'"
+ return $OCF_ERR_INSTALLED
+ fi
+ return $OCF_SUCCESS
+}
+
+bird_meta() {
+cat <<END
+<?xml version="1.0"?>
+<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
+<resource-agent name="Bird">
+ <version>1.0</version>
+ <longdesc lang="en">
+ This agent manages Bird routing daemon.
+
+ When used in standard mode (primitive resource) just manages
+ (starts and stops) BIRD routing daemon
+
+ When used in master-slave configuration, besides from starting/stopping daemon
+ allows to fail-over (enable on promote, disable on demote)
+ static defined route. Make sure, that this static route is disabled by default.
+ </longdesc>
+ <shortdesc lang="en">Manages Bird routing daemon</shortdesc>
+
+ <parameters>
+ <parameter name="name">
+ <longdesc lang="en">
+ Static route name as defined in bird.
+ This route should be disabled by default.
+ It will be enabled when this resource will be started.
+ </longdesc>
+ <shortdesc lang="en">Static route name</shortdesc>
+ <content type="string" default=""/>
+ </parameter>
+ </parameters>
+ <actions>
+ <action name="start" timeout="20s" />
+ <action name="stop" timeout="20s" />
+ <action name="promote" timeout="20s" />
+ <action name="demote" timeout="20s" />
+ <action name="monitor" depth="0" timeout="20s" interval="10" />
+ <action name="meta-data" timeout="5" />
+ <action name="validate-all" timeout="5" />
+ </actions>
+</resource-agent>
+END
+exit 0
+}
+
+case "$1" in
+ meta-data|metadata|meta_data)
+ bird_meta
+ ;;
+ start)
+ bird_start
+ ;;
+ stop)
+ bird_stop
+ ;;
+ promote)
+ bird_promote
+ ;;
+ demote)
+ bird_demote
+ ;;
+ monitor)
+ bird_status
+ ;;
+ validate-all)
+ bird_validate
+ ;;
+ *)
+ ocf_log err "$0 was called with unsupported arguments: $*"
+ exit $OCF_ERR_UNIMPLEMENTED
+ ;;
+esac
View
1  heartbeat/Makefile.am
@@ -58,6 +58,7 @@ ocf_SCRIPTS = ClusterMon \
asterisk \
nginx \
AudibleAlarm \
+ Bird \
conntrackd \
db2 \
dhcpd \
Something went wrong with that request. Please try again.