Skip to content

Commit

Permalink
remove retries for pings in tsic
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
  • Loading branch information
kradalby committed Sep 19, 2023
1 parent 9c5301e commit e90a669
Showing 1 changed file with 39 additions and 47 deletions.
86 changes: 39 additions & 47 deletions integration/tsic/tsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"strings"
"time"

"github.com/cenkalti/backoff/v4"
"github.com/juanfont/headscale/hscontrol/util"
"github.com/juanfont/headscale/integration/dockertestutil"
"github.com/juanfont/headscale/integration/integrationutil"
Expand Down Expand Up @@ -592,7 +591,7 @@ func WithPingUntilDirect(direct bool) PingOption {
// TODO(kradalby): Make multiping, go routine magic.
func (t *TailscaleInContainer) Ping(hostnameOrIP string, opts ...PingOption) error {
args := pingArgs{
timeout: time.Second,
timeout: 300 * time.Millisecond,
count: defaultPingCount,
direct: true,
}
Expand All @@ -610,42 +609,40 @@ func (t *TailscaleInContainer) Ping(hostnameOrIP string, opts ...PingOption) err

command = append(command, hostnameOrIP)

return t.pool.Retry(func() error {
result, _, err := t.Execute(
command,
dockertestutil.ExecuteCommandTimeout(
time.Duration(int64(args.timeout)*int64(args.count)),
),
result, _, err := t.Execute(
command,
dockertestutil.ExecuteCommandTimeout(
time.Duration(int64(args.timeout)*int64(args.count)),
),
)
if err != nil {
log.Printf(
"failed to run ping command from %s to %s, err: %s",
t.Hostname(),
hostnameOrIP,
err,
)
if err != nil {
log.Printf(
"failed to run ping command from %s to %s, err: %s",
t.Hostname(),
hostnameOrIP,
err,
)

return err
}
return err
}

if strings.Contains(result, "is local") {
return nil
}
if strings.Contains(result, "is local") {
return nil
}

if !strings.Contains(result, "pong") {
return backoff.Permanent(errTailscalePingFailed)
}
if !strings.Contains(result, "pong") {
return errTailscalePingFailed
}

if !args.direct {
if strings.Contains(result, "via DERP") {
return nil
} else {
return backoff.Permanent(errTailscalePingNotDERP)
}
if !args.direct {
if strings.Contains(result, "via DERP") {
return nil
} else {
return errTailscalePingNotDERP
}
}

return nil
})
return nil
}

type (
Expand Down Expand Up @@ -720,24 +717,19 @@ func (t *TailscaleInContainer) Curl(url string, opts ...CurlOption) (string, err
}

var result string
err := t.pool.Retry(func() error {
var err error
result, _, err = t.Execute(command)
if err != nil {
log.Printf(
"failed to run curl command from %s to %s, err: %s",
t.Hostname(),
url,
err,
)

return err
}
result, _, err := t.Execute(command)
if err != nil {
log.Printf(
"failed to run curl command from %s to %s, err: %s",
t.Hostname(),
url,
err,
)

return nil
})
return result, err
}

return result, err
return result, nil
}

// WriteFile save file inside the Tailscale container.
Expand Down

0 comments on commit e90a669

Please sign in to comment.