plugin/k8s_external: fix SRV queries doesn't work with AWS ELB/NLB (#4929)
* fix for issue #4927 Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply review comments Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply review comments Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com>
This commit is contained in:
parent
6a6905c16c
commit
de21fb2436
3 changed files with 24 additions and 10 deletions
|
@ -22,9 +22,7 @@ func (e *External) a(ctx context.Context, services []msg.Service, state request.
|
|||
rr := s.NewCNAME(state.QName(), s.Host)
|
||||
records = append(records, rr)
|
||||
if resp, err := e.upstream.Lookup(ctx, state, dns.Fqdn(s.Host), dns.TypeA); err == nil {
|
||||
for _, rr := range resp.Answer {
|
||||
records = append(records, rr)
|
||||
}
|
||||
records = append(records, resp.Answer...)
|
||||
}
|
||||
|
||||
case dns.TypeA:
|
||||
|
@ -54,9 +52,7 @@ func (e *External) aaaa(ctx context.Context, services []msg.Service, state reque
|
|||
rr := s.NewCNAME(state.QName(), s.Host)
|
||||
records = append(records, rr)
|
||||
if resp, err := e.upstream.Lookup(ctx, state, dns.Fqdn(s.Host), dns.TypeAAAA); err == nil {
|
||||
for _, rr := range resp.Answer {
|
||||
records = append(records, rr)
|
||||
}
|
||||
records = append(records, resp.Answer...)
|
||||
}
|
||||
|
||||
case dns.TypeA:
|
||||
|
@ -74,7 +70,7 @@ func (e *External) aaaa(ctx context.Context, services []msg.Service, state reque
|
|||
return records
|
||||
}
|
||||
|
||||
func (e *External) srv(services []msg.Service, state request.Request) (records, extra []dns.RR) {
|
||||
func (e *External) srv(ctx context.Context, services []msg.Service, state request.Request) (records, extra []dns.RR) {
|
||||
dup := make(map[item]struct{})
|
||||
|
||||
// Looping twice to get the right weight vs priority. This might break because we may drop duplicate SRV records latter on.
|
||||
|
@ -111,9 +107,21 @@ func (e *External) srv(services []msg.Service, state request.Request) (records,
|
|||
what, ip := s.HostType()
|
||||
|
||||
switch what {
|
||||
case dns.TypeCNAME:
|
||||
// can't happen
|
||||
|
||||
case dns.TypeCNAME:
|
||||
addr := dns.Fqdn(s.Host)
|
||||
srv := s.NewSRV(state.QName(), weight)
|
||||
if ok := isDuplicate(dup, srv.Target, "", srv.Port); !ok {
|
||||
records = append(records, srv)
|
||||
}
|
||||
if ok := isDuplicate(dup, srv.Target, addr, 0); !ok {
|
||||
if resp, err := e.upstream.Lookup(ctx, state, addr, dns.TypeA); err == nil {
|
||||
extra = append(extra, resp.Answer...)
|
||||
}
|
||||
if resp, err := e.upstream.Lookup(ctx, state, addr, dns.TypeAAAA); err == nil {
|
||||
extra = append(extra, resp.Answer...)
|
||||
}
|
||||
}
|
||||
case dns.TypeA, dns.TypeAAAA:
|
||||
addr := s.Host
|
||||
s.Host = msg.Domain(s.Key)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue