3

I'm running keepalived under Debian (Lenny, Squeeze) in a fairly simple setup, I'm just (ab)using it as a VRRP daemon to decide the mastership between two equal machines for some virtual IPs. All the magic happens in the notify-script.

When I completely stop the daemon (using debian's init-script) keepalived does not run the notify-script for backup or at least fault mode, which is what I would suspect and need.

I could "fix" the rc-script with some unwanted effects - the notify-script would be hard-coded into the rc-script introducing an unwanted coupling of these two and the mess of porting the patch to the next debian versions so this is not the way I really want to go...

Any hints for a cleaner solution to this problem?

vrrp_instance FOORRP {
  virtual_router_id 42
  interface eth0
  state BACKUP
  priority 200
  nopreempt
  authentication {
    auth_type AH
    auth_pass foobar42
  }
  notify "/usr/local/bin/vrrp-state"
  virtual_ipaddress {
    127.0.0.2
  }
}

PS: the use of the "three notify_"-scripts does not change anything

PPS: in the changelog (Release 1.1.16) there is something mentioned, that somehow fits my problem (though I am not using anything lvs-related in keepalived), but I am using a newer version (1.1.20): "notify_down isn't executed for working real servers on keepalived shutdown."

3 Answers 3

6

Dug through more documentation and finally found it:

notify_stop "/usr/local/bin/vrrp-state fault"

Works as expected.... X-}

0

I faced such an issue recently and I found it is logical to not execute these scripts. These scripts get executed in case of specific events like becoming a master or slave. Keepalived process should not be shutdown unless it is done manually and there is a good reason to do so. If you are worried about failure in keepalived process (not the case of manually shutting it down), you can use monit. It is a great tool to monitor your running processes and restart them if anyone fails.

As you mentioned, you can simply modify the startup script of keepalived to execute the desired script (like stopping some other service). I think this will be cleaner than patching keepalived code, maintaining it yourself, and doing the necessary patch again each time you want to re-install/upgrade it.

2
  • I have a good reason to shutdown keepalived - maintainance! (I haven't seen keepalived crashing for years now, though I've seen it messing up. But thats not my point here.) And - as I wrote - editing the rc script is a technical solution but with unwanted administrative overhead. Finally: "not running these script" is no solution at all, since this script does all my failover stuff! (which is more than keepalived can do)
    – Michuelnik
    May 8, 2012 at 7:28
  • @Michuelnik: So, this will be part of your maintenance anyway. You can include this in keepalived startup script or run it manually.
    – Khaled
    May 8, 2012 at 7:30
0

You can use notify to get notified about these 5 state transitions:

  • MASTER
  • BACKUP
  • FAULT
  • STOP
  • DELETED

You can have a script to catch anyone of these:

#!/bin/bash

ENDSTATE=$3
NAME=$2
TYPE=$1

case $ENDSTATE in
    "BACKUP") # Perform action for transition to BACKUP state
              exit 0
              ;;
    "FAULT")  # Perform action for transition to FAULT state
              exit 0
              ;;
    "STOP")  # Perform action for transition to STOP state
              exit 0
              ;;
    "MASTER") # Perform action for transition to MASTER state
              exit 0
              ;;
    *)        echo "Unknown state ${ENDSTATE} for VRRP ${TYPE} ${NAME}"
              exit 1
              ;;
esac

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .