Skip to content

Commit

Permalink
Fix SRV records not returned for clusterset IP service
Browse files Browse the repository at this point in the history
With clusterset IP enabled, we extract the ports from the
aggregated ServiceImport instead of the EndpointSlices.
However the ports are populated in the ServiceImport sometime
after creation so PutServiceImport needs to update the
cached spec if it already exists.

Signed-off-by: Tom Pantelis <[email protected]>
  • Loading branch information
tpantelis committed Nov 22, 2024
1 parent e499e76 commit 0c8321d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions coredns/plugin/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -975,10 +975,12 @@ func testClusterSetIP() {

si := newServiceImport(namespace1, service1, mcsv1a1.ClusterSetIP)
si.Spec.IPs = []string{clusterSetIP}
si.Spec.Ports = []mcsv1a1.ServicePort{port1, port2}

t.lh.Resolver.PutServiceImport(si)

si.Spec.Ports = []mcsv1a1.ServicePort{port1, port2}
t.lh.Resolver.PutServiceImport(si)

t.lh.Resolver.PutEndpointSlices(newEndpointSlice(namespace1, service1, clusterID, []mcsv1a1.ServicePort{port1},
newEndpoint(serviceIP, "", true)))

Expand All @@ -999,7 +1001,7 @@ func testClusterSetIP() {
})
})

Specify("DNS query of Type SRV should succeed and write an SRV record response", func() {
FSpecify("DNS query of Type SRV should succeed and write an SRV record response", func() {
t.executeTestCase(rec, test.Case{
Qname: qname,
Qtype: dns.TypeSRV,
Expand Down
8 changes: 4 additions & 4 deletions coredns/resolver/service_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ func (i *Interface) PutServiceImport(serviceImport *mcsv1a1.ServiceImport) {
balancer: loadbalancer.NewSmoothWeightedRR(),
}

if !isLegacy {
svcInfo.spec = serviceImport.Spec
}

i.serviceMap[key] = svcInfo
}

if !isLegacy {
svcInfo.spec = serviceImport.Spec
}

svcInfo.isExported = true

if svcInfo.isHeadless() || !isLegacy {
Expand Down

0 comments on commit 0c8321d

Please sign in to comment.