Fix ClusterIP leak flake and potential NodePort leak

This commit is contained in:
xiangpengzhao 2017-07-07 12:00:24 +08:00
parent 895da2cd49
commit 472e10faf9
2 changed files with 8 additions and 2 deletions

View File

@ -59,6 +59,7 @@ go_test(
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
"//pkg/api/helper:go_default_library",
"//pkg/api/service:go_default_library",
"//pkg/api/testing:go_default_library",
"//pkg/features:go_default_library",

View File

@ -34,6 +34,7 @@ import (
"k8s.io/apiserver/pkg/registry/rest"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/helper"
"k8s.io/kubernetes/pkg/api/service"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/registry/core/service/ipallocator"
@ -1359,6 +1360,12 @@ func TestInitClusterIP(t *testing.T) {
if test.name == "Allocate specified ClusterIP" && test.svc.Spec.ClusterIP != "1.2.3.4" {
t.Errorf("%q: expected ClusterIP %q, but got %q", test.name, "1.2.3.4", test.svc.Spec.ClusterIP)
}
if hasAllocatedIP {
if helper.IsServiceIPSet(test.svc) {
storage.serviceIPs.Release(net.ParseIP(test.svc.Spec.ClusterIP))
}
}
}
}
@ -1524,7 +1531,6 @@ func TestInitNodePorts(t *testing.T) {
t.Errorf("%q: unexpected error: %v", test.name, err)
continue
}
_ = nodePortOp.Commit()
serviceNodePorts := CollectServiceNodePorts(test.service)
@ -1705,7 +1711,6 @@ func TestUpdateNodePorts(t *testing.T) {
t.Errorf("%q: unexpected error: %v", test.name, err)
continue
}
_ = nodePortOp.Commit()
serviceNodePorts := CollectServiceNodePorts(test.newService)