Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit c950bc9

Browse files
authored
Merge pull request #1935 from tylerslaton/fix-bad-handshake
Fix bad handshake
2 parents 833dcb4 + e448c26 commit c950bc9

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

pkg/buildclient/client.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package buildclient
33
import (
44
"context"
55
"fmt"
6+
"io"
67
"net/http"
78
"os"
89
"path/filepath"
@@ -31,11 +32,24 @@ type WebSocketDialer func(ctx context.Context, urlStr string, requestHeader http
3132

3233
func Stream(ctx context.Context, cwd string, streams *streams.Output, dialer WebSocketDialer,
3334
creds CredentialLookup, build *apiv1.AcornImageBuild) (*v1.AppImage, error) {
34-
conn, _, err := dialer(ctx, wsURL(build.Status.BuildURL), map[string][]string{
35+
conn, response, err := dialer(ctx, wsURL(build.Status.BuildURL), map[string][]string{
3536
"X-Acorn-Build-Token": {build.Status.Token},
3637
})
38+
if response.Body != nil {
39+
defer response.Body.Close()
40+
}
3741
if err != nil {
38-
return nil, err
42+
if response.Body == nil {
43+
return nil, err
44+
}
45+
46+
// If there was a body and an error ocurred, read the body and write it
47+
// into the error message.
48+
body, readErr := io.ReadAll(response.Body)
49+
if readErr != nil {
50+
return nil, fmt.Errorf("%w: status %v, error occured while reading builder response body: %v", err, response.StatusCode, readErr)
51+
}
52+
return nil, fmt.Errorf("%w: %v, %v", err, response.StatusCode, string(body))
3953
}
4054

4155
var (

pkg/controller/builder/builder.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/acorn-io/runtime/pkg/config"
88
"github.com/acorn-io/runtime/pkg/imagesystem"
99
"github.com/acorn-io/runtime/pkg/system"
10-
"github.com/google/uuid"
1110
appsv1 "k8s.io/api/apps/v1"
1211
apierrors "k8s.io/apimachinery/pkg/api/errors"
1312
kclient "sigs.k8s.io/controller-runtime/pkg/client"
@@ -61,7 +60,7 @@ func DeployBuilder(req router.Request, resp router.Response) error {
6160

6261
if *cfg.BuilderPerProject {
6362
if builder.Status.UUID == "" {
64-
builder.Status.UUID = uuid.New().String()
63+
builder.Status.UUID = string(builder.UID)
6564
}
6665
} else {
6766
builder.Status.UUID = ""

0 commit comments

Comments
 (0)