mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Fix bug with empty subsets
This commit is contained in:
parent
0662141f67
commit
50a98d8fc0
@ -295,6 +295,9 @@ func (rs *REST) ResourceLocation(ctx api.Context, id string) (*url.URL, http.Rou
|
|||||||
// Find a Subset that has the port.
|
// Find a Subset that has the port.
|
||||||
for ssi := 0; ssi < len(eps.Subsets); ssi++ {
|
for ssi := 0; ssi < len(eps.Subsets); ssi++ {
|
||||||
ss := &eps.Subsets[(ssSeed+ssi)%len(eps.Subsets)]
|
ss := &eps.Subsets[(ssSeed+ssi)%len(eps.Subsets)]
|
||||||
|
if len(ss.Addresses) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
for i := range ss.Ports {
|
for i := range ss.Ports {
|
||||||
if ss.Ports[i].Name == portStr {
|
if ss.Ports[i].Name == portStr {
|
||||||
// Pick a random address.
|
// Pick a random address.
|
||||||
|
@ -440,6 +440,22 @@ func TestServiceRegistryResourceLocation(t *testing.T) {
|
|||||||
Ports: []api.EndpointPort{{Name: "", Port: 80}, {Name: "p", Port: 93}},
|
Ports: []api.EndpointPort{{Name: "", Port: 80}, {Name: "p", Port: 93}},
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ObjectMeta: api.ObjectMeta{
|
||||||
|
Name: "foo",
|
||||||
|
Namespace: api.NamespaceDefault,
|
||||||
|
},
|
||||||
|
Subsets: []api.EndpointSubset{{
|
||||||
|
Addresses: []api.EndpointAddress{},
|
||||||
|
Ports: []api.EndpointPort{{Name: "", Port: 80}, {Name: "p", Port: 93}},
|
||||||
|
}, {
|
||||||
|
Addresses: []api.EndpointAddress{{IP: "1.2.3.4"}},
|
||||||
|
Ports: []api.EndpointPort{{Name: "", Port: 80}, {Name: "p", Port: 93}},
|
||||||
|
}, {
|
||||||
|
Addresses: []api.EndpointAddress{{IP: "1.2.3.5"}},
|
||||||
|
Ports: []api.EndpointPort{},
|
||||||
|
}},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
storage, registry := NewTestREST(t, endpoints)
|
storage, registry := NewTestREST(t, endpoints)
|
||||||
|
Loading…
Reference in New Issue
Block a user