diff options
author | 2019-10-04 17:48:43 +0200 | |
---|---|---|
committer | 2019-10-04 16:48:43 +0100 | |
commit | d7cdb992b4f96603d444b7ab058594563c5fe043 (patch) | |
tree | f86cd9bc6acc2c69b30a0980b2a4ed2b481ca45f /plugin/kubernetes/object/service.go | |
parent | 03ea2ae955823612da2e3b2ebf21da7ab8eea1bd (diff) | |
download | coredns-d7cdb992b4f96603d444b7ab058594563c5fe043.tar.gz coredns-d7cdb992b4f96603d444b7ab058594563c5fe043.tar.zst coredns-d7cdb992b4f96603d444b7ab058594563c5fe043.zip |
Measure and expose DNS programming latency from Kubernetes plugin. (#3171)
For now metric is measure only for headless services. Informer has been slighlty
refactored, so the code can measure latency without storing extra fields on
Endpoint struct.
Signed-off-by: Janek Ćukaszewicz <janluk@google.com>
Suggestions from code review
Co-Authored-By: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin/kubernetes/object/service.go')
-rw-r--r-- | plugin/kubernetes/object/service.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/plugin/kubernetes/object/service.go b/plugin/kubernetes/object/service.go index a41100ab9..295715e2d 100644 --- a/plugin/kubernetes/object/service.go +++ b/plugin/kubernetes/object/service.go @@ -26,8 +26,14 @@ type Service struct { // ServiceKey return a string using for the index. func ServiceKey(name, namespace string) string { return name + "." + namespace } -// ToService converts an api.Service to a *Service. -func ToService(obj interface{}) interface{} { +// ToService returns a function that converts an api.Service to a *Service. +func ToService(skipCleanup bool) ToFunc { + return func(obj interface{}) interface{} { + return toService(skipCleanup, obj) + } +} + +func toService(skipCleanup bool, obj interface{}) interface{} { svc, ok := obj.(*api.Service) if !ok { return nil @@ -58,7 +64,9 @@ func ToService(obj interface{}) interface{} { s.ExternalIPs[li+i] = lb.IP } - *svc = api.Service{} + if !skipCleanup { + *svc = api.Service{} + } return s } |