Skip to content

Conversation

@lxchx
Copy link

@lxchx lxchx commented Jul 29, 2025

The current IPVS implementation allows duplicate virtual server (VS) configurations. While IPVS ensures only the first VS takes effect, the presence of redundant VS entries in the keepalived state can be confusing. Furthermore, checkers for these remaining duplicate VS still perform unnecessary work.

This commit actively detects and removes duplicate virtual servers during configuration validation. To maintain compatibility with existing configurations that might implicitly rely on this behavior, this change preserves the first encountered VS.

The current IPVS implementation allows duplicate virtual server (VS)
configurations. While IPVS ensures only the first VS takes effect,
the presence of redundant VS entries in the keepalived state can be
confusing. Furthermore, checkers for these remaining duplicate
VS still perform unnecessary work.

This commit actively detects and removes duplicate virtual servers
during configuration validation. To maintain compatibility with
existing configurations that might implicitly rely on this behavior,
this change preserves the first encountered VS.
@lxchx
Copy link
Author

lxchx commented Jul 29, 2025

This configuration might be helpful:

virtual_server 192.168.200.1 80 {
    delay_loop 6
    lb_algo rr
    lb_kind DR
    protocol TCP

    real_server 10.0.0.1 80 {
        weight 1
        MISC_CHECK {
            misc_path "/etc/keepalived/checks/check_rr_rs1.sh"
            misc_timeout 5
            user root
        }
    }

    real_server 10.0.0.2 80 {
        weight 1
        MISC_CHECK {
            misc_path "/etc/keepalived/checks/check_rr_rs2.sh"
            misc_timeout 5
            user root
        }
    }
}
virtual_server 192.168.200.1 80 {
    delay_loop 6
    lb_algo wrr
    lb_kind DR
    protocol TCP

    real_server 10.0.0.1 80 {
        weight 5
        MISC_CHECK {
            misc_path "/etc/keepalived/checks/check_wrr_rs1.sh"
            misc_timeout 5
            user root
        }
    }

    real_server 10.0.0.2 80 {
        weight 1
        MISC_CHECK {
            misc_path "/etc/keepalived/checks/check_wrr_rs2.sh"
            misc_timeout 5
            user root
        }
    }
}

When the --dump-conf parameter is enabled, Keepalived retains two duplicate virtual server (VS) configurations. Furthermore, all four misc_checker instances remain active, even though the real servers associated with check_wrr_rs1.sh and check_wrr_rs2.sh are effectively shadowed or superseded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant