Skip to content

Commit d282ea1

Browse files
committed
Fix slow image pull caused by delayed DNS response
When IPv6 is disabled, the hostAgent enters a code path that introduces a 1-second sleep whenever it receives an `AAAA` DNS query. This delay can cause the DNS query to timeout, triggering a retry loop on the client side. Docker, for example, retries up to 10 times at 1-second intervals—resulting in a significant delay before an image is pulled. A suggested workaround is to remove the sleep, which was originally introduced to address a specific issue that now appears to be outdated or no longer relevant. [Unexpected A record DNS response](rancher-sandbox/rancher-desktop#3447 (comment)) Signed-off-by: Nino Kodabande <[email protected]>
1 parent c2833b8 commit d282ea1

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

pkg/hostagent/dns/dns.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,14 @@ import (
1111
"runtime"
1212
"strconv"
1313
"strings"
14-
"time"
1514

1615
"github.com/miekg/dns"
1716
"github.com/sirupsen/logrus"
1817
)
1918

20-
const (
21-
// Truncate for avoiding "Parse error" from `busybox nslookup`
22-
// https://github.com/lima-vm/lima/issues/380
23-
truncateSize = 512
24-
ipv6ResponseDelay = time.Second
25-
)
19+
// Truncate for avoiding "Parse error" from `busybox nslookup`
20+
// https://github.com/lima-vm/lima/issues/380
21+
const truncateSize = 512
2622

2723
var defaultFallbackIPs = []string{"8.8.8.8", "1.1.1.1"}
2824

@@ -168,12 +164,6 @@ func (h *Handler) handleQuery(w dns.ResponseWriter, req *dns.Msg) {
168164
switch q.Qtype {
169165
case dns.TypeAAAA:
170166
if !h.ipv6 {
171-
// Unfortunately some older resolvers use a slow random source to set the Transaction ID.
172-
// This creates a problem on M1 computers, which are too fast for that implementation:
173-
// Both the A and AAAA queries might end up with the same id. Therefore, we wait for
174-
// 1 second and then we return NODATA for AAAA. This will allow the client to receive
175-
// the correct response even when both Transaction IDs are the same.
176-
time.Sleep(ipv6ResponseDelay)
177167
// See RFC 2308 section 2.2 which suggests that NODATA is indicated by setting the
178168
// RCODE to NOERROR along with zero entries in the response.
179169
reply.SetRcode(req, dns.RcodeSuccess)

0 commit comments

Comments
 (0)