Skip to content

Commit cd94a73

Browse files
ivanmatmatiGopher Bot
authored andcommitted
BUG/MINOR: service: ExternalName backend resolution bypassed by orphan EndpointSlices
When a Kubernetes service transitions from ClusterIP to ExternalName type, orphan EndpointSlices from the previous ClusterIP state are not cleaned up by Kubernetes (known behavior). These orphan slices populate HAProxyRuntime for the service, causing getRuntimeBackend() to skip the ExternalName path and proceed to port name matching instead. Port matching then fails because the orphan EndpointSlice carries a named port (e.g. "http") while the ExternalName service spec has no named port, resulting in a routing error instead of the expected DNS-based server entry. Fix by checking s.resource.DNS before consulting HAProxyRuntime: an ExternalName service must always resolve via getExternalNameEndpoints(), regardless of any EndpointSlices that may exist in the cluster.
1 parent cba5041 commit cd94a73

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

pkg/service/endpoints.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ func (s *Service) scaleHAProxySrvs(backend *store.RuntimeBackend) {
158158
}
159159

160160
func (s *Service) getRuntimeBackend(k8s store.K8s) (backend *store.RuntimeBackend, err error) {
161+
if s.resource.DNS != "" {
162+
return s.getExternalNameEndpoints()
163+
}
161164
var ok bool
162165
var backends map[string]*store.RuntimeBackend
163166
if ns := k8s.Namespaces[s.resource.Namespace]; ns != nil {
164167
backends, ok = ns.HAProxyRuntime[s.resource.Name]
165168
}
166169
if !ok {
167-
if s.resource.DNS != "" {
168-
return s.getExternalNameEndpoints()
169-
}
170170
return nil, errors.New("no available endpoints")
171171
}
172172
svcPort := s.path.SvcPortResolved

0 commit comments

Comments
 (0)