Skip to content

Commit

Permalink
Skip calling updateEDS for headless service (istio#18952)
Browse files Browse the repository at this point in the history
* For headless service, we donot need updateEDS as its discovery type is ORIGINAL_DST

* fix typo

* fix lint
  • Loading branch information
hzxuzhonghu authored and istio-testing committed Nov 14, 2019
1 parent b88c446 commit 10ef6e8
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions pilot/pkg/serviceregistry/kube/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,25 @@ func (c *Controller) AppendInstanceHandler(f func(*model.ServiceInstance, model.
}
}

log.Debugf("Handle event %s for endpoint %s in namespace %s", event, ep.Name, ep.Namespace)

// headless service cluster discovery type is ORIGINAL_DST, we do not need update EDS.
if features.EnableHeadlessService.Get() {
if obj, _, _ := c.services.informer.GetIndexer().GetByKey(kube.KeyFunc(ep.Name, ep.Namespace)); obj != nil {
svc := obj.(*v1.Service)
// if the service is headless service, trigger a full push.
if svc.Spec.ClusterIP == v1.ClusterIPNone {
c.XDSUpdater.ConfigUpdate(&model.PushRequest{
Full: true,
NamespacesUpdated: map[string]struct{}{ep.Namespace: {}},
// TODO: extend and set service instance type, so no need to re-init push context
ConfigTypesUpdated: map[string]struct{}{schemas.ServiceEntry.Type: {}},
})
return nil
}
}
}

c.updateEDS(ep, event)

return nil
Expand Down Expand Up @@ -972,22 +991,6 @@ func (c *Controller) updateEDS(ep *v1.Endpoints, event model.Event) {
log.Infof("Handle EDS endpoint %s in namespace %s -> %v", ep.Name, ep.Namespace, addresses)
}

if features.EnableHeadlessService.Get() {
if obj, _, _ := c.services.informer.GetIndexer().GetByKey(kube.KeyFunc(ep.Name, ep.Namespace)); obj != nil {
svc := obj.(*v1.Service)
// if the service is headless service, trigger a full push.
if svc.Spec.ClusterIP == v1.ClusterIPNone {
c.XDSUpdater.ConfigUpdate(&model.PushRequest{
Full: true,
NamespacesUpdated: map[string]struct{}{ep.Namespace: {}},
// TODO: extend and set service instance type, so no need to re-init push context
ConfigTypesUpdated: map[string]struct{}{schemas.ServiceEntry.Type: {}},
})
return
}
}
}

_ = c.XDSUpdater.EDSUpdate(c.ClusterID, string(hostname), ep.Namespace, endpoints)
}

Expand Down

0 comments on commit 10ef6e8

Please sign in to comment.