Skip to content

Commit

Permalink
fix(updater): show the hint to disable a network when IP detection ti…
Browse files Browse the repository at this point in the history
…meouts (#859)
  • Loading branch information
favonia committed Aug 10, 2024
1 parent 14517e7 commit bdf154c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
14 changes: 7 additions & 7 deletions internal/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,7 @@ func detectIP(ctx context.Context, ppfmt pp.PP,
} else {
ppfmt.Warningf(pp.EmojiError, "Failed to detect the %s address", ipNet.Describe())

if ShouldDisplayHints[HintDetectionTimeouts] && errors.Is(context.Cause(ctx), errTimeout) {
ppfmt.Infof(pp.EmojiHint,
"If your network is experiencing high latency, consider increasing DETECTION_TIMEOUT=%v",
c.DetectionTimeout,
)
ShouldDisplayHints[HintDetectionTimeouts] = false
} else if ShouldDisplayHints[getHintIDForDetection(ipNet)] {
if ShouldDisplayHints[getHintIDForDetection(ipNet)] {
switch ipNet {
case ipnet.IP6:
ppfmt.Infof(pp.EmojiHint, "If you are using Docker or Kubernetes, IPv6 often requires additional setups") //nolint:lll
Expand All @@ -73,6 +67,12 @@ func detectIP(ctx context.Context, ppfmt pp.PP,
ppfmt.Infof(pp.EmojiHint, "If your network does not support IPv4, you can disable it with IP4_PROVIDER=none") //nolint:lll
}
}
if ShouldDisplayHints[HintDetectionTimeouts] && errors.Is(context.Cause(ctx), errTimeout) {
ppfmt.Infof(pp.EmojiHint,
"If your network is experiencing high latency, consider increasing DETECTION_TIMEOUT=%v",
c.DetectionTimeout,
)
}
}
ShouldDisplayHints[getHintIDForDetection(ipNet)] = false
return ip, generateDetectMessage(ipNet, ok)
Expand Down
1 change: 1 addition & 0 deletions internal/updater/updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ func TestUpdateIPs(t *testing.T) {
},
),
p.EXPECT().Warningf(pp.EmojiError, "Failed to detect the %s address", "IPv4"),
p.EXPECT().Infof(pp.EmojiHint, "If your network does not support IPv4, you can disable it with IP4_PROVIDER=none"), //nolint:lll
p.EXPECT().Infof(pp.EmojiHint, "If your network is experiencing high latency, consider increasing DETECTION_TIMEOUT=%v", time.Second), //nolint:lll
)
},
Expand Down

0 comments on commit bdf154c

Please sign in to comment.