Skip to content

Commit

Permalink
xds/googledirectpath: Check if ipv6 address is non empty (#6959)
Browse files Browse the repository at this point in the history
  • Loading branch information
zasweq committed Feb 2, 2024
1 parent 6f63f05 commit 84b85ba
Showing 1 changed file with 6 additions and 1 deletion.
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 @@ import (
"io"
"net/http"
"net/url"
"strings"
"sync"
"time"
)
Expand Down Expand Up @@ -85,11 +86,15 @@ var (
// 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
}
ipv6Capable = true
})
return ipv6Capable
Expand Down

0 comments on commit 84b85ba

Please sign in to comment.