VRRP master script not executing every-time

Hi all,

VyOS Version: 1.3-beta-202112050443

My VRRP master script doesn’t always get executed when switching to master.

I have two groups eth0 (WAN) and eth1 (LAN). VRRP failover works fine. I have created a sync-group called MAIN where I have placed the transition-script line. I have tested that it does work if I execute independently.

It also works if I attach the master script to the sync for just eth0, and then after reboot/process restart it stops working.

The show log vrrp - is not showing any errors. My script also has an output that shows up in the log when it has worked.

Same configuration below on both routers, different priorities (100, 200)

high-availability {
   vrrp {
     group eth0 {
        interface eth0
        no-preempt
        priority 100
        rfc3768-compatibility
        virtual-address <floating IP>
        vrid 10
       }
   group eth1 {
      interface eth1
      no-preempt
      priority 100
      rfc3768-compatibility
      virtual-address <Internal VIP IP>
      vrid 11
     }
   sync-group MAIN {
    member eth0
    member eth1
    transition-script {
      master /config/scripts/<my script name>.sh
      }
    }
   }
}

My script

#!/usr/bin/bash

RESERVED_IP_INSTANCE_ID='sanitized'
API_KEY='sanitized'
VM_INSTANCE_ID='sanitized'

#determine if the floating ip has been assigned
HAS_FLOATING_IP=`curl -s https://api.vultr.com/v2/reserved-ips/${RESERVED_IP_INSTANCE_ID} -X GET -H "Authorization: Bearer ${API_KEY}"`

#debug
logger -s ${HAS_FLOATING_IP}

#check to see if this instance has the floating ip
if [[ "${HAS_FLOATING_IP}" != *"${VM_INSTANCE_ID}"* ]]; then
  logger -s "This machine does not have a IP assigned to this machine already. Let's assign it."

#detach
`curl -s "https://api.vultr.com/v2/reserved-ips/${RESERVED_IP_INSTANCE_ID}/detach" \
-X POST \
-H "Authorization: Bearer ${API_KEY}"`

#attach
`curl -s "https://api.vultr.com/v2/reserved-ips/${RESERVED_IP_INSTANCE_ID}/attach" \
-X POST \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
-d "{\"instance_id\" : \"${VM_INSTANCE_ID}\"}"`

fi

logger -s "Completed IP failover"
exit

Hi @keneshhagard,

this is a known issue which was fixed yesterday (bug ⚓ T4041 "transition-script" doesn't work on "sync-group") please try the latest images from later today.

Ok awesome!! I thought I was going crazy. I tried 5 different ISO versions. Will this be on the 1.3 and 1.4 rolling?

Hello @keneshhagard , it already there

Hi -This is not still fully working. I used this ISO the latest 1.3 beta from yesterday (vyos-1.3-beta-202112060443-amd64.iso). Here is how I am testing it:

I setup the configuration above on two machines. Priority 200 for all interfaces on Machine A, Priority 100 for all interfaces on machine B. Script is saved in the /config/scripts with chmod +x. I run the script on bash to make sure it works.

I start pinging Machine A that has the Floating IP/WAN IP active:
→ Machine A (MASTER): ping works; restart vrrp
→ Ping drops for two packets and comes online, Machine B is now MASTER
→ Machine B (MASTER): ping works; restart vrrp
—> Ping drops for two packets and comes online, Machine A is now MASTER
—> show log vrrp on Machine A/Machine B - I see the output of my script in the show VRRP log (image below)

Running the same tests as above - if I just reboot the router from command line - the script never get executed anymore.

If I delete VRRP and set it up again it works OR if I delete the transition-script line, set it again, commit, save it works again For some reason the script setting is not persisting on reboot. I opened a ticket: ⚓ T4059 VRRP sync-group transition script does not persist after reboot

I’ve attached show log vrrp dump with the failover and script executing successfully when it does work (just to rule out it is not the script)

For anyone affected by the issue- this is my workaround until it is patched. I am just adding a line to restart the service right after bootup in the “/config/scripts/vyos-postconfig-bootup.script” (more info on this file in the command scripting section - Command Scripting — VyOS 1.4.x (sagitta) documentation)