Skip to content

Commit

Permalink
Bump Go to v1.23.2
Browse files Browse the repository at this point in the history
https://groups.google.com/g/golang-announce/c/RQjbRNOcV74/m/N72mEv9ECAAJ
https://go.dev/doc/go1.23

Adapt the internal downloader to upstream chages, as net/http now
properly supports context causes.

See: golang commit a61729b880 ("net/http: return correct error when reading from a canceled request body")
See: golang commit 505000b2d3 ("net/http: simplify HTTP/1 request cancelation")
Signed-off-by: Tom Wieczorek <[email protected]>
  • Loading branch information
twz123 committed Oct 28, 2024
1 parent 6a099d3 commit 77e7fbc
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM $BUILDIMAGE
ARG TARGETARCH
RUN set -ex; \
# Need to use the gold linker on ARM, Go really wants to have it.
# https://github.com/golang/go/blob/go1.22.4/src/cmd/link/internal/ld/lib.go#L1622-L1641
# https://github.com/golang/go/blob/go1.23.2/src/cmd/link/internal/ld/lib.go##L1661-L1680
case "$TARGETARCH" in \
arm*) binutils=binutils-gold ;; \
*) binutils=binutils ;; \
Expand Down
2 changes: 1 addition & 1 deletion embedded-bins/Makefile.variables
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
alpine_version = 3.20
alpine_patch_version = $(alpine_version).1
golang_buildimage=docker.io/library/golang:$(go_version)-alpine$(alpine_version)
go_version = 1.22.8
go_version = 1.23.2

runc_version = 1.1.15
runc_buildimage = $(golang_buildimage)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/k0sproject/k0s

go 1.22.0
go 1.23

// k0s
require (
Expand Down
2 changes: 1 addition & 1 deletion hack/tool/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module tool

go 1.22.0
go 1.23

require (
github.com/hashicorp/terraform-exec v0.21.0
Expand Down
7 changes: 0 additions & 7 deletions internal/http/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ func Download(ctx context.Context, url string, target io.Writer, options ...Down
// Execute the request.
resp, err := client.Do(req.WithContext(ctx))
if err != nil {
if cause := context.Cause(ctx); cause != nil && !errors.Is(err, cause) {
err = fmt.Errorf("%w (%w)", cause, err)
}
return fmt.Errorf("request failed: %w", err)
}
defer func() {
Expand Down Expand Up @@ -111,10 +108,6 @@ func Download(ctx context.Context, url string, target io.Writer, options ...Down

// Run the actual data transfer.
if _, err := io.Copy(io.MultiWriter(writeMonitor, target), resp.Body); err != nil {
if cause := context.Cause(ctx); cause != nil && !errors.Is(err, cause) {
err = fmt.Errorf("%w (%w)", cause, err)
}

return fmt.Errorf("while downloading: %w", err)
}

Expand Down
4 changes: 1 addition & 3 deletions internal/http/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ func TestDownload_CancelRequest(t *testing.T) {
cancel(assert.AnError)

err := internalhttp.Download(ctx, "http://404.example.com", io.Discard)
assert.ErrorIs(t, err, assert.AnError)
if urlErr := (*url.Error)(nil); assert.ErrorAs(t, err, &urlErr) {
assert.Equal(t, "Get", urlErr.Op)
assert.Equal(t, "http://404.example.com", urlErr.URL)
assert.Equal(t, context.Canceled, urlErr.Err)
assert.Equal(t, assert.AnError, urlErr.Err)
}
}

Expand Down Expand Up @@ -113,7 +112,6 @@ func TestDownload_CancelDownload(t *testing.T) {

assert.ErrorContains(t, err, "while downloading: ")
assert.ErrorIs(t, err, assert.AnError)
assert.ErrorIs(t, err, context.Canceled)
}

func TestDownload_RedirectLoop(t *testing.T) {
Expand Down

0 comments on commit 77e7fbc

Please sign in to comment.