-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Expand file tree
/
Copy pathcontroller.go
More file actions
679 lines (602 loc) · 20.7 KB
/
Copy pathcontroller.go
File metadata and controls
679 lines (602 loc) · 20.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
// Copyright 2017 Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package kube
import (
"errors"
"fmt"
"os"
"reflect"
"strconv"
"time"
"github.com/prometheus/client_golang/prometheus"
"k8s.io/api/core/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"
"istio.io/istio/pilot/pkg/model"
"istio.io/istio/pkg/log"
)
const (
// NodeRegionLabel is the well-known label for kubernetes node region
NodeRegionLabel = "failure-domain.beta.kubernetes.io/region"
// NodeZoneLabel is the well-known label for kubernetes node zone
NodeZoneLabel = "failure-domain.beta.kubernetes.io/zone"
// IstioNamespace used by default for Istio cluster-wide installation
IstioNamespace = "istio-system"
// IstioConfigMap is used by default
IstioConfigMap = "istio"
// PrometheusScrape is the annotation used by prometheus to determine if service metrics should be scraped (collected)
PrometheusScrape = "prometheus.io/scrape"
// PrometheusPort is the annotation used to explicitly specify the port to use for scraping metrics
PrometheusPort = "prometheus.io/port"
// PrometheusPath is the annotation used to specify a path for scraping metrics. Default is "/metrics"
PrometheusPath = "prometheus.io/path"
// PrometheusPathDefault is the default value for the PrometheusPath annotation
PrometheusPathDefault = "/metrics"
)
var (
// experiment on getting some monitoring on config errors.
k8sEvents = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "pilot_k8s_reg_events",
Help: "Events from k8s registry.",
}, []string{"type", "event"})
)
func init() {
prometheus.MustRegister(k8sEvents)
}
var (
azDebug = os.Getenv("VERBOSE_AZ_DEBUG") == "1"
)
// ControllerOptions stores the configurable attributes of a Controller.
type ControllerOptions struct {
// Namespace the controller watches. If set to meta_v1.NamespaceAll (""), controller watches all namespaces
WatchedNamespace string
ResyncPeriod time.Duration
DomainSuffix string
}
// Controller is a collection of synchronized resource watchers
// Caches are thread-safe
type Controller struct {
domainSuffix string
client kubernetes.Interface
queue Queue
services cacheHandler
endpoints cacheHandler
nodes cacheHandler
pods *PodCache
// Env is set by server to point to the environment, to allow the controller to
// use env data and push status. It may be null in tests.
Env *model.Environment
}
type cacheHandler struct {
informer cache.SharedIndexInformer
handler *ChainHandler
}
// NewController creates a new Kubernetes controller
func NewController(client kubernetes.Interface, options ControllerOptions) *Controller {
log.Infof("Service controller watching namespace %q for service, endpoint, nodes and pods, refresh %d",
options.WatchedNamespace, options.ResyncPeriod)
// Queue requires a time duration for a retry delay after a handler error
out := &Controller{
domainSuffix: options.DomainSuffix,
client: client,
queue: NewQueue(1 * time.Second),
}
out.services = out.createInformer(&v1.Service{}, "Service", options.ResyncPeriod,
func(opts meta_v1.ListOptions) (runtime.Object, error) {
return client.CoreV1().Services(options.WatchedNamespace).List(opts)
},
func(opts meta_v1.ListOptions) (watch.Interface, error) {
return client.CoreV1().Services(options.WatchedNamespace).Watch(opts)
})
out.endpoints = out.createInformer(&v1.Endpoints{}, "Endpoints", options.ResyncPeriod,
func(opts meta_v1.ListOptions) (runtime.Object, error) {
return client.CoreV1().Endpoints(options.WatchedNamespace).List(opts)
},
func(opts meta_v1.ListOptions) (watch.Interface, error) {
return client.CoreV1().Endpoints(options.WatchedNamespace).Watch(opts)
})
out.nodes = out.createInformer(&v1.Node{}, "Node", options.ResyncPeriod,
func(opts meta_v1.ListOptions) (runtime.Object, error) {
return client.CoreV1().Nodes().List(opts)
},
func(opts meta_v1.ListOptions) (watch.Interface, error) {
return client.CoreV1().Nodes().Watch(opts)
})
out.pods = newPodCache(out.createInformer(&v1.Pod{}, "Pod", options.ResyncPeriod,
func(opts meta_v1.ListOptions) (runtime.Object, error) {
return client.CoreV1().Pods(options.WatchedNamespace).List(opts)
},
func(opts meta_v1.ListOptions) (watch.Interface, error) {
return client.CoreV1().Pods(options.WatchedNamespace).Watch(opts)
}))
return out
}
// notify is the first handler in the handler chain.
// Returning an error causes repeated execution of the entire chain.
func (c *Controller) notify(obj interface{}, event model.Event) error {
if !c.HasSynced() {
return errors.New("waiting till full synchronization")
}
return nil
}
// createInformer registers handlers for a specific event.
// Current implementation queues the events in queue.go, and the handler is run with
// some throttling.
// Used for Service, Endpoint, Node and Pod.
// See config/kube for CRD events.
// See config/ingress for Ingress objects
func (c *Controller) createInformer(
o runtime.Object,
otype string,
resyncPeriod time.Duration,
lf cache.ListFunc,
wf cache.WatchFunc) cacheHandler {
handler := &ChainHandler{funcs: []Handler{c.notify}}
// TODO: finer-grained index (perf)
informer := cache.NewSharedIndexInformer(
&cache.ListWatch{ListFunc: lf, WatchFunc: wf}, o,
resyncPeriod, cache.Indexers{})
informer.AddEventHandler(
cache.ResourceEventHandlerFuncs{
// TODO: filtering functions to skip over un-referenced resources (perf)
AddFunc: func(obj interface{}) {
k8sEvents.With(prometheus.Labels{"type": otype, "event": "add"}).Add(1)
c.queue.Push(Task{handler: handler.Apply, obj: obj, event: model.EventAdd})
},
UpdateFunc: func(old, cur interface{}) {
if !reflect.DeepEqual(old, cur) {
k8sEvents.With(prometheus.Labels{"type": otype, "event": "update"}).Add(1)
c.queue.Push(Task{handler: handler.Apply, obj: cur, event: model.EventUpdate})
} else {
k8sEvents.With(prometheus.Labels{"type": otype, "event": "updateSame"}).Add(1)
}
},
DeleteFunc: func(obj interface{}) {
k8sEvents.With(prometheus.Labels{"type": otype, "event": "add"}).Add(1)
c.queue.Push(Task{handler: handler.Apply, obj: obj, event: model.EventDelete})
},
})
return cacheHandler{informer: informer, handler: handler}
}
// HasSynced returns true after the initial state synchronization
func (c *Controller) HasSynced() bool {
if !c.services.informer.HasSynced() ||
!c.endpoints.informer.HasSynced() ||
!c.pods.informer.HasSynced() ||
!c.nodes.informer.HasSynced() {
return false
}
return true
}
// Run all controllers until a signal is received
func (c *Controller) Run(stop <-chan struct{}) {
go c.queue.Run(stop)
go c.services.informer.Run(stop)
go c.endpoints.informer.Run(stop)
go c.pods.informer.Run(stop)
go c.nodes.informer.Run(stop)
<-stop
log.Infof("Controller terminated")
}
// Services implements a service catalog operation
func (c *Controller) Services() ([]*model.Service, error) {
list := c.services.informer.GetStore().List()
out := make([]*model.Service, 0, len(list))
for _, item := range list {
if svc := convertService(*item.(*v1.Service), c.domainSuffix); svc != nil {
out = append(out, svc)
}
}
return out, nil
}
// GetService implements a service catalog operation
func (c *Controller) GetService(hostname model.Hostname) (*model.Service, error) {
name, namespace, err := parseHostname(hostname)
if err != nil {
log.Infof("parseHostname(%s) => error %v", hostname, err)
return nil, err
}
item, exists := c.serviceByKey(name, namespace)
if !exists {
return nil, nil
}
svc := convertService(*item, c.domainSuffix)
return svc, nil
}
// serviceByKey retrieves a service by name and namespace
func (c *Controller) serviceByKey(name, namespace string) (*v1.Service, bool) {
item, exists, err := c.services.informer.GetStore().GetByKey(KeyFunc(name, namespace))
if err != nil {
log.Infof("serviceByKey(%s, %s) => error %v", name, namespace, err)
return nil, false
}
if !exists {
return nil, false
}
return item.(*v1.Service), true
}
// GetPodAZ retrieves the AZ for a pod.
func (c *Controller) GetPodAZ(pod *v1.Pod) (string, bool) {
// NodeName is set by the scheduler after the pod is created
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#late-initialization
node, exists, err := c.nodes.informer.GetStore().GetByKey(pod.Spec.NodeName)
if !exists || err != nil {
log.Warnf("unable to get node %q for pod %q: %v", pod.Spec.NodeName, pod.Name, err)
return "", false
}
region, exists := node.(*v1.Node).Labels[NodeRegionLabel]
if !exists {
if azDebug {
log.Warnf("unable to retrieve region label for pod: %v", pod.Name)
}
return "", false
}
zone, exists := node.(*v1.Node).Labels[NodeZoneLabel]
if !exists {
if azDebug {
log.Warnf("unable to retrieve zone label for pod: %v", pod.Name)
}
return "", false
}
return fmt.Sprintf("%v/%v", region, zone), true
}
// ManagementPorts implements a service catalog operation
func (c *Controller) ManagementPorts(addr string) model.PortList {
pod, exists := c.pods.getPodByIP(addr)
if !exists {
return nil
}
managementPorts, err := convertProbesToPorts(&pod.Spec)
if err != nil {
log.Infof("Error while parsing liveliness and readiness probe ports for %s => %v", addr, err)
}
// We continue despite the error because healthCheckPorts could return a partial
// list of management ports
return managementPorts
}
// WorkloadHealthCheckInfo implements a service catalog operation
func (c *Controller) WorkloadHealthCheckInfo(addr string) model.ProbeList {
pod, exists := c.pods.getPodByIP(addr)
if !exists {
return nil
}
probes := make([]*model.Probe, 0)
// Obtain probes from the readiness and liveness probes
for _, container := range pod.Spec.Containers {
if container.ReadinessProbe != nil && container.ReadinessProbe.Handler.HTTPGet != nil {
p, err := convertProbePort(container, &container.ReadinessProbe.Handler)
if err != nil {
log.Infof("Error while parsing readiness probe port =%v", err)
}
probes = append(probes, &model.Probe{
Port: p,
Path: container.ReadinessProbe.Handler.HTTPGet.Path,
})
}
if container.LivenessProbe != nil && container.LivenessProbe.Handler.HTTPGet != nil {
p, err := convertProbePort(container, &container.LivenessProbe.Handler)
if err != nil {
log.Infof("Error while parsing liveness probe port =%v", err)
}
probes = append(probes, &model.Probe{
Port: p,
Path: container.LivenessProbe.Handler.HTTPGet.Path,
})
}
}
// Obtain probe from prometheus scrape
if scrape := pod.Annotations[PrometheusScrape]; scrape == "true" {
var port *model.Port
path := PrometheusPathDefault
if portstr := pod.Annotations[PrometheusPort]; portstr != "" {
portnum, err := strconv.Atoi(portstr)
if err != nil {
log.Warna(err)
} else {
port = &model.Port{
Port: portnum,
}
}
}
if pod.Annotations[PrometheusPath] != "" {
path = pod.Annotations[PrometheusPath]
}
probes = append(probes, &model.Probe{
Port: port,
Path: path,
})
}
return probes
}
// Instances implements a service catalog operation
func (c *Controller) Instances(hostname model.Hostname, ports []string,
labelsList model.LabelsCollection) ([]*model.ServiceInstance, error) {
// Get actual service by name
name, namespace, err := parseHostname(hostname)
if err != nil {
log.Infof("parseHostname(%s) => error %v", hostname, err)
return nil, err
}
item, exists := c.serviceByKey(name, namespace)
if !exists {
return nil, nil
}
// Locate all ports in the actual service
svc := convertService(*item, c.domainSuffix)
if svc == nil {
return nil, nil
}
svcPorts := make(map[string]*model.Port)
for _, port := range ports {
if svcPort, exists := svc.Ports.Get(port); exists {
svcPorts[port] = svcPort
}
}
// TODO: single port service missing name
for _, item := range c.endpoints.informer.GetStore().List() {
ep := *item.(*v1.Endpoints)
if ep.Name == name && ep.Namespace == namespace {
var out []*model.ServiceInstance
for _, ss := range ep.Subsets {
for _, ea := range ss.Addresses {
labels, _ := c.pods.labelsByIP(ea.IP)
// check that one of the input labels is a subset of the labels
if !labelsList.HasSubsetOf(labels) {
continue
}
pod, exists := c.pods.getPodByIP(ea.IP)
az, sa, uid := "", "", ""
if exists {
az, _ = c.GetPodAZ(pod)
sa = kubeToIstioServiceAccount(pod.Spec.ServiceAccountName, pod.GetNamespace(), c.domainSuffix)
uid = fmt.Sprintf("kubernetes://%s.%s", pod.Name, pod.Namespace)
}
// identify the port by name
for _, port := range ss.Ports {
if svcPort, exists := svcPorts[port.Name]; exists {
out = append(out, &model.ServiceInstance{
Endpoint: model.NetworkEndpoint{
Address: ea.IP,
Port: int(port.Port),
ServicePort: svcPort,
UID: uid,
},
Service: svc,
Labels: labels,
AvailabilityZone: az,
ServiceAccount: sa,
})
}
}
}
}
return out, nil
}
}
return nil, nil
}
// InstancesByPort implements a service catalog operation
func (c *Controller) InstancesByPort(hostname model.Hostname, reqSvcPort int,
labelsList model.LabelsCollection) ([]*model.ServiceInstance, error) {
// Get actual service by name
name, namespace, err := parseHostname(hostname)
if err != nil {
log.Infof("parseHostname(%s) => error %v", hostname, err)
return nil, err
}
item, exists := c.serviceByKey(name, namespace)
if !exists {
return nil, nil
}
// Locate all ports in the actual service
svc := convertService(*item, c.domainSuffix)
if svc == nil {
return nil, nil
}
svcPortEntry, exists := svc.Ports.GetByPort(reqSvcPort)
if !exists && reqSvcPort != 0 {
return nil, nil
}
for _, item := range c.endpoints.informer.GetStore().List() {
ep := *item.(*v1.Endpoints)
if ep.Name == name && ep.Namespace == namespace {
var out []*model.ServiceInstance
for _, ss := range ep.Subsets {
for _, ea := range ss.Addresses {
labels, _ := c.pods.labelsByIP(ea.IP)
// check that one of the input labels is a subset of the labels
if !labelsList.HasSubsetOf(labels) {
continue
}
pod, exists := c.pods.getPodByIP(ea.IP)
az, sa, uid := "", "", ""
if exists {
az, _ = c.GetPodAZ(pod)
sa = kubeToIstioServiceAccount(pod.Spec.ServiceAccountName, pod.GetNamespace(), c.domainSuffix)
uid = fmt.Sprintf("kubernetes://%s.%s", pod.Name, pod.Namespace)
}
// identify the port by name. K8S EndpointPort uses the service port name
for _, port := range ss.Ports {
if port.Name == "" || // 'name optional if single port is defined'
reqSvcPort == 0 || // return all ports (mostly used by tests/debug)
svcPortEntry.Name == port.Name {
out = append(out, &model.ServiceInstance{
Endpoint: model.NetworkEndpoint{
Address: ea.IP,
Port: int(port.Port),
ServicePort: svcPortEntry,
UID: uid,
},
Service: svc,
Labels: labels,
AvailabilityZone: az,
ServiceAccount: sa,
})
}
}
}
}
return out, nil
}
}
return nil, nil
}
// GetProxyServiceInstances returns service instances co-located with a given proxy
func (c *Controller) GetProxyServiceInstances(proxy *model.Proxy) ([]*model.ServiceInstance, error) {
var out []*model.ServiceInstance
proxyIP := proxy.IPAddress
for _, item := range c.endpoints.informer.GetStore().List() {
ep := *item.(*v1.Endpoints)
svcItem, exists := c.serviceByKey(ep.Name, ep.Namespace)
if !exists {
continue
}
svc := convertService(*svcItem, c.domainSuffix)
if svc == nil {
continue
}
for _, ss := range ep.Subsets {
for _, port := range ss.Ports {
svcPort, exists := svc.Ports.Get(port.Name)
if !exists {
continue
}
out = append(out, getEndpoints(ss.Addresses, proxyIP, c, port, svcPort, svc)...)
nrEP := getEndpoints(ss.NotReadyAddresses, proxyIP, c, port, svcPort, svc)
out = append(out, nrEP...)
if len(nrEP) > 0 && c.Env != nil {
c.Env.PushContext.Add(model.ProxyStatusEndpointNotReady, proxy.ID, proxy, "")
}
}
}
}
if len(out) == 0 {
if c.Env != nil {
c.Env.PushContext.Add(model.ProxyStatusNoService, proxy.ID, proxy, "")
status := c.Env.PushContext
if status == nil {
log.Infof("Empty list of services for pod %s %v", proxy.ID, c.Env)
}
} else {
log.Infof("Missing env, empty list of services for pod %s", proxy.ID)
}
}
return out, nil
}
func getEndpoints(addr []v1.EndpointAddress, proxyIP string, c *Controller,
port v1.EndpointPort, svcPort *model.Port, svc *model.Service) []*model.ServiceInstance {
var out []*model.ServiceInstance
for _, ea := range addr {
if proxyIP != ea.IP {
continue
}
labels, _ := c.pods.labelsByIP(ea.IP)
pod, exists := c.pods.getPodByIP(ea.IP)
az, sa := "", ""
if exists {
az, _ = c.GetPodAZ(pod)
sa = kubeToIstioServiceAccount(pod.Spec.ServiceAccountName, pod.GetNamespace(), c.domainSuffix)
}
out = append(out, &model.ServiceInstance{
Endpoint: model.NetworkEndpoint{
Address: ea.IP,
Port: int(port.Port),
ServicePort: svcPort,
},
Service: svc,
Labels: labels,
AvailabilityZone: az,
ServiceAccount: sa,
})
}
return out
}
// GetIstioServiceAccounts returns the Istio service accounts running a serivce
// hostname. Each service account is encoded according to the SPIFFE VSID spec.
// For example, a service account named "bar" in namespace "foo" is encoded as
// "spiffe://cluster.local/ns/foo/sa/bar".
func (c *Controller) GetIstioServiceAccounts(hostname model.Hostname, ports []string) []string {
saSet := make(map[string]bool)
// Get the service accounts running the service, if it is deployed on VMs. This is retrieved
// from the service annotation explicitly set by the operators.
svc, err := c.GetService(hostname)
if err != nil {
// Do not log error here, as the service could exist in another registry
return nil
}
if svc == nil {
// Do not log error here as the service could exist in another registry
return nil
}
// Get the service accounts running service within Kubernetes. This is reflected by the pods that
// the service is deployed on, and the service accounts of the pods.
instances, err := c.Instances(hostname, ports, model.LabelsCollection{})
if err != nil {
log.Warnf("Instances(%s) error: %v", hostname, err)
return nil
}
for _, si := range instances {
if si.ServiceAccount != "" {
saSet[si.ServiceAccount] = true
}
}
for _, serviceAccount := range svc.ServiceAccounts {
sa := serviceAccount
saSet[sa] = true
}
saArray := make([]string, 0, len(saSet))
for sa := range saSet {
saArray = append(saArray, sa)
}
return saArray
}
// AppendServiceHandler implements a service catalog operation
func (c *Controller) AppendServiceHandler(f func(*model.Service, model.Event)) error {
c.services.handler.Append(func(obj interface{}, event model.Event) error {
svc := *obj.(*v1.Service)
// Do not handle "kube-system" services
if svc.Namespace == meta_v1.NamespaceSystem {
return nil
}
log.Infof("Handle service %s in namespace %s", svc.Name, svc.Namespace)
if svcConv := convertService(svc, c.domainSuffix); svcConv != nil {
f(svcConv, event)
}
return nil
})
return nil
}
// AppendInstanceHandler implements a service catalog operation
func (c *Controller) AppendInstanceHandler(f func(*model.ServiceInstance, model.Event)) error {
c.endpoints.handler.Append(func(obj interface{}, event model.Event) error {
ep := *obj.(*v1.Endpoints)
// Do not handle "kube-system" endpoints
if ep.Namespace == meta_v1.NamespaceSystem {
return nil
}
log.Infof("Handle endpoint %s in namespace %s -> %v", ep.Name, ep.Namespace, ep.Subsets)
if item, exists := c.serviceByKey(ep.Name, ep.Namespace); exists {
if svc := convertService(*item, c.domainSuffix); svc != nil {
// TODO: we're passing an incomplete instance to the
// handler since endpoints is an aggregate structure
f(&model.ServiceInstance{Service: svc}, event)
}
}
return nil
})
return nil
}