mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 10:19:50 +00:00
Fix ClusterIP leak flake and potential NodePort leak
This commit is contained in:
parent
895da2cd49
commit
472e10faf9
@ -59,6 +59,7 @@ go_test(
|
|||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/api:go_default_library",
|
"//pkg/api:go_default_library",
|
||||||
|
"//pkg/api/helper:go_default_library",
|
||||||
"//pkg/api/service:go_default_library",
|
"//pkg/api/service:go_default_library",
|
||||||
"//pkg/api/testing:go_default_library",
|
"//pkg/api/testing:go_default_library",
|
||||||
"//pkg/features:go_default_library",
|
"//pkg/features:go_default_library",
|
||||||
|
@ -34,6 +34,7 @@ import (
|
|||||||
"k8s.io/apiserver/pkg/registry/rest"
|
"k8s.io/apiserver/pkg/registry/rest"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
|
"k8s.io/kubernetes/pkg/api/helper"
|
||||||
"k8s.io/kubernetes/pkg/api/service"
|
"k8s.io/kubernetes/pkg/api/service"
|
||||||
"k8s.io/kubernetes/pkg/features"
|
"k8s.io/kubernetes/pkg/features"
|
||||||
"k8s.io/kubernetes/pkg/registry/core/service/ipallocator"
|
"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" {
|
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)
|
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)
|
t.Errorf("%q: unexpected error: %v", test.name, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
_ = nodePortOp.Commit()
|
|
||||||
|
|
||||||
serviceNodePorts := CollectServiceNodePorts(test.service)
|
serviceNodePorts := CollectServiceNodePorts(test.service)
|
||||||
|
|
||||||
@ -1705,7 +1711,6 @@ func TestUpdateNodePorts(t *testing.T) {
|
|||||||
t.Errorf("%q: unexpected error: %v", test.name, err)
|
t.Errorf("%q: unexpected error: %v", test.name, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
_ = nodePortOp.Commit()
|
|
||||||
|
|
||||||
serviceNodePorts := CollectServiceNodePorts(test.newService)
|
serviceNodePorts := CollectServiceNodePorts(test.newService)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user