From b3b33a82baa17a1603a95ed19c441cbafe0a7ff0 Mon Sep 17 00:00:00 2001 From: Pasha Sviderski Date: Thu, 9 Apr 2026 14:37:35 +1000 Subject: [PATCH] chore(e2e): increase ucind cluster init timeouts, decrease max backoff delay for TCP connection to retry faster --- internal/ucind/cluster.go | 6 +++--- pkg/client/connector/tcp.go | 11 +++++++++++ scripts/docker/entrypoint.sh | 2 +- test/e2e/cluster_test.go | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/internal/ucind/cluster.go b/internal/ucind/cluster.go index 986f4d52..8e1cbd15 100644 --- a/internal/ucind/cluster.go +++ b/internal/ucind/cluster.go @@ -125,7 +125,7 @@ func (p *Provisioner) initCluster(ctx context.Context, machines []Machine) error } defer initClient.Close() - if err := initClient.WaitMachineReady(ctx, 30*time.Second); err != nil { + if err := initClient.WaitMachineReady(ctx, 90*time.Second); err != nil { return fmt.Errorf("wait for machine %q to be ready: %w", initMachine.Name, err) } @@ -140,7 +140,7 @@ func (p *Provisioner) initCluster(ctx context.Context, machines []Machine) error fmt.Printf("Cluster %q initialised with machine %q\n", initMachine.ClusterName, initResp.Machine.Name) fmt.Printf("Waiting for cluster to be ready...") - if err = initClient.WaitClusterReady(ctx, 30*time.Second); err != nil { + if err = initClient.WaitClusterReady(ctx, 90*time.Second); err != nil { return fmt.Errorf("wait for cluster to be ready: %w", err) } fmt.Println(" done.") @@ -160,7 +160,7 @@ func (p *Provisioner) initCluster(ctx context.Context, machines []Machine) error //goland:noinspection GoDeferInLoop defer cli.Close() - if err := cli.WaitMachineReady(ctx, 30*time.Second); err != nil { + if err := cli.WaitMachineReady(ctx, 90*time.Second); err != nil { return fmt.Errorf("wait for machine %q to be ready: %w", m.Name, err) } diff --git a/pkg/client/connector/tcp.go b/pkg/client/connector/tcp.go index 098c5c51..f75e23a1 100644 --- a/pkg/client/connector/tcp.go +++ b/pkg/client/connector/tcp.go @@ -4,10 +4,12 @@ import ( "context" "fmt" "net/netip" + "time" "github.com/psviderski/uncloud/internal/grpcversion" "golang.org/x/net/proxy" "google.golang.org/grpc" + "google.golang.org/grpc/backoff" "google.golang.org/grpc/credentials/insecure" ) @@ -21,10 +23,19 @@ func NewTCPConnector(apiAddr netip.AddrPort) *TCPConnector { } func (c *TCPConnector) Connect(_ context.Context) (*grpc.ClientConn, error) { + // Use a faster connection backoff than the default (which grows up to 120s). TCP connections are typically to + // local Docker containers (ucind) or LAN machines where long backoff delays are unnecessary. + backoffConfig := backoff.DefaultConfig + backoffConfig.MaxDelay = 5 * time.Second + conn, err := grpc.NewClient( c.apiAddr.String(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(defaultServiceConfig), + grpc.WithConnectParams(grpc.ConnectParams{ + Backoff: backoffConfig, + MinConnectTimeout: 5 * time.Second, + }), grpc.WithUnaryInterceptor(grpcversion.ClientUnaryInterceptor), grpc.WithStreamInterceptor(grpcversion.ClientStreamInterceptor), ) diff --git a/scripts/docker/entrypoint.sh b/scripts/docker/entrypoint.sh index 61b698b1..5f5ad7c9 100755 --- a/scripts/docker/entrypoint.sh +++ b/scripts/docker/entrypoint.sh @@ -25,7 +25,7 @@ trap cleanup INT TERM EXIT dind dockerd & echo "Waiting for Docker in Docker to be ready..." -timeout 5s sh -c "until docker info &> /dev/null; do sleep 0.1; done" +timeout 60s sh -c "until docker info &> /dev/null; do sleep 0.5; done" echo "Docker in Docker is ready." echo "Loading corrosion image from /images/corrosion.tar..." diff --git a/test/e2e/cluster_test.go b/test/e2e/cluster_test.go index d8f604cd..d6ef3b18 100644 --- a/test/e2e/cluster_test.go +++ b/test/e2e/cluster_test.go @@ -55,7 +55,7 @@ func createTestCluster( }) if waitReady { - require.NoError(t, p.WaitClusterReady(ctx, c, 60*time.Second)) + require.NoError(t, p.WaitClusterReady(ctx, c, 90*time.Second)) } return c, p