Skip to content

ipfailover - control preempt strategy #14947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contrib/completions/bash/oadm
Original file line number Diff line number Diff line change
Expand Up @@ -2574,6 +2574,8 @@ _oadm_ipfailover()
local_nonpersistent_flags+=("--output=")
flags+=("--output-version=")
local_nonpersistent_flags+=("--output-version=")
flags+=("--preemption-strategy=")
local_nonpersistent_flags+=("--preemption-strategy=")
flags+=("--replicas=")
two_word_flags+=("-r")
local_nonpersistent_flags+=("--replicas=")
Expand Down
2 changes: 2 additions & 0 deletions contrib/completions/bash/oc
Original file line number Diff line number Diff line change
Expand Up @@ -2655,6 +2655,8 @@ _oc_adm_ipfailover()
local_nonpersistent_flags+=("--output=")
flags+=("--output-version=")
local_nonpersistent_flags+=("--output-version=")
flags+=("--preemption-strategy=")
local_nonpersistent_flags+=("--preemption-strategy=")
flags+=("--replicas=")
two_word_flags+=("-r")
local_nonpersistent_flags+=("--replicas=")
Expand Down
6 changes: 6 additions & 0 deletions contrib/completions/bash/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -2574,6 +2574,8 @@ _openshift_admin_ipfailover()
local_nonpersistent_flags+=("--output=")
flags+=("--output-version=")
local_nonpersistent_flags+=("--output-version=")
flags+=("--preemption-strategy=")
local_nonpersistent_flags+=("--preemption-strategy=")
flags+=("--replicas=")
two_word_flags+=("-r")
local_nonpersistent_flags+=("--replicas=")
Expand Down Expand Up @@ -7859,6 +7861,8 @@ _openshift_cli_adm_ipfailover()
local_nonpersistent_flags+=("--output=")
flags+=("--output-version=")
local_nonpersistent_flags+=("--output-version=")
flags+=("--preemption-strategy=")
local_nonpersistent_flags+=("--preemption-strategy=")
flags+=("--replicas=")
two_word_flags+=("-r")
local_nonpersistent_flags+=("--replicas=")
Expand Down Expand Up @@ -22881,6 +22885,8 @@ _openshift_ex_ipfailover()
local_nonpersistent_flags+=("--output=")
flags+=("--output-version=")
local_nonpersistent_flags+=("--output-version=")
flags+=("--preemption-strategy=")
local_nonpersistent_flags+=("--preemption-strategy=")
flags+=("--replicas=")
two_word_flags+=("-r")
local_nonpersistent_flags+=("--replicas=")
Expand Down
2 changes: 2 additions & 0 deletions contrib/completions/zsh/oadm
Original file line number Diff line number Diff line change
Expand Up @@ -2723,6 +2723,8 @@ _oadm_ipfailover()
local_nonpersistent_flags+=("--output=")
flags+=("--output-version=")
local_nonpersistent_flags+=("--output-version=")
flags+=("--preemption-strategy=")
local_nonpersistent_flags+=("--preemption-strategy=")
flags+=("--replicas=")
two_word_flags+=("-r")
local_nonpersistent_flags+=("--replicas=")
Expand Down
2 changes: 2 additions & 0 deletions contrib/completions/zsh/oc
Original file line number Diff line number Diff line change
Expand Up @@ -2804,6 +2804,8 @@ _oc_adm_ipfailover()
local_nonpersistent_flags+=("--output=")
flags+=("--output-version=")
local_nonpersistent_flags+=("--output-version=")
flags+=("--preemption-strategy=")
local_nonpersistent_flags+=("--preemption-strategy=")
flags+=("--replicas=")
two_word_flags+=("-r")
local_nonpersistent_flags+=("--replicas=")
Expand Down
6 changes: 6 additions & 0 deletions contrib/completions/zsh/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -2723,6 +2723,8 @@ _openshift_admin_ipfailover()
local_nonpersistent_flags+=("--output=")
flags+=("--output-version=")
local_nonpersistent_flags+=("--output-version=")
flags+=("--preemption-strategy=")
local_nonpersistent_flags+=("--preemption-strategy=")
flags+=("--replicas=")
two_word_flags+=("-r")
local_nonpersistent_flags+=("--replicas=")
Expand Down Expand Up @@ -8008,6 +8010,8 @@ _openshift_cli_adm_ipfailover()
local_nonpersistent_flags+=("--output=")
flags+=("--output-version=")
local_nonpersistent_flags+=("--output-version=")
flags+=("--preemption-strategy=")
local_nonpersistent_flags+=("--preemption-strategy=")
flags+=("--replicas=")
two_word_flags+=("-r")
local_nonpersistent_flags+=("--replicas=")
Expand Down Expand Up @@ -23030,6 +23034,8 @@ _openshift_ex_ipfailover()
local_nonpersistent_flags+=("--output=")
flags+=("--output-version=")
local_nonpersistent_flags+=("--output-version=")
flags+=("--preemption-strategy=")
local_nonpersistent_flags+=("--preemption-strategy=")
flags+=("--replicas=")
two_word_flags+=("-r")
local_nonpersistent_flags+=("--replicas=")
Expand Down
20 changes: 9 additions & 11 deletions images/ipfailover/keepalived/conf/settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ HA_NOTIFY_SCRIPT="${OPENSHIFT_HA_NOTIFY_SCRIPT:-""}"
# Default is 2
HA_CHECK_INTERVAL="${OPENSHIFT_HA_CHECK_INTERVAL:-"2"}"

# VRRP will preempt a lower priority machine when a higher priority one
# comes back online. You can change the preemption strategy to either:
# "nopreempt" - which allows the lower priority machine to maintain its
# 'MASTER' status.
# OR
# "preempt_delay 300" - waits 5 mins (in seconds) after startup to
# preempt lower priority MASTERs.
PREEMPTION="${OPENSHIFT_HA_PREEMPTION:-"preempt_delay 300"}"


# ========================================================================
# Default settings - not currently exposed or overridden on OpenShift.
Expand All @@ -94,17 +103,6 @@ SMTP_SERVER="${OPENSHIFT_HA_SMTP_SERVER:-"127.0.0.1"}"
# SMTP connect timeout (in seconds).
SMTP_CONNECT_TIMEOUT=30


# VRRP will preempt a lower priority machine when a higher priority one
# comes back online. You can change the preemption strategy to either:
# "nopreempt" - which allows the lower priority machine to maintain its
# 'MASTER' status.
# OR
# "preempt_delay 300" - waits 5 mins (in seconds) after startup to
# preempt lower priority MASTERs.
PREEMPTION="preempt_delay 300"


# By default, the IP for binding vrrpd is the primary IP on the above
# specified interface. If you want to hide the location of vrrpd, you can
# specify a src_addr for multicast/unicast vrrp packets.
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/experimental/ipfailover/ipfailover.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func NewCmdIPFailoverConfig(f *clientcmd.Factory, parentName, name string, out,
cmd.Flags().StringVar(&options.NotifyScript, "notify-script", "", "Run this script when state changes.")
cmd.Flags().StringVar(&options.CheckScript, "check-script", "", "Run this script at the check-interval to verify service is OK")
cmd.Flags().IntVar(&options.CheckInterval, "check-interval", ipfailover.DefaultCheckInterval, "Run the check-script at this interval (seconds)")
cmd.Flags().StringVar(&options.Preemption, "preemption-strategy", "preempt_delay 300", "Normlly VRRP will preempt a lower priority machine when a higher priority one comes online. 'nopreempt' allows the lower priority machine to maintain its MASTER status. The default 'preempt_delay 300' causes MASTER to switch after 5 min.")
cmd.Flags().StringVar(&options.IptablesChain, "iptables-chain", ipfailover.DefaultIptablesChain, "Add a rule to this iptables chain to accept 224.0.0.28 multicast packets if no rule exists. When iptables-chain is empty do not change iptables.")
cmd.Flags().StringVarP(&options.NetworkInterface, "interface", "i", "", "Network interface bound by VRRP to use for the set of virtual IP ranges/addresses specified.")

Expand Down
1 change: 1 addition & 0 deletions pkg/ipfailover/keepalived/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func generateEnvEntries(name string, options *ipfailover.IPFailoverConfigCmdOpti
"OPENSHIFT_HA_IPTABLES_CHAIN": options.IptablesChain,
"OPENSHIFT_HA_NOTIFY_SCRIPT": options.NotifyScript,
"OPENSHIFT_HA_CHECK_SCRIPT": options.CheckScript,
"OPENSHIFT_HA_PREEMPTION": options.Preemption,
"OPENSHIFT_HA_CHECK_INTERVAL": interval,
// "OPENSHIFT_HA_UNICAST_PEERS": "127.0.0.1",
})
Expand Down
9 changes: 9 additions & 0 deletions pkg/ipfailover/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ const (
// between calls to the CheckScript
DefaultCheckInterval = 2

// DefaultPreemption strategy determines what to do when a lower
// priority machine has MASTER and a higher priority machine becomes
// available. The choices are "nopreempt" which leaves the lower priority
// machine as MASTER and "preempt_delay 300" (the default) which allows the
// supplied number of seconds to settle and then switches to the higher
// priority machine.
DefaultPreemption = "preempt_delay 300"

// DefaultIptablesChain is the default iptables chain on which to add
// a rule that accesses 224.0.0.18 (if none exists).
DefaultIptablesChain = "INPUT"
Expand All @@ -51,6 +59,7 @@ type IPFailoverConfigCmdOptions struct {
NotifyScript string
CheckScript string
CheckInterval int
Preemption string
NetworkInterface string
WatchPort int
VRRPIDOffset int
Expand Down
1 change: 1 addition & 0 deletions test/cmd/router.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ os::cmd::expect_success_and_text 'oadm ipfailover --virtual-ips="1.2.3.4" --ipta
os::cmd::expect_success_and_text 'oadm ipfailover --virtual-ips="1.2.3.4" --check-interval=1177 --dry-run -o yaml' 'value: "1177"'
os::cmd::expect_success_and_text 'oadm ipfailover --virtual-ips="1.2.3.4" --check-script="ChkScript.sh" --dry-run -o yaml' 'value: ChkScript.sh'
os::cmd::expect_success_and_text 'oadm ipfailover --virtual-ips="1.2.3.4" --notify-script="NotScript.sh" --dry-run -o yaml' 'value: NotScript.sh'
os::cmd::expect_success_and_text 'oadm ipfailover --virtual-ips="1.2.3.4" --preemption-strategy="nopreempt" --dry-run -o yaml' 'value: nopreempt'
os::cmd::expect_success_and_text 'oadm ipfailover --virtual-ips="1.2.3.4" --dry-run -o yaml --vrrp-id-offset=56' 'hostPort: 63056'
os::cmd::expect_failure_and_text 'oadm ipfailover --virtual-ips="1.2.3.4" --dry-run -o yaml --vrrp-id-offset=255' 'error: The vrrp-id-offset must be in the range 0..254'
os::cmd::expect_success 'oadm policy remove-scc-from-user privileged -z ipfailover'
Expand Down