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 <tompantelis@gmail.com>
  • Loading branch information
tpantelis committed Nov 25, 2024
1 parent 8831d1b commit dc9f67d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion coredns/resolver/clusterip_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,13 @@ func testClusterSetIP() {

BeforeEach(func() {
si := newAggregatedServiceImport(namespace1, service1)

si.Spec.IPs = []string{clusterSetIP}
si.Spec.Ports = []mcsv1a1.ServicePort{port1, port2}
t.resolver.PutServiceImport(si)

// We call PutServiceImport separately with the ports to ensure it updates the cache. This simulates the
// real behavior where the port information is added/updated in the ServiceImport some time after creation.
si.Spec.Ports = []mcsv1a1.ServicePort{port1, port2}
t.resolver.PutServiceImport(si)

t.putEndpointSlice(newClusterIPEndpointSlice(namespace1, service1, clusterID1, serviceIP1, true, port1))
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 dc9f67d

Please sign in to comment.