acassen / keepalived

Keepalived
https://www.keepalived.org
GNU General Public License v2.0
3.96k stars 737 forks source link

What is the correct way to disable preempt for keepalived #2379

Closed geotransformer closed 8 months ago

geotransformer commented 8 months ago

Describe the bug Use nopreempt option. However, vip is not switching into other healthy node although first node with VIP goes fault state . States are tracked by track_script in my case.

Initial asking https://access.redhat.com/discussions/3029791

       # VRRP will normally preempt a lower priority
       # machine when a higher priority machine comes
       # online.  "nopreempt" allows the lower priority
       # machine to maintain the master role, even when
       # a higher priority machine comes back online.
       # NOTE: For this to work, the initial state of this
       # entry must be BACKUP.
       nopreempt

To Reproduce vrrp_script check_api { script "/etc/keepalived/check_api.sh" interval 1 #check every second weight 50 rise 3 # required number of successes for OK transition fall 2 # required number of successes for KO transition init_fail # assume script initially is in failed state }

track_script { check_api }

Expected behavior If the node with VIP consistently failed the track_script, the VIP should move

Keepalived version

Keepalived v2.0.19 (10/19,2019)

Distro (please complete the following information): NAME="Ubuntu" VERSION="20.04.6 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.6 LTS" VERSION_ID="20.04" HOME_URL="https://

Details of any containerisation or hosted service (e.g. AWS) If keepalived is being run in a container or on a hosted service, provide full details

Configuration file:

! Configuration File for keepalived
global_defs {
    vrrp_netlink_monitor_rcv_bufs 1048576
}
vrrp_script check_api {
    script "/etc/keepalived/check_api.sh"
    interval 1        #check every second
    weight 50
    rise 3            # required number of successes for OK transition
    fall 2            # required number of successes for KO transition
    init_fail         # assume script initially is in failed state
}
#vrrp instance config
vrrp_instance VI_1 {
    nopreempt
    state BACKUP
    priority 50
    interface ens192
    virtual_router_id 183
    advert_int 1
    garp_master_refresh 30
    garp_master_refresh_repeat 1
    authentication {
        auth_type PASS
        auth_pass xxxxxxx
    }

        unicast_src_ip 192.168.xxx.55
        unicast_peer {
                            192.168.xxx.56
                            192.168.xxx.57
                    }

    virtual_ipaddress {
        192.168.xxx.54/25 dev ens192

    }

    track_script {
       check_api
    }
}

Notify and track scripts

If any notify or track scripts are in use, please provide copies of them

System Log entries

Full keepalived system log entries from when keepalived started

Did keepalived coredump?

If so, can you please provide a stacktrace from the coredump, using gdb.

Additional context Add any other context about the problem here.

pqarmitage commented 8 months ago

The correct way to disable preempt is to specify nopreempt in the VRRP instance.

If you need any further assistance, you will need to post the keepalived configurations for each of your three systems, and the full keepalived system logs from each of the three systems from the time that keepalived started on those systems. We can then reopen this issue.

I have tested your configuration and nopreempt works for me as expected.

geotransformer commented 7 months ago

The correct way to disable preempt is to specify nopreempt in the VRRP instance.

If you need any further assistance, you will need to post the keepalived configurations for each of your three systems, and the full keepalived system logs from each of the three systems from the time that keepalived started on those systems. We can then reopen this issue.

I have tested your configuration and nopreempt works for me as expected.

@pqarmitage For "nopreempt" in the posted config above, VIP switches over as expected when the node (with VIP) is completely down. However, the VIP did not switch over when node (with VIP) is alive but the track_script keeps failing. Is this expected behavior?

pqarmitage commented 7 months ago

The track script has a weight of 50, so when the script fails it subtracts 50 from the vrrp priority. To make a vrrp instance go to fault state on failure, weight must not be specified.

geotransformer commented 7 months ago

The track script has a weight of 50, so when the script fails it subtracts 50 from the vrrp priority. To make a vrrp instance go to fault state on failure, weight must not be specified.

This is exactly what we are looking for. Thanks a lot @pqarmitage