E
E
Eugene2019-03-20 15:21:37
High availability
Eugene, 2019-03-20 15:21:37

Why doesn't keepalived execute the notify script the first time it starts on the master?

At the first start (AWS, ASG - that is, manual intervention is undesirable, everything is automated as much as possible), the service starts on two machines. One becomes a master, the second a backup - everything is ok with the elections.
When changing the status (MASTER\BACKUP\FAULT\STOP), the notify.sh script is triggered in which these statuses are processed.
Issue: The NOTIFY script is not executed the first time MASTER is received. Logs from master:

Mar 20 11:53:50 ip-10-20-112-233 Keepalived[2770]: Opening file '/etc/keepalived/keepalived.conf'.
Mar 20 11:53:50 ip-10-20-112-233 systemd: Reloaded LVS and VRRP High Availability Monitor.
Mar 20 11:53:50 ip-10-20-112-233 Keepalived_healthcheckers[2771]: Got SIGHUP, reloading checker configuration
Mar 20 11:53:50 ip-10-20-112-233 Keepalived_healthcheckers[2771]: Opening file '/etc/keepalived/keepalived.conf'.
Mar 20 11:53:50 ip-10-20-112-233 Keepalived_vrrp[2772]: Registering Kernel netlink reflector
Mar 20 11:53:50 ip-10-20-112-233 Keepalived_vrrp[2772]: Registering Kernel netlink command channel
Mar 20 11:53:50 ip-10-20-112-233 Keepalived_vrrp[2772]: Registering gratuitous ARP shared channel
Mar 20 11:53:50 ip-10-20-112-233 Keepalived_vrrp[2772]: Opening file '/etc/keepalived/keepalived.conf'.
Mar 20 11:53:50 ip-10-20-112-233 Keepalived_vrrp[2772]: WARNING - default user 'keepalived_script' for script execution does not exist - please create.
Mar 20 11:53:50 ip-10-20-112-233 Keepalived_vrrp[2772]: SECURITY VIOLATION - scripts are being executed but script_security not enabled.
Mar 20 11:53:50 ip-10-20-112-233 Keepalived_vrrp[2772]: Using LinkWatch kernel netlink reflector...
Mar 20 11:53:50 ip-10-20-112-233 Keepalived_vrrp[2772]: VRRP sockpool: [ifindex(2), proto(112), unicast(1), fd(10,11)]
Mar 20 11:53:50 ip-10-20-112-233 Keepalived_vrrp[2772]: VRRP_Script(script1) succeeded
Mar 20 11:53:50 ip-10-20-112-233 Keepalived_vrrp[2772]: VRRP_Script(script2) succeeded
Mar 20 11:53:51 ip-10-20-112-233 Keepalived_vrrp[2772]: VRRP_Instance(VI_1) Transition to MASTER STATE
Mar 20 11:54:12 ip-10-20-112-233 dhclient[2251]: XMT: Solicit on eth0, interval 65330ms.
Mar 20 11:55:17 ip-10-20-112-233 dhclient[2251]: XMT: Solicit on eth0, interval 126690ms.
Mar 20 11:56:35 ip-10-20-112-233 systemd: Created slice User Slice of ec2-user.
Mar 20 11:56:35 ip-10-20-112-233 systemd: Starting User Slice of ec2-user.
Mar 20 11:56:35 ip-10-20-112-233 systemd-logind: New session 1 of user ec2-user.

Backup logs:
Mar 20 11:53:48 ip-10-20-111-140 systemd: Reloaded LVS and VRRP High Availability Monitor.
Mar 20 11:53:48 ip-10-20-111-140 Keepalived_healthcheckers[2765]: Got SIGHUP, reloading checker configuration
Mar 20 11:53:48 ip-10-20-111-140 Keepalived_healthcheckers[2765]: Opening file '/etc/keepalived/keepalived.conf'.
Mar 20 11:53:48 ip-10-20-111-140 Keepalived_vrrp[2766]: Registering Kernel netlink reflector
Mar 20 11:53:48 ip-10-20-111-140 Keepalived_vrrp[2766]: Registering Kernel netlink command channel
Mar 20 11:53:48 ip-10-20-111-140 Keepalived_vrrp[2766]: Registering gratuitous ARP shared channel
Mar 20 11:53:48 ip-10-20-111-140 Keepalived_vrrp[2766]: Opening file '/etc/keepalived/keepalived.conf'.
Mar 20 11:53:48 ip-10-20-111-140 Keepalived_vrrp[2766]: VRRP_Script(script1) considered successful on reload
Mar 20 11:53:48 ip-10-20-111-140 Keepalived_vrrp[2766]: VRRP_Script(script2) considered successful on reload
Mar 20 11:53:48 ip-10-20-111-140 Keepalived_vrrp[2766]: SECURITY VIOLATION - scripts are being executed but script_security not enabled.
Mar 20 11:53:48 ip-10-20-111-140 Keepalived_vrrp[2766]: Using LinkWatch kernel netlink reflector...
Mar 20 11:53:48 ip-10-20-111-140 Keepalived_vrrp[2766]: VRRP sockpool: [ifindex(2), proto(112), unicast(1), fd(10,11)]
Mar 20 11:53:49 ip-10-20-111-140 Keepalived_vrrp[2766]: VRRP_Instance(VI_1) Transition to MASTER STATE
Mar 20 11:53:51 ip-10-20-111-140 Keepalived_vrrp[2766]: VRRP_Instance(VI_1) Received advert with higher priority 100, ours 100
Mar 20 11:53:51 ip-10-20-111-140 Keepalived_vrrp[2766]: VRRP_Instance(VI_1) Entering BACKUP STATE
Mar 20 11:53:52 ip-10-20-111-140 root: triggering notify BACKUP event

line Mar 20 11:53:52 ip-10-20-111-140 root: triggering notify BACKUP event - a sign of the beginning of the script execution
keepalived config 1.3.5.8
vrrp_script script1{
}
vrrp_script script2{
}
vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 100 
    unicast_src_ip <LOCAL IP>
    authentication {
        auth_type PASS
        auth_pass <PASS>
    }
    unicast_peer {
    <REMOTE_IP>
    }
    track_script {
        script1
    }
    track_script {
        script2
    }
    track_interface {
        eth0
    }
    notify /etc/keepalived/notify.sh
}

If you go to the machine with your hands and restart the service, then everything continues to work like clockwork, the problem is precisely in the first, clean start.
Is there some kind of non-obvious feature of the service that is not described in the documentation? How to force keepalived to execute script on initial transition to master state?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question