remove retries for pings in tsic

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
Kristoffer Dalby 2023-07-26 17:51:33 +02:00 committed by Kristoffer Dalby
parent 9c5301ee2e
commit e90a669951

View File

@ -11,7 +11,6 @@ import (
"strings" "strings"
"time" "time"
"github.com/cenkalti/backoff/v4"
"github.com/juanfont/headscale/hscontrol/util" "github.com/juanfont/headscale/hscontrol/util"
"github.com/juanfont/headscale/integration/dockertestutil" "github.com/juanfont/headscale/integration/dockertestutil"
"github.com/juanfont/headscale/integration/integrationutil" "github.com/juanfont/headscale/integration/integrationutil"
@ -592,7 +591,7 @@ func WithPingUntilDirect(direct bool) PingOption {
// TODO(kradalby): Make multiping, go routine magic. // TODO(kradalby): Make multiping, go routine magic.
func (t *TailscaleInContainer) Ping(hostnameOrIP string, opts ...PingOption) error { func (t *TailscaleInContainer) Ping(hostnameOrIP string, opts ...PingOption) error {
args := pingArgs{ args := pingArgs{
timeout: time.Second, timeout: 300 * time.Millisecond,
count: defaultPingCount, count: defaultPingCount,
direct: true, direct: true,
} }
@ -610,7 +609,6 @@ func (t *TailscaleInContainer) Ping(hostnameOrIP string, opts ...PingOption) err
command = append(command, hostnameOrIP) command = append(command, hostnameOrIP)
return t.pool.Retry(func() error {
result, _, err := t.Execute( result, _, err := t.Execute(
command, command,
dockertestutil.ExecuteCommandTimeout( dockertestutil.ExecuteCommandTimeout(
@ -633,19 +631,18 @@ func (t *TailscaleInContainer) Ping(hostnameOrIP string, opts ...PingOption) err
} }
if !strings.Contains(result, "pong") { if !strings.Contains(result, "pong") {
return backoff.Permanent(errTailscalePingFailed) return errTailscalePingFailed
} }
if !args.direct { if !args.direct {
if strings.Contains(result, "via DERP") { if strings.Contains(result, "via DERP") {
return nil return nil
} else { } else {
return backoff.Permanent(errTailscalePingNotDERP) return errTailscalePingNotDERP
} }
} }
return nil return nil
})
} }
type ( type (
@ -720,9 +717,7 @@ func (t *TailscaleInContainer) Curl(url string, opts ...CurlOption) (string, err
} }
var result string var result string
err := t.pool.Retry(func() error { result, _, err := t.Execute(command)
var err error
result, _, err = t.Execute(command)
if err != nil { if err != nil {
log.Printf( log.Printf(
"failed to run curl command from %s to %s, err: %s", "failed to run curl command from %s to %s, err: %s",
@ -731,13 +726,10 @@ func (t *TailscaleInContainer) Curl(url string, opts ...CurlOption) (string, err
err, err,
) )
return err return result, err
} }
return nil return result, nil
})
return result, err
} }
// WriteFile save file inside the Tailscale container. // WriteFile save file inside the Tailscale container.