Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xds/googledirectpath: Check if ipv6 address is non empty #6959

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion xds/googledirectpath/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"io"
"net/http"
"net/url"
"strings"
"sync"
"time"
)
Expand Down Expand Up @@ -85,11 +86,15 @@
// Defined as var to be overridden in tests.
var getIPv6Capable = func(timeout time.Duration) bool {
ipv6CapableOnce.Do(func() {
_, err := getFromMetadata(timeout, ipv6URL)
addr, err := getFromMetadata(timeout, ipv6URL)
if err != nil {
logger.Warningf("could not discover ipv6 capability: %v", err)
return
}
if trimmedAddr := strings.TrimSpace(string(addr)); trimmedAddr == "" {
logger.Warningf("metadata server returned empty ipv6 address")
return
}

Check warning on line 97 in xds/googledirectpath/utils.go

View check run for this annotation

Codecov / codecov/patch

xds/googledirectpath/utils.go#L94-L97

Added lines #L94 - L97 were not covered by tests
ipv6Capable = true
})
return ipv6Capable
Expand Down