55 "os"
66 "os/exec"
77 "strings"
8+ "time"
89
910 "github.com/moby/buildkit/identity"
1011 "github.com/moby/buildkit/util/testutil/integration"
@@ -32,7 +33,10 @@ func NewK3dServer(ctx context.Context, cfg *integration.BackendConfig, dockerAdd
3233
3334 clusterName = "bk-" + identity .NewID ()
3435
35- cmd := exec .CommandContext (ctx , k3dBin , "cluster" , "create" , clusterName ,
36+ createCtx , cancelCreate := context .WithTimeout (ctx , 90 * time .Second )
37+ defer cancelCreate ()
38+
39+ cmd := exec .CommandContext (createCtx , k3dBin , "cluster" , "create" , clusterName ,
3640 "--wait" ,
3741 )
3842 cmd .Env = append (
@@ -41,7 +45,8 @@ func NewK3dServer(ctx context.Context, cfg *integration.BackendConfig, dockerAdd
4145 )
4246 out , err := cmd .CombinedOutput ()
4347 if err != nil {
44- return "" , "" , nil , errors .Wrapf (err , "failed to create k3d cluster %s: %s" , clusterName , string (out ))
48+ diag := KubernetesDiagnostics (clusterName , dockerAddress )
49+ return "" , "" , nil , errors .Wrapf (err , "failed to create k3d cluster %s: %s\n %s" , clusterName , strings .TrimSpace (string (out )), diag )
4550 }
4651 deferF .Append (func () error {
4752 cmd := exec .Command (k3dBin , "cluster" , "delete" , clusterName )
@@ -56,14 +61,18 @@ func NewK3dServer(ctx context.Context, cfg *integration.BackendConfig, dockerAdd
5661 return nil
5762 })
5863
59- cmd = exec .CommandContext (ctx , k3dBin , "kubeconfig" , "write" , clusterName )
64+ kubeconfigCtx , cancelKubeconfig := context .WithTimeout (ctx , 30 * time .Second )
65+ defer cancelKubeconfig ()
66+
67+ cmd = exec .CommandContext (kubeconfigCtx , k3dBin , "kubeconfig" , "write" , clusterName )
6068 cmd .Env = append (
6169 os .Environ (),
6270 "DOCKER_CONTEXT=" + dockerAddress ,
6371 )
6472 out , err = cmd .CombinedOutput ()
6573 if err != nil {
66- return "" , "" , nil , errors .Wrapf (err , "failed to write kubeconfig for cluster %s: %s" , clusterName , string (out ))
74+ diag := KubernetesDiagnostics (clusterName , dockerAddress )
75+ return "" , "" , nil , errors .Wrapf (err , "failed to write kubeconfig for cluster %s: %s\n %s" , clusterName , strings .TrimSpace (string (out )), diag )
6776 }
6877 kubeConfig = strings .TrimSpace (string (out ))
6978
0 commit comments