Skip to content

Commit

Permalink
Use environment var for ResolveIPAddressTimeout
Browse files Browse the repository at this point in the history
Signed-off-by: மனோஜ்குமார் பழனிச்சாமி <[email protected]>
  • Loading branch information
SmartManoj committed Jul 23, 2024
1 parent 495db7a commit c46ba9d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/networks/usernet/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"fmt"
"net"
"net/http"
"os"
"strconv"
"time"

gvproxyclient "github.com/containers/gvisor-tap-vsock/pkg/client"
Expand Down Expand Up @@ -74,11 +76,19 @@ func (c *Client) ResolveAndForwardSSH(ipAddr string, sshPort int) error {
}

func (c *Client) ResolveIPAddress(ctx context.Context, vmMacAddr string) (string, error) {
timeout := time.After(2 * time.Minute)
ResolveIPAddressTimeout := 2 * time.Minute
ResolveIPAddressTimeoutEnv := os.Getenv("RESOLVE_IP_ADDRESS_TIMEOUT")
if ResolveIPAddressTimeoutEnv != "" {
if parsedTimeout, err := strconv.Atoi(ResolveIPAddressTimeoutEnv); err == nil {
ResolveIPAddressTimeout = parsedTimeout * time.Minute

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Colima (v0.6.5)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (alpine.yaml)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (../hack/test-templates/test-misc.yaml)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (archlinux.yaml)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (debian.yaml)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Unit tests (1.21.x)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (experimental/9p.yaml)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Artifacts Darwin

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (docker.yaml)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Unit tests (1.22.x)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (experimental/net-user-v2.yaml)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (opensuse.yaml)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (fedora.yaml)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Lints

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)) (typecheck)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Lints

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)) (typecheck)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Lints

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)) (typecheck)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Lints

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration) (typecheck)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Lints

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)) (typecheck)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / VMNet test

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Integration tests (on Linux) (../hack/test-templates/alpine-9p-writable.yaml)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Integration tests

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Windows tests

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / vz (experimental/vz.yaml)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / vz (fedora.yaml)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Upgrade test (v0.15.1)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Upgrade test (v0.15.1)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)

Check failure on line 83 in pkg/networks/usernet/client.go

View workflow job for this annotation

GitHub Actions / Upgrade test (v0.15.1)

invalid operation: parsedTimeout * time.Minute (mismatched types int and time.Duration)
}
}
ctx, cancel := context.WithTimeout(ctx, ResolveIPAddressTimeout)
defer cancel()
ticker := time.NewTicker(500 * time.Millisecond)
for {
select {
case <-timeout:
case <-ctx.Done():
return "", errors.New("usernet unable to resolve IP for SSH forwarding")
case <-ticker.C:
leases, err := c.Leases(ctx)
Expand Down

0 comments on commit c46ba9d

Please sign in to comment.