Skip to content

Commit 3ca62e8

Browse files
authored
Merge branch 'develop' into dependabot/go_modules/golang.org/x/net-0.17.0
2 parents efb2e05 + 42aee21 commit 3ca62e8

File tree

104 files changed

+6819
-2849
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+6819
-2849
lines changed

.github/workflows/integ-tests.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Run Integration Tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
8+
jobs:
9+
integ-tests:
10+
runs-on: ubuntu-latest
11+
environment:
12+
name: prod
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.11'
18+
- name: allows us to build arm64 images
19+
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
20+
- name: run integration tests
21+
run: make integ-tests-with-docker

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ compile-lambda-linux-all:
2121
make ARCH=old compile-lambda-linux
2222

2323
compile-with-docker:
24-
docker run --env GOPROXY=direct -v $(shell pwd):/LambdaRuntimeLocal -w /LambdaRuntimeLocal golang:1.19 make ARCH=${ARCH} compile-lambda-linux
24+
docker run --env GOPROXY=direct -v $(shell pwd):/LambdaRuntimeLocal -w /LambdaRuntimeLocal golang:1.21 make ARCH=${ARCH} compile-lambda-linux
2525

2626
compile-lambda-linux:
27-
CGO_ENABLED=0 GOOS=linux GOARCH=${GO_ARCH_${ARCH}} go build -ldflags "${RELEASE_BUILD_LINKER_FLAGS}" -o ${DESTINATION_${ARCH}} ./cmd/aws-lambda-rie
27+
CGO_ENABLED=0 GOOS=linux GOARCH=${GO_ARCH_${ARCH}} go build -buildvcs=false -ldflags "${RELEASE_BUILD_LINKER_FLAGS}" -o ${DESTINATION_${ARCH}} ./cmd/aws-lambda-rie
2828

2929
tests:
3030
go test ./...

cmd/aws-lambda-rie/main.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"runtime/debug"
1212

1313
"github.com/jessevdk/go-flags"
14+
"go.amzn.com/lambda/interop"
1415
"go.amzn.com/lambda/rapidcore"
1516

1617
log "github.com/sirupsen/logrus"
@@ -103,7 +104,7 @@ func isBootstrapFileExist(filePath string) bool {
103104
return !os.IsNotExist(err) && !file.IsDir()
104105
}
105106

106-
func getBootstrap(args []string, opts options) (*rapidcore.Bootstrap, string) {
107+
func getBootstrap(args []string, opts options) (interop.Bootstrap, string) {
107108
var bootstrapLookupCmd []string
108109
var handler string
109110
currentWorkingDir := "/var/task" // default value
@@ -149,5 +150,5 @@ func getBootstrap(args []string, opts options) (*rapidcore.Bootstrap, string) {
149150
log.Panic("insufficient arguments: bootstrap not provided")
150151
}
151152

152-
return rapidcore.NewBootstrapSingleCmd(bootstrapLookupCmd, currentWorkingDir, ""), handler
153+
return NewSimpleBootstrap(bootstrapLookupCmd, currentWorkingDir), handler
153154
}
+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package main
5+
6+
import (
7+
"fmt"
8+
"os"
9+
"path/filepath"
10+
11+
"go.amzn.com/lambda/fatalerror"
12+
"go.amzn.com/lambda/interop"
13+
"go.amzn.com/lambda/rapidcore/env"
14+
)
15+
16+
// the type implement a simpler version of the Bootstrap
17+
// this is useful in the Standalone Core implementation.
18+
type simpleBootstrap struct {
19+
cmd []string
20+
workingDir string
21+
}
22+
23+
func NewSimpleBootstrap(cmd []string, currentWorkingDir string) interop.Bootstrap {
24+
if currentWorkingDir == "" {
25+
// use the root directory as the default working directory
26+
currentWorkingDir = "/"
27+
}
28+
29+
// a single candidate command makes it automatically valid
30+
return &simpleBootstrap{
31+
cmd: cmd,
32+
workingDir: currentWorkingDir,
33+
}
34+
}
35+
36+
func (b *simpleBootstrap) Cmd() ([]string, error) {
37+
return b.cmd, nil
38+
}
39+
40+
// Cwd returns the working directory of the bootstrap process
41+
// The path is validated against the chroot identified by `root`
42+
func (b *simpleBootstrap) Cwd() (string, error) {
43+
if !filepath.IsAbs(b.workingDir) {
44+
return "", fmt.Errorf("the working directory '%s' is invalid, it needs to be an absolute path", b.workingDir)
45+
}
46+
47+
// evaluate the path relatively to the domain's mnt namespace root
48+
if _, err := os.Stat(b.workingDir); os.IsNotExist(err) {
49+
return "", fmt.Errorf("the working directory doesn't exist: %s", b.workingDir)
50+
}
51+
52+
return b.workingDir, nil
53+
}
54+
55+
// Env returns the environment variables available to
56+
// the bootstrap process
57+
func (b *simpleBootstrap) Env(e *env.Environment) map[string]string {
58+
return e.RuntimeExecEnv()
59+
}
60+
61+
// ExtraFiles returns the extra file descriptors apart from 1 & 2 to be passed to runtime
62+
func (b *simpleBootstrap) ExtraFiles() []*os.File {
63+
return make([]*os.File, 0)
64+
}
65+
66+
func (b *simpleBootstrap) CachedFatalError(err error) (fatalerror.ErrorType, string, bool) {
67+
// not implemented as it is not needed in Core but we need to fullfil the interface anyway
68+
return fatalerror.ErrorType(""), "", false
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package main
5+
6+
import (
7+
"os"
8+
"reflect"
9+
"testing"
10+
11+
"go.amzn.com/lambda/rapidcore/env"
12+
13+
"github.com/stretchr/testify/assert"
14+
)
15+
16+
func TestSimpleBootstrap(t *testing.T) {
17+
tmpFile, err := os.CreateTemp("", "oci-test-bootstrap")
18+
assert.NoError(t, err)
19+
defer os.Remove(tmpFile.Name())
20+
21+
// Setup single cmd candidate
22+
file := []string{tmpFile.Name(), "--arg1 s", "foo"}
23+
cmdCandidate := file
24+
25+
// Setup working dir
26+
cwd, err := os.Getwd()
27+
assert.NoError(t, err)
28+
29+
// Setup environment
30+
environment := env.NewEnvironment()
31+
environment.StoreRuntimeAPIEnvironmentVariable("host:port")
32+
environment.StoreEnvironmentVariablesFromInit(map[string]string{}, "", "", "", "", "", "")
33+
34+
// Test
35+
b := NewSimpleBootstrap(cmdCandidate, cwd)
36+
bCwd, err := b.Cwd()
37+
assert.NoError(t, err)
38+
assert.Equal(t, cwd, bCwd)
39+
assert.True(t, reflect.DeepEqual(environment.RuntimeExecEnv(), b.Env(environment)))
40+
41+
cmd, err := b.Cmd()
42+
assert.NoError(t, err)
43+
assert.Equal(t, file, cmd)
44+
}
45+
46+
func TestSimpleBootstrapCmdNonExistingCandidate(t *testing.T) {
47+
// Setup inexistent single cmd candidate
48+
file := []string{"/foo/bar", "--arg1 s", "foo"}
49+
cmdCandidate := file
50+
51+
// Setup working dir
52+
cwd, err := os.Getwd()
53+
assert.NoError(t, err)
54+
55+
// Setup environment
56+
environment := env.NewEnvironment()
57+
environment.StoreRuntimeAPIEnvironmentVariable("host:port")
58+
environment.StoreEnvironmentVariablesFromInit(map[string]string{}, "", "", "", "", "", "")
59+
60+
// Test
61+
b := NewSimpleBootstrap(cmdCandidate, cwd)
62+
bCwd, err := b.Cwd()
63+
assert.NoError(t, err)
64+
assert.Equal(t, cwd, bCwd)
65+
assert.True(t, reflect.DeepEqual(environment.RuntimeExecEnv(), b.Env(environment)))
66+
67+
// No validations run against single candidates
68+
cmd, err := b.Cmd()
69+
assert.NoError(t, err)
70+
assert.Equal(t, file, cmd)
71+
}
72+
73+
func TestSimpleBootstrapCmdDefaultWorkingDir(t *testing.T) {
74+
b := NewSimpleBootstrap([]string{}, "")
75+
bCwd, err := b.Cwd()
76+
assert.NoError(t, err)
77+
assert.Equal(t, "/", bCwd)
78+
}

go.mod

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
module go.amzn.com
22

3-
go 1.19
3+
go 1.21
44

55
require (
6-
github.com/aws/aws-lambda-go v1.41.0
7-
github.com/go-chi/chi v4.1.2+incompatible
8-
github.com/google/uuid v1.3.0
6+
github.com/aws/aws-lambda-go v1.46.0
7+
github.com/go-chi/chi v1.5.5
8+
github.com/google/uuid v1.6.0
99
github.com/jessevdk/go-flags v1.5.0
1010
github.com/sirupsen/logrus v1.9.3
11-
github.com/stretchr/testify v1.8.4
12-
golang.org/x/sync v0.2.0
11+
github.com/stretchr/testify v1.9.0
12+
golang.org/x/sync v0.6.0
1313
)
1414

1515
require (
1616
github.com/davecgh/go-spew v1.1.1 // indirect
1717
github.com/pmezard/go-difflib v1.0.0 // indirect
18-
github.com/stretchr/objx v0.5.0 // indirect
19-
golang.org/x/net v0.17.0 // indirect
20-
golang.org/x/sys v0.13.0 // indirect
18+
github.com/stretchr/objx v0.5.2 // indirect
19+
golang.org/x/sys v0.14.0 // indirect
2120
gopkg.in/yaml.v3 v3.0.1 // indirect
2221
)

go.sum

+14-20
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,30 @@
1-
github.com/aws/aws-lambda-go v1.41.0 h1:l/5fyVb6Ud9uYd411xdHZzSf2n86TakxzpvIoz7l+3Y=
2-
github.com/aws/aws-lambda-go v1.41.0/go.mod h1:jwFe2KmMsHmffA1X2R09hH6lFzJQxzI8qK17ewzbQMM=
1+
github.com/aws/aws-lambda-go v1.46.0 h1:UWVnvh2h2gecOlFhHQfIPQcD8pL/f7pVCutmFl+oXU8=
2+
github.com/aws/aws-lambda-go v1.46.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A=
33
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
44
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
55
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6-
github.com/go-chi/chi v4.1.2+incompatible h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec=
7-
github.com/go-chi/chi v4.1.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
8-
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
9-
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
6+
github.com/go-chi/chi v1.5.5 h1:vOB/HbEMt9QqBqErz07QehcOKHaWFtuj87tTDVz2qXE=
7+
github.com/go-chi/chi v1.5.5/go.mod h1:C9JqLr3tIYjDOZpzn+BCuxY8z8vmca43EeMgyZt7irw=
8+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
9+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
1010
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
1111
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
1212
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1313
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1414
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
1515
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
1616
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
17-
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
18-
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
19-
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
17+
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
18+
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
2019
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
21-
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
22-
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
23-
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
24-
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
25-
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
26-
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
27-
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
28-
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
20+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
21+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
22+
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
23+
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
2924
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
3025
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
31-
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
32-
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
33-
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
26+
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
27+
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
3428
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
3529
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3630
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

lambda/agents/agent.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,18 @@ func ListExternalAgentPaths(dir string, root string) []string {
2020
}
2121
fullDir := path.Join(root, dir)
2222
files, err := os.ReadDir(fullDir)
23+
2324
if err != nil {
24-
log.WithError(err).Warning("Cannot list external agents")
25+
if os.IsNotExist(err) {
26+
log.Infof("The extension's directory %q does not exist, assuming no extensions to be loaded.", fullDir)
27+
} else {
28+
// TODO - Should this return an error rather than ignore failing to load?
29+
log.WithError(err).Error("Cannot list external agents")
30+
}
31+
2532
return agentPaths
2633
}
34+
2735
for _, file := range files {
2836
if !file.IsDir() {
2937
// The returned path is absolute wrt to `root`. This allows

lambda/appctx/appctx.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ type Key int
1313
type InitType int
1414

1515
const (
16-
// AppCtxInvokeErrorResponseKey is used for storing deferred invoke error response.
16+
// AppCtxInvokeErrorTraceDataKey is used for storing deferred invoke error cause header value.
1717
// Only used by xray. TODO refactor xray interface so it doesn't use appctx
18-
AppCtxInvokeErrorResponseKey Key = iota
18+
AppCtxInvokeErrorTraceDataKey Key = iota
1919

2020
// AppCtxRuntimeReleaseKey is used for storing runtime release information (parsed from User_Agent Http header string).
2121
AppCtxRuntimeReleaseKey
2222

2323
// AppCtxInteropServerKey is used to store a reference to the interop server.
2424
AppCtxInteropServerKey
2525

26+
// AppCtxResponseSenderKey is used to store a reference to the response sender
27+
AppCtxResponseSenderKey
28+
2629
// AppCtxFirstFatalErrorKey is used to store first unrecoverable error message encountered to propagate it to slicer with DONE(errortype) or DONEFAIL(errortype)
2730
AppCtxFirstFatalErrorKey
2831

lambda/appctx/appctxutil.go

+21-7
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,16 @@ func UpdateAppCtxWithRuntimeRelease(request *http.Request, appCtx ApplicationCon
119119
return false
120120
}
121121

122-
// StoreErrorResponse stores response in the applicaton context.
123-
func StoreErrorResponse(appCtx ApplicationContext, errorResponse *interop.ErrorResponse) {
124-
appCtx.Store(AppCtxInvokeErrorResponseKey, errorResponse)
122+
// StoreInvokeErrorTraceData stores invocation error x-ray cause header in the applicaton context.
123+
func StoreInvokeErrorTraceData(appCtx ApplicationContext, invokeError *interop.InvokeErrorTraceData) {
124+
appCtx.Store(AppCtxInvokeErrorTraceDataKey, invokeError)
125125
}
126126

127-
// LoadErrorResponse retrieves response from the application context.
128-
func LoadErrorResponse(appCtx ApplicationContext) *interop.ErrorResponse {
129-
v, ok := appCtx.Load(AppCtxInvokeErrorResponseKey)
127+
// LoadInvokeErrorTraceData retrieves invocation error x-ray cause header from the application context.
128+
func LoadInvokeErrorTraceData(appCtx ApplicationContext) *interop.InvokeErrorTraceData {
129+
v, ok := appCtx.Load(AppCtxInvokeErrorTraceDataKey)
130130
if ok {
131-
return v.(*interop.ErrorResponse)
131+
return v.(*interop.InvokeErrorTraceData)
132132
}
133133
return nil
134134
}
@@ -147,6 +147,20 @@ func LoadInteropServer(appCtx ApplicationContext) interop.Server {
147147
return nil
148148
}
149149

150+
// StoreResponseSender stores a reference to the response sender
151+
func StoreResponseSender(appCtx ApplicationContext, server interop.InvokeResponseSender) {
152+
appCtx.Store(AppCtxResponseSenderKey, server)
153+
}
154+
155+
// LoadResponseSender retrieves the response sender
156+
func LoadResponseSender(appCtx ApplicationContext) interop.InvokeResponseSender {
157+
v, ok := appCtx.Load(AppCtxResponseSenderKey)
158+
if ok {
159+
return v.(interop.InvokeResponseSender)
160+
}
161+
return nil
162+
}
163+
150164
// StoreFirstFatalError stores unrecoverable error code in appctx once. This error is considered to be the rootcause of failure
151165
func StoreFirstFatalError(appCtx ApplicationContext, err fatalerror.ErrorType) {
152166
if existing := appCtx.StoreIfNotExists(AppCtxFirstFatalErrorKey, err); existing != nil {

0 commit comments

Comments
 (0)