Page MenuHomeVyOS Platform

Execute VRRP transition script when `set high-availability disable` is commited
Needs reporter action, WishlistPublicFEATURE REQUEST

Description

In T5060 I suggested to implement something like a "VRRP maintenance mode". Thank you again for implementing this feature!

Part of the VRRP configuration in one of our testing environments looks like this:

sync-group main {
    member com
    member mgmt
    member adm
    member apm
    member byod
    member dflt
    member gst
    member gyod
    member prn
    member rol
    member srv01
    member stdnt
    member stf
    member tchr
    member tr_scl
    member prs
    transition-script {
        backup /config/scripts/ha/vrrp-backup.sh
        fault /config/scripts/ha/vrrp-fault.sh
        master /config/scripts/ha/vrrp-master.sh
        stop /config/scripts/ha/vrrp-stop.sh
    }
}

Transition scripts work perfectly fine when transitioning from MASTER to BACKUP and vice-versa. However, no transition script is executed when disabling keepalived through set high-availability disable.

It would be nice if committing set high-availability disable would also execute the stop transition script.

Details

Difficulty level
Unknown (require assessment)
Version
-
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Improvement (missing useful functionality)

Event Timeline

Maybe it is the wrong way. I think it shouldn't touch anything in the disable state.

Hmm, fair enough. Maybe just executing the stop script and then committing set high-availability disable is enough for maintenance periods.
One general question though out of curiosity: What are the circumstances in which the stop script is executed in the first place?

dmbaturin triaged this task as Wishlist priority.Jan 11 2024, 11:51 AM
dmbaturin added a project: VyOS 1.5 Circinus.
Viacheslav changed the task status from Open to Needs reporter action.EditedThu, Apr 11, 11:19 AM

Just to make sure: This change is part of the current nightly build, right?

Just checked with the current rolling release 1.5-rolling-202404141045. After committing set high-availability disable, keepalived is successfully stopped and the logs show that the transition script seems to be executed:

Apr 17 15:48:57 keepalived-fifo.py[20707]: GROUP main changed state to STOP
Apr 17 15:48:57 keepalived-fifo.py[20707]: Running the command: /config/scripts/ha/vrrp-stop.sh
Apr 17 15:48:58 systemd[1]: opt-vyatta-config-tmp-new_config_27850.mount: Deactivated successfully.
Apr 17 15:48:58 keepalived-fifo.py[20707]: Terminating messages processing thread
Apr 17 15:48:58 keepalived-fifo.py[20707]: Ending processing: Received SIGTERM signal
Apr 17 15:48:58 Keepalived_vrrp[20705]: Stopped
Apr 17 15:48:58 Keepalived[20701]: Stopped Keepalived v2.2.8 (06/21,2023), git commit debian/1%2.2.8-1+
Apr 17 15:48:58 systemd[1]: keepalived.service: Deactivated successfully.
Apr 17 15:48:58 systemd[1]: Stopped keepalived.service - Keepalive Daemon (LVS and VRRP).
Apr 17 15:48:58 systemd[1]: keepalived.service: Consumed 8.509s CPU time.

However, something goes wrong as the execution of the script seems to have no effect. It is supposed to stop some containers, which works perfectly fine when transitioning to BACKUP (backup and stop script are the same). It looks like this:

#!/bin/vbash

if [ "$(id -g -n)" != 'vyattacfg' ] ; then
    exec sg vyattacfg -c "/bin/vbash $(readlink -f $0) $@"
fi

source /opt/vyatta/etc/functions/script-template
configure
set container name zabbix-proxy disable
set container name haproxy disable
set service dhcp-relay disable
commit comment "VRRP backup transition"
exit