Skip to content

Commit 64b66f9

Browse files
dtaskaiDominik Táskaiolix0r
authored
Add informative error messages when there is no internet connection. (#11377)
When the Linkerd CLI is unable to access the internet, it will encounter a DNS error when trying to discover the latest Linkerd releases from linkerd.io. This change handles this DNS resolution error explicitly so that users receive a more informative error message. Fixes #11349 Signed-off-by: Dominik Táskai <[email protected]> Co-authored-by: Dominik Táskai <[email protected]> Co-authored-by: Oliver Gould <[email protected]>
1 parent 74337f9 commit 64b66f9

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

pkg/healthcheck/healthcheck.go

+3
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,9 @@ func CheckProxyVersionsUpToDate(pods []corev1.Pod, versions version.Channels) er
14391439
}
14401440
}
14411441
}
1442+
if versions.Empty() {
1443+
return errors.New("unable to determine version channel")
1444+
}
14421445
if len(outdatedPods) > 0 {
14431446
podList := strings.Join(outdatedPods, "\n")
14441447
return fmt.Errorf("some proxies are not running the current version:\n%s", podList)

pkg/version/channels.go

+14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8+
"net"
89
"net/http"
910

1011
"github.com/linkerd/linkerd2/pkg/util"
@@ -44,6 +45,10 @@ func (c Channels) Match(actualVersion string) error {
4445
return errors.New("actual version is empty")
4546
}
4647

48+
if c.Empty() {
49+
return errors.New("unable to determine version channel")
50+
}
51+
4752
actual, err := parseChannelVersion(actualVersion)
4853
if err != nil {
4954
return fmt.Errorf("failed to parse actual version: %w", err)
@@ -58,6 +63,11 @@ func (c Channels) Match(actualVersion string) error {
5863
return fmt.Errorf("unsupported version channel: %s", actualVersion)
5964
}
6065

66+
// Determines whether there are any release channels stored in the struct.
67+
func (c Channels) Empty() bool {
68+
return len(c.array) == 0
69+
}
70+
6171
// GetLatestVersions performs an online request to check for the latest Linkerd
6272
// release channels.
6373
func GetLatestVersions(ctx context.Context, uuid string, source string) (Channels, error) {
@@ -73,6 +83,10 @@ func getLatestVersions(ctx context.Context, client *http.Client, url string) (Ch
7383

7484
rsp, err := client.Do(req.WithContext(ctx))
7585
if err != nil {
86+
var dnsError *net.DNSError
87+
if errors.As(err, &dnsError) {
88+
return Channels{}, fmt.Errorf("failed to resolve version check server: %s", url)
89+
}
7690
return Channels{}, err
7791
}
7892
defer rsp.Body.Close()

0 commit comments

Comments
 (0)