d2iq-archive / mesos-dns

DNS-based service discovery for Mesos.
https://mesosphere.github.com/mesos-dns
Apache License 2.0
483 stars 137 forks source link

Properly proxy truncated responses #467

Closed timcharper closed 8 years ago

timcharper commented 8 years ago

Fixes #457

mesosphere-ci commented 8 years ago

Can one of the admins verify this patch?

timcharper commented 8 years ago

Truncation state is being reset here:

dns/resolver/resolver.go

 459 | func truncate(m *dns.Msg, udp bool) *dns.Msg {
 460 |  max := dns.MinMsgSize
 461 |  if !udp {
 462 |      max = dns.MaxMsgSize
 463 |  } else if opt := m.IsEdns0(); opt != nil {
 464 |      max = int(opt.UDPSize())
 465 |  }
 466 | 
 467 |  m.Truncated = m.Len() > max
 468 |  if !m.Truncated {
 469 |      return m
 470 |  }
 471 | 
 472 |  m.Extra = nil // Drop all extra records first
 473 |  if m.Len() < max {
 474 |      return m
 475 |  }
 476 |  answers := m.Answer[:]
 477 |  left, right := 0, len(m.Answer)
 478 |  for {
 479 |      if left == right {
 480 |          break
 481 |      }
 482 |      mid := (left + right) / 2
 483 |      m.Answer = answers[:mid]
 484 |      if m.Len() < max {
 485 |          left = mid + 1
 486 |          continue
 487 |      }
 488 |      right = mid
 489 |  }
 490 |  return m
 491 | }
 492 | 
timcharper commented 8 years ago

I've confirmed, using tcpdump / wireshark, that the last patch causes mesos-dns to appropriately forward the truncated state.

timcharper commented 8 years ago

Looks like the failure may be unrelated to my change

drewkerrigan commented 8 years ago

@timcharper rebasing should help - some changes to circle.yml and other fixes have been committed since you forked

timcharper commented 8 years ago

@drewkerrigan thanks; I have rebased

sargun commented 8 years ago

Thank you for splitting commits!

sargun commented 8 years ago

Do you have an idea on how to simply get truncated replies out of dnsmasq?

timcharper commented 8 years ago

@sargun the way I replicate the issue is using weave DNS. I run 14 containers or so with the same weave host name and it serves them truncated

timcharper commented 8 years ago

(Weave DNS does not compress responses so it is easier to replicate)

timcharper commented 8 years ago

http://unix.stackexchange.com/questions/52933/how-to-assign-multiple-fixed-ip-address-for-one-domain ?

sargun commented 8 years ago

@timcharper I'll recreate this issue over the coming week. Would anyone be interested if we had an integration test that propped up a dns server?

timcharper commented 8 years ago

🎉