summaryrefslogtreecommitdiffhomepage
path: root/pkg/test
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2020-11-23 14:16:20 -0800
committergVisor bot <gvisor-bot@google.com>2020-11-23 14:24:27 -0800
commit2320ce5b7d992973182a90b2885e852b2059ee08 (patch)
treee4ccaf9499549bf0e4b831636aff8474c505dbc0 /pkg/test
parentb6c00520d314811d59485a42c2fba578f34b91ee (diff)
Fail gracefully if Docker is not configured with ipv6.
PiperOrigin-RevId: 343927315
Diffstat (limited to 'pkg/test')
-rw-r--r--pkg/test/dockerutil/container.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/pkg/test/dockerutil/container.go b/pkg/test/dockerutil/container.go
index 64d17f661..2bf0a22ff 100644
--- a/pkg/test/dockerutil/container.go
+++ b/pkg/test/dockerutil/container.go
@@ -17,6 +17,7 @@ package dockerutil
import (
"bytes"
"context"
+ "errors"
"fmt"
"io/ioutil"
"net"
@@ -351,6 +352,9 @@ func (c *Container) SandboxPid(ctx context.Context) (int, error) {
return resp.ContainerJSONBase.State.Pid, nil
}
+// ErrNoIP indicates that no IP address is available.
+var ErrNoIP = errors.New("no IP available")
+
// FindIP returns the IP address of the container.
func (c *Container) FindIP(ctx context.Context, ipv6 bool) (net.IP, error) {
resp, err := c.client.ContainerInspect(ctx, c.id)
@@ -365,7 +369,7 @@ func (c *Container) FindIP(ctx context.Context, ipv6 bool) (net.IP, error) {
ip = net.ParseIP(resp.NetworkSettings.DefaultNetworkSettings.IPAddress)
}
if ip == nil {
- return net.IP{}, fmt.Errorf("invalid IP: %q", ip)
+ return net.IP{}, ErrNoIP
}
return ip, nil
}