Skip to content

Commit 034e447

Browse files
committed
Allow multiple ipfailover configs on same node
The ipfailover pods for a given configuration must run on different nodes. We are using the ServicePort as a mechanism to prevent multiple pods for same configuration from starting on the same node. Since pods for different configurations can run on the same node a different ServicePort is used for each configuration. In the future, this may be changed to pod anti-affinity. bug 1411501 https://bugzilla.redhat.com/show_bug.cgi?id=1411501 Signed-off-by: Phil Cameron <[email protected]>
1 parent f861c25 commit 034e447

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

images/ipfailover/keepalived/lib/config-generators.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ function generate_vip_section() {
178178
#
179179
function generate_vrrpd_instance_config() {
180180
local servicename=$1
181-
local iid=${2:-"0"}
181+
local iid=${2:-"1"}
182182
local vips=$3
183183
local interface=$4
184184
local priority=${5:-"10"}

pkg/cmd/experimental/ipfailover/ipfailover.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,18 @@ func Run(f *clientcmd.Factory, options *ipfailover.IPFailoverConfigCmdOptions, c
155155
return err
156156
}
157157

158-
if len(options.ServiceAccount) == 0 {
159-
return fmt.Errorf("you must specify a service account for the ipfailover pod with --service-account, it cannot be blank")
158+
if options.VRRPIDOffset < 0 || options.VRRPIDOffset > 254 {
159+
return fmt.Errorf("The vrrp-id-offset must be in the range 0..254")
160160
}
161161

162+
// The ipfailover pods for a given configuration must run on different nodes.
163+
// We are using the ServicePort as a mechanism to prevent multiple pods for
164+
// same configuration starting on the same node. Since pods for different
165+
// configurations can run on the same node a different ServicePort is used
166+
// for each configuration.
167+
// In the future, this may be changed to pod anti-affinity.
168+
options.ServicePort = options.ServicePort + options.VRRPIDOffset
169+
162170
options.Action.Bulk.Mapper = clientcmd.ResourceMapper(f)
163171
options.Action.Bulk.Op = configcmd.Create
164172

pkg/ipfailover/keepalived/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (p *KeepalivedPlugin) Generate() (*kapi.List, error) {
116116
}
117117

118118
if len(p.Options.VirtualIPs) == 0 {
119-
return nil, fmt.Errorf("you must specify at least one virtual IP address for keepalived to expose")
119+
return nil, fmt.Errorf("you must specify at least one virtual IP address (--virtual-ips=) for keepalived to expose")
120120
}
121121

122122
dc, err := GenerateDeploymentConfig(p.Name, p.Options, selector)

pkg/ipfailover/types.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ const (
1212
// DefaultType is the default IP Failover type.
1313
DefaultType = "keepalived"
1414

15-
// DefaultServicePort is the default service port.
16-
DefaultServicePort = 1985
15+
// DefaultServicePort is the port associated with the ipfailover config.
16+
// Each ipfailover config has a different ServicePort.
17+
DefaultServicePort = 63000
1718

1819
// DefaultWatchPort is the default IP Failover watched port number.
1920
DefaultWatchPort = 80

test/cmd/router.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ os::cmd::expect_success_and_text 'oadm ipfailover --virtual-ips="1.2.3.4" --ipta
8181
os::cmd::expect_success_and_text 'oadm ipfailover --virtual-ips="1.2.3.4" --check-interval=1177 --dry-run -o yaml' 'value: "1177"'
8282
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'
8383
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'
84+
os::cmd::expect_success_and_text 'oadm ipfailover --virtual-ips="1.2.3.4" --dry-run -o yaml --vrrp-id-offset=56' 'hostPort: 63056'
85+
os::cmd::expect_failure_and_text 'oadm ipfailover --virtual-ips="1.2.3.4" --dry-run -o yaml --vrrp-id-offset=256' 'error: The vrrp-id-offset must be in the range 0..255'
8486
os::cmd::expect_success 'oadm policy remove-scc-from-user privileged -z ipfailover'
87+
8588
# TODO add tests for normal ipfailover creation
8689
# os::cmd::expect_success_and_text 'oadm ipfailover' 'deploymentconfig "ipfailover" created'
8790
# os::cmd::expect_failure_and_text 'oadm ipfailover' 'Error from server: deploymentconfig "ipfailover" already exists'

0 commit comments

Comments
 (0)