Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
Merge pull request kubernetes#66138 from wsong/fix_proxy_healthz
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue (batch tested with PRs 66138, 65951). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Don't validate HealthzBindAddress in KubeProxyConfiguration if it's empty

**What this PR does / why we need it**:
kubernetes#49087 added validation for
the HealthzBindAddress field in the KubeProxyConfiguration, but if you pass in
--healthz-port=0 to the kube-proxy CLI, it sets this field to the empty string.
However, an empty string is not a valid value for this field.

This change allows validation to pass if HealthzBindAddress is empty.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Ref kubernetes#65118

**Special notes for your reviewer**:

**Release note**:

```release-note
Fix validation for HealthzBindAddress in kube-proxy when --healthz-port is set to 0
```
  • Loading branch information
Kubernetes Submit Queue authored Jul 14, 2018
2 parents 614e3ad + 9ad9e7e commit d2387be
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/proxy/apis/kubeproxyconfig/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ func Validate(config *kubeproxyconfig.KubeProxyConfiguration) field.ErrorList {
allErrs = append(allErrs, field.Invalid(newPath.Child("BindAddress"), config.BindAddress, "not a valid textual representation of an IP address"))
}

allErrs = append(allErrs, validateHostPort(config.HealthzBindAddress, newPath.Child("HealthzBindAddress"))...)
if config.HealthzBindAddress != "" {
allErrs = append(allErrs, validateHostPort(config.HealthzBindAddress, newPath.Child("HealthzBindAddress"))...)
}
allErrs = append(allErrs, validateHostPort(config.MetricsBindAddress, newPath.Child("MetricsBindAddress"))...)

if config.ClusterCIDR != "" {
Expand Down
20 changes: 20 additions & 0 deletions pkg/proxy/apis/kubeproxyconfig/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ func TestValidateKubeProxyConfiguration(t *testing.T) {
TCPCloseWaitTimeout: &metav1.Duration{Duration: 5 * time.Second},
},
},
{
BindAddress: "192.168.59.103",
HealthzBindAddress: "",
MetricsBindAddress: "127.0.0.1:10249",
ClusterCIDR: "192.168.59.0/24",
UDPIdleTimeout: metav1.Duration{Duration: 1 * time.Second},
ConfigSyncPeriod: metav1.Duration{Duration: 1 * time.Second},
IPTables: kubeproxyconfig.KubeProxyIPTablesConfiguration{
MasqueradeAll: true,
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
},
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{
Max: pointer.Int32Ptr(2),
MaxPerCore: pointer.Int32Ptr(1),
Min: pointer.Int32Ptr(1),
TCPEstablishedTimeout: &metav1.Duration{Duration: 5 * time.Second},
TCPCloseWaitTimeout: &metav1.Duration{Duration: 5 * time.Second},
},
},
}

for _, successCase := range successCases {
Expand Down

0 comments on commit d2387be

Please sign in to comment.