acassen / keepalived

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

When the main process is started without instance, and the instance is added later and reloaded, the child process will fail to start. #2464

Closed swimlessbird closed 1 month ago

swimlessbird commented 1 month ago

Describe the bug After 7cb09b2.When the main process is started without instance, and the instance is added later and reloaded, the child process will fail to start.

To Reproduce

  1. Using an empty configuration file.
  2. Start keepalived.
  3. Add instance to configuration file.
  4. Reload keepalived.

Expected behavior

Child process can start.

Keepalived version

Keepalived v2.2.4 (08/21,2021)

Copyright(C) 2001-2021 Alexandre Cassen, <acassen@gmail.com>

Built with kernel headers for Linux 5.10.0
Running on Linux 5.10.0-60.18.0.50.h815.eulerosv2r11.x86_64 #1 SMP Tue Mar 28 09:30:42 UTC 2023
Distro: EulerOS 2.0 (SP11x86_64)

configure options: --build=x86_64-openEuler-linux-gnu --host=x86_64-openEuler-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-sha1 --with-init=systemd --enable-snmp --enable-snmp-rfc build_alias=x86_64-openEuler-linux-gnu host_alias=x86_64-openEuler-linux-gnu PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig CFLAGS=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/generic-hardened-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection  LDFLAGS=-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/generic-hardened-ld

Config options:  LIBIPSET_DYNAMIC NFTABLES LVS VRRP VRRP_AUTH VRRP_VMAC OLD_CHKSUM_COMPAT SNMP_V3_FOR_V2 SNMP_VRRP SNMP_CHECKER SNMP_RFCV2 SNMP_RFCV3 INIT=systemd SYSTEMD_NOTIFY

System options:  VSYSLOG MEMFD_CREATE IPV4_DEVCONF LIBNL3 RTA_ENCAP RTA_EXPIRES RTA_NEWDST RTA_PREF FRA_SUPPRESS_PREFIXLEN FRA_SUPPRESS_IFGROUP FRA_TUN_ID RTAX_CC_ALGO RTAX_QUICKACK RTEXT_FILTER_SKIP_STATS FRA_L3MDEV FRA_UID_RANGE RTAX_FASTOPEN_NO_COOKIE RTA_VIA FRA_PROTOCOL FRA_IP_PROTO FRA_SPORT_RANGE FRA_DPORT_RANGE RTA_TTL_PROPAGATE IFA_FLAGS LWTUNNEL_ENCAP_MPLS LWTUNNEL_ENCAP_ILA IPTABLES NET_LINUX_IF_H_COLLISION LIBIPVS_NETLINK IPVS_DEST_ATTR_ADDR_FAMILY IPVS_SYNCD_ATTRIBUTES IPVS_64BIT_STATS IPVS_TUN_TYPE IPVS_TUN_CSUM IPVS_TUN_GRE VRRP_IPVLAN IFLA_LINK_NETNSID GLOB_BRACE GLOB_ALTDIRFUNC INET6_ADDR_GEN_MODE VRF SO_MARK

and 2c4cd3b, 7cb09b2

Distro (please complete the following information):

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: Config when start

Config before reload

vrrp_instance VI_1 {
    state MASTER
    interface enp2s7
    virtual_router_id 52
    priority 90
    advert_int 1
    virtual_ipaddress {
        100.125.137.254
    }
}

virtual_server 100.125.137.254 80 {
    delay_loop 2
    lb_algo wlc
    lb_kind NAT
    protocol TCP

    real_server 100.79.33.53 80 {
        MISC_CHECK {
            misc_path "/opt/test.sh 100.79.33.53 80"
            misc_timeout 15
            misc_dynamic
        }
    }
}

Notify and track scripts NA

System Log entries

Wed Aug 21 21:35:58 2024: Starting Keepalived v2.2.4 (08/21,2021)
Wed Aug 21 21:35:58 2024: Running on Linux 5.10.0-60.18.0.50.h815.eulerosv2r11.x86_64 #1 SMP Tue Mar 28 09:30:42 UTC 2023 (built for Linux 5.10.0)
Wed Aug 21 21:35:58 2024: Command line: 'keepalived' '-D' '-l' '-n' '-p' '/var/run/keepalived.pid' '-r' '/var/run/vrrp_lvs.pid'
Wed Aug 21 21:35:58 2024:               '-c' '/var/run/checkers_lvs.pid'
Wed Aug 21 21:35:58 2024: Opening file '/etc/keepalived/keepalived.conf'.
Wed Aug 21 21:35:58 2024: Configuration file /etc/keepalived/keepalived.conf
Wed Aug 21 21:35:58 2024: pidfile_write returned 8
Wed Aug 21 21:35:58 2024: NOTICE: setting config option max_auto_priority should result in better keepalived performance
Wed Aug 21 21:35:58 2024: Warning - keepalived has no configuration to run

Wed Aug 21 21:36:33 2024: Reloading ...
Wed Aug 21 21:36:33 2024: Opening file '/etc/keepalived/keepalived.conf'.
Wed Aug 21 21:36:33 2024: Configuration file /etc/keepalived/keepalived.conf
Wed Aug 21 21:36:33 2024: Starting VRRP child process, pid=2890863
Wed Aug 21 21:36:33 2024: VRRP child process: cannot write pidfile
Wed Aug 21 21:36:33 2024: Starting Healthcheck child process, pid=2890864
Wed Aug 21 21:36:33 2024: Healthcheck child process: cannot write pidfile
Wed Aug 21 21:36:33 2024: VRRP child process(2890863) died: Respawning
Wed Aug 21 21:36:33 2024:   Please log an issue at https://github.com/acassen/keepalived/issues/
Wed Aug 21 21:36:33 2024:   and include a full copy of your keepalived configuration files, and
Wed Aug 21 21:36:33 2024:   copies of the keepalived system log entries around the time this happened
Wed Aug 21 21:36:33 2024: Restart of VRRP process delayed 0 seconds to limit respawn rate
Wed Aug 21 21:36:33 2024: Starting VRRP child process, pid=2890865
Wed Aug 21 21:36:33 2024: VRRP child process: cannot write pidfile
Wed Aug 21 21:36:33 2024: Keepalived_healthcheckers exited with permanent error FATAL. Terminating
Wed Aug 21 21:36:33 2024: Stopping
Wed Aug 21 21:36:33 2024: CPU usage (self/children) user: 0.006640/0.000759 system: 0.007562/0.001933
Wed Aug 21 21:36:33 2024: Stopped Keepalived v2.2.4 (08/21,2021)

Did keepalived coredump? NA

Additional context Before reload only have main process

# ps -ef | grep keepalived
root     2890239 3643166  0 21:35 pts/1    00:00:00 keepalived -D -l -n -p /var/run/keepalived.pid -r /var/run/vrrp.pid -c /var/run/checkers.pid
pqarmitage commented 1 month ago

Many thanks for reporting this. Commits 3ea412d and b93596f (I changed my mind about how this should be implemented) resolve the issue.

pqarmitage commented 1 month ago

Apologies, commit 3ea412d included other changes (work in progress). I have now reverted the 2 commits and commit 2103ba2 includes just the changes to pidfile.c from the previous two commits.