Skip to content

Commit 2c40b4c

Browse files
author
OpenShift Bot
authored
Merge pull request #10207 from xiangpengzhao/fix-port-check
Merged by openshift-bot
2 parents b135807 + 4edc81c commit 2c40b4c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

pkg/ipfailover/keepalived/plugin.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ func NewIPFailoverConfiguratorPlugin(name string, f *clientcmd.Factory, options
3838
// GetWatchPort gets the port to monitor for the IP Failover configuration.
3939
func (p *KeepalivedPlugin) GetWatchPort() (int, error) {
4040
port := p.Options.WatchPort
41-
if port < 1 {
41+
if port < 1 || port > 65535 {
42+
glog.V(4).Infof("Warning: KeepAlived IP Failover config: %q - WatchPort: %d invalid, will default to %d", p.Name, port, ipfailover.DefaultWatchPort)
4243
port = ipfailover.DefaultWatchPort
4344
}
4445

45-
glog.V(4).Infof("KeepAlived IP Failover config: %q - WatchPort: %+v", p.Name, port)
46+
glog.V(4).Infof("KeepAlived IP Failover config: %q - WatchPort: %d", p.Name, port)
4647

4748
return port, nil
4849
}

pkg/ipfailover/keepalived/plugin_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ func TestPluginGetWatchPort(t *testing.T) {
111111
WatchPort: 9999,
112112
Expected: 9999,
113113
},
114+
{
115+
Name: "service2",
116+
WatchPort: 65535,
117+
Expected: 65535,
118+
},
114119
{
115120
Name: "invalid-port",
116121
WatchPort: -12345,
@@ -121,6 +126,11 @@ func TestPluginGetWatchPort(t *testing.T) {
121126
WatchPort: -1,
122127
Expected: 80,
123128
},
129+
{
130+
Name: "invalid-port-3",
131+
WatchPort: 65536,
132+
Expected: 80,
133+
},
124134
{
125135
Name: "zero-port",
126136
WatchPort: 0,

0 commit comments

Comments
 (0)