Skip to content

Commit

Permalink
Update CI to include Go 1.19 (#4500)
Browse files Browse the repository at this point in the history
Fixes issue with Go 1.19 discovered in the S3 transfer manager's windows
upload and downloader buffer pools. It looks like the update to Go 1.19
changes the code path that is used by the pool because io.NopCloser was
updated to forward WriterTo if the underlying Writer implemented it.
Looks likes we'd made some assumptions about this behavior not being
present. This PR suppresses the WriterTo of the buffer pool to prevent
the unexpected usage.
  • Loading branch information
jasdel committed Aug 5, 2022
1 parent 45d5208 commit f81b2dc
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 57 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version:
- 1.16.x
- 1.17.x
- 1.18.x
- 1.19.x
steps:
- name: Setup Go
uses: actions/setup-go@v2
Expand All @@ -32,12 +31,9 @@ jobs:

- name: Test
shell: bash
run: |
if [ "${{ matrix.os }}" == "windows-latest" ]; then
make unit-no-verify
else
make get-deps-verify ci-test
fi
# SDK is currently being released with go 1.18, this cannot perform
# ci-tests task until the release system is updated to go 1.19.
run: make unit-no-verify

deprecated-go-module-tests:
needs: full-test
Expand All @@ -52,6 +48,8 @@ jobs:
- 1.13.x
- 1.14.x
- 1.15.x
- 1.16.x
- 1.17.x
steps:
- name: Setup Go
uses: actions/setup-go@v2
Expand Down
12 changes: 12 additions & 0 deletions awstesting/sandbox/Dockerfile.test.go1.19
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM golang:1.19

ENV GOPROXY=direct

ADD . /go/src/github.com/aws/aws-sdk-go

RUN apt-get update && apt-get install -y --no-install-recommends \
vim \
&& rm -rf /var/list/apt/lists/*

WORKDIR /go/src/github.com/aws/aws-sdk-go
CMD ["make", "get-deps-verify", "unit"]
95 changes: 47 additions & 48 deletions private/model/api/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package api
import (
"encoding/json"
"testing"

"github.com/aws/aws-sdk-go/private/util"
)

func buildAPI() *API {
Expand Down Expand Up @@ -238,80 +240,77 @@ func TestExampleGeneration(t *testing.T) {
def.API = a

def.setup()
expected := `
import (
expected := `import (
"bytes"
"fmt"
"strings"
"time"
"` + SDKImportRoot + `/aws"
"` + SDKImportRoot + `/aws/awserr"
"` + SDKImportRoot + `/aws/session"
"` + SDKImportRoot + `/service/fooservice"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/fooservice"
)
var _ time.Duration
var _ strings.Reader
var _ aws.Config
var _ bytes.Buffer
func parseTime(layout, value string) *time.Time {
t, err := time.Parse(layout, value)
if err != nil {
panic(err)
}
return &t
}
func ExampleFooService_Foo() {
sess := session.Must(session.NewSession())
// I pity the foo
//
// Foo bar baz qux
func ExampleFooService_Foo_shared00() {
svc := fooservice.New(session.New())
input := &fooservice.FooInput{
BarShape: aws.String("Hello world"),
svc := fooservice.New(sess)
params := &fooservice.FooInput{
BarShape: aws.String("string"),
ComplexField: &fooservice.ComplexShape{
Field: aws.String("bar"),
Field: aws.String("string"),
List: []*fooservice.NestedComplexShape{
{
NestedField: aws.String("qux"),
&fooservice.NestedComplexShape{ // Required
NestedField: aws.String("string"),
},
// More values...
},
},
ListField: []*fooservice.ComplexShape{
{
Field: aws.String("baz"),
&fooservice.ComplexShape{ // Required
Field: aws.String("string"),
List: []*fooservice.NestedComplexShape{
&fooservice.NestedComplexShape{ // Required
NestedField: aws.String("string"),
},
// More values...
},
},
// More values...
},
ListsField: [][]*fooservice.ComplexShape{
{
{
Field: aws.String("baz"),
[]*fooservice.ComplexShape{ // Required
&fooservice.ComplexShape{ // Required
Field: aws.String("string"),
List: []*fooservice.NestedComplexShape{
&fooservice.NestedComplexShape{ // Required
NestedField: aws.String("string"),
},
// More values...
},
},
// More values...
},
// More values...
},
}
resp, err := svc.Foo(params)
result, err := svc.Foo(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
fmt.Println(result)
}
`
if expected != a.ExamplesGoCode() {
t.Errorf("Expected:\n%s\nReceived:\n%s\n", expected, a.ExamplesGoCode())
// Pretty-print the response data.
fmt.Println(resp)
}`
if e, a := util.GoFmt(expected), util.GoFmt(a.ExampleGoCode()); e != a {
t.Errorf("Expect:\n%s\nActual:\n%s\n", e, a)
}
}

Expand Down
6 changes: 5 additions & 1 deletion service/s3/s3manager/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,11 @@ func (d *downloader) tryDownloadChunk(in *s3.GetObjectInput, w io.Writer) (int64
}
d.setTotalBytes(resp) // Set total if not yet set.

n, err := io.Copy(w, resp.Body)
var src io.Reader = resp.Body
if d.cfg.BufferProvider != nil {
src = &suppressWriterAt{suppressed: src}
}
n, err := io.Copy(w, src)
resp.Body.Close()
if err != nil {
return n, &errReadingBody{err: err}
Expand Down
8 changes: 8 additions & 0 deletions service/s3/s3manager/writer_read_from.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,11 @@ func (p *PooledBufferedReadFromProvider) GetReadFrom(writer io.Writer) (r Writer
}
return r, cleanup
}

type suppressWriterAt struct {
suppressed io.Reader
}

func (s *suppressWriterAt) Read(p []byte) (n int, err error) {
return s.suppressed.Read(p)
}

0 comments on commit f81b2dc

Please sign in to comment.