always add client metadata (#3874)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
parent
9f9509b6c0
commit
7c7772b735
2 changed files with 32 additions and 32 deletions
|
@ -10,7 +10,21 @@ import (
|
|||
|
||||
// Metadata implements the metadata.Provider interface.
|
||||
func (k *Kubernetes) Metadata(ctx context.Context, state request.Request) context.Context {
|
||||
pod := k.podWithIP(state.IP())
|
||||
if pod != nil {
|
||||
metadata.SetValueFunc(ctx, "kubernetes/client-namespace", func() string {
|
||||
return pod.Namespace
|
||||
})
|
||||
|
||||
metadata.SetValueFunc(ctx, "kubernetes/client-pod-name", func() string {
|
||||
return pod.Name
|
||||
})
|
||||
}
|
||||
|
||||
zone := plugin.Zones(k.Zones).Matches(state.Name())
|
||||
if zone == "" {
|
||||
return ctx
|
||||
}
|
||||
// possible optimization: cache r so it doesn't need to be calculated again in ServeDNS
|
||||
r, err := parseRequest(state.Name(), zone)
|
||||
if err != nil {
|
||||
|
@ -44,18 +58,5 @@ func (k *Kubernetes) Metadata(ctx context.Context, state request.Request) contex
|
|||
return r.podOrSvc
|
||||
})
|
||||
|
||||
pod := k.podWithIP(state.IP())
|
||||
if pod == nil {
|
||||
return ctx
|
||||
}
|
||||
|
||||
metadata.SetValueFunc(ctx, "kubernetes/client-namespace", func() string {
|
||||
return pod.Namespace
|
||||
})
|
||||
|
||||
metadata.SetValueFunc(ctx, "kubernetes/client-pod-name", func() string {
|
||||
return pod.Name
|
||||
})
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue