Skip to content

Commit

Permalink
improve the error message when failing to download kots binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
laverya committed Nov 11, 2024
1 parent af1c3c7 commit 67bf30d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/replicatedapp/embeddedcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@ func DownloadKOTSBinary(license *kotsv1beta1.License, versionLabel string) (stri
defer resp.Body.Close()

if resp.StatusCode != 200 {
return "", errors.Errorf("unexpected status code %d", resp.StatusCode)
if resp.Body != nil {
body, err := io.ReadAll(resp.Body)
if err != nil {
return "", errors.Wrapf(err, "failed to read body following unexpected status code %d", resp.StatusCode)
}
return "", errors.Errorf("unexpected status code %d: %s", resp.StatusCode, body)
} else {
return "", errors.Errorf("unexpected status code %d", resp.StatusCode)
}
}

tmpFile, err := os.CreateTemp("", "kotsbin")
Expand Down

0 comments on commit 67bf30d

Please sign in to comment.