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,42 +609,40 @@ 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( time.Duration(int64(args.timeout)*int64(args.count)),
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, "pong") {
return backoff.Permanent(errTailscalePingFailed)
}
if !args.direct {
if strings.Contains(result, "via DERP") {
return nil
} else {
return backoff.Permanent(errTailscalePingNotDERP)
}
}
if strings.Contains(result, "is local") {
return nil return nil
}) }
if !strings.Contains(result, "pong") {
return errTailscalePingFailed
}
if !args.direct {
if strings.Contains(result, "via DERP") {
return nil
} else {
return errTailscalePingNotDERP
}
}
return nil
} }
type ( type (
@ -720,24 +717,19 @@ 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 if err != nil {
result, _, err = t.Execute(command) log.Printf(
if err != nil { "failed to run curl command from %s to %s, err: %s",
log.Printf( t.Hostname(),
"failed to run curl command from %s to %s, err: %s", url,
t.Hostname(), err,
url, )
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.