From 781cd9a296b10ed44a0223b34092703ddc4a36b6 Mon Sep 17 00:00:00 2001 From: Renato Valenzuela <37676028+valerena@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:16:03 -0800 Subject: [PATCH 1/5] test: Add delay for time-related arm64 tests (#138) The tests on GitHub run on x86 instances (because arm64 instances don't have Docker installed) so when running the arm64 tests, invokes take longer because of the cross-architecture emulation. This caused that some tests that check remaining time in the function were not landing on the correct time range. It's unknown why this delay started manifesting more consistently, we might want to find a better solution in the future. --- .../local_lambda/test_end_to_end.py | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/test/integration/local_lambda/test_end_to_end.py b/test/integration/local_lambda/test_end_to_end.py index 8e34b77..d564bb1 100644 --- a/test/integration/local_lambda/test_end_to_end.py +++ b/test/integration/local_lambda/test_end_to_end.py @@ -173,9 +173,8 @@ def test_context_get_remaining_time_in_three_seconds(self): with self.create_container(params, image): r = self.invoke_function() - # Execution time is not decided, 1.0s ~ 3.0s is a good estimation - self.assertLess(int(r.content), 3000) - self.assertGreater(int(r.content), 1000) + # Execution time is not decided, but it should be around 2.0s + self.assertAround(int(r.content), 2000) def test_context_get_remaining_time_in_ten_seconds(self): @@ -186,9 +185,8 @@ def test_context_get_remaining_time_in_ten_seconds(self): with self.create_container(params, image): r = self.invoke_function() - # Execution time is not decided, 8.0s ~ 10.0s is a good estimation - self.assertLess(int(r.content), 10000) - self.assertGreater(int(r.content), 8000) + # Execution time is not decided, but it should be around 9.0s + self.assertAround(int(r.content), 9000) def test_context_get_remaining_time_in_default_deadline(self): @@ -199,9 +197,8 @@ def test_context_get_remaining_time_in_default_deadline(self): with self.create_container(params, image): r = self.invoke_function() - # Executation time is not decided, 298.0s ~ 300.0s is a good estimation - self.assertLess(int(r.content), 300000) - self.assertGreater(int(r.content), 298000) + # Execution time is not decided, but it should be around 299.0s + self.assertAround(int(r.content), 299000) def test_invoke_with_pre_runtime_api_runtime(self): @@ -256,6 +253,13 @@ def test_custom_client_context(self): self.assertEqual("bar", content["foo"]) self.assertEqual(123, content["baz"]) + def assertAround(self, number, target): + # Emulating arm64 on x86 causes the invoke to take longer + delay_arm64 = 500 + actual_target = target if self.ARCH != 'arm64' else target - delay_arm64 + + self.assertLess(number, actual_target + 1000) + self.assertGreater(number, actual_target - 1000) if __name__ == "__main__": main() From 3a0772eae98d7653006b259e6be9c2a8e5b32d88 Mon Sep 17 00:00:00 2001 From: Roger Zhang Date: Wed, 23 Apr 2025 10:31:40 -0700 Subject: [PATCH 2/5] chore(deps): Update to Go 1.24 (#143) * update to 1.24 * fix changes --- Makefile | 2 +- go.mod | 2 +- lambda/rapi/handler/agentnext.go | 2 +- lambda/rapi/handler/agentregister.go | 2 +- lambda/rapi/handler/runtimelogs.go | 4 ++-- lambda/rapid/handlers.go | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 6b66e79..077cf31 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ DESTINATION_old:= bin/${BINARY_NAME} DESTINATION_x86_64 := bin/${BINARY_NAME}-x86_64 DESTINATION_arm64 := bin/${BINARY_NAME}-arm64 -run_in_docker = docker run --env GOPROXY=direct -v $(shell pwd):/LambdaRuntimeLocal -w /LambdaRuntimeLocal golang:1.22 $(1) +run_in_docker = docker run --env GOPROXY=direct -v $(shell pwd):/LambdaRuntimeLocal -w /LambdaRuntimeLocal golang:1.24 $(1) compile-with-docker-all: $(call run_in_docker, make compile-lambda-linux-all) diff --git a/go.mod b/go.mod index 4ee45d7..5519b8c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module go.amzn.com -go 1.22 +go 1.24 require ( github.com/aws/aws-lambda-go v1.46.0 diff --git a/lambda/rapi/handler/agentnext.go b/lambda/rapi/handler/agentnext.go index 7ce76f0..ffdd61d 100644 --- a/lambda/rapi/handler/agentnext.go +++ b/lambda/rapi/handler/agentnext.go @@ -48,7 +48,7 @@ func (h *agentNextHandler) ServeHTTP(writer http.ResponseWriter, request *http.R } } else { log.Warnf("Unknown agent %s tried to call /next", agentID.String()) - rendering.RenderForbiddenWithTypeMsg(writer, request, errAgentIdentifierUnknown, "Unknown extension"+agentID.String()) + rendering.RenderForbiddenWithTypeMsg(writer, request, errAgentIdentifierUnknown, "Unknown extension %s", agentID.String()) return } diff --git a/lambda/rapi/handler/agentregister.go b/lambda/rapi/handler/agentregister.go index 8da9e4c..867ad9d 100644 --- a/lambda/rapi/handler/agentregister.go +++ b/lambda/rapi/handler/agentregister.go @@ -77,7 +77,7 @@ func (h *agentRegisterHandler) ServeHTTP(writer http.ResponseWriter, request *ht registerRequest, err := parseRegister(request) if err != nil { - rendering.RenderForbiddenWithTypeMsg(writer, request, errInvalidRequestFormat, err.Error()) + rendering.RenderForbiddenWithTypeMsg(writer, request, errInvalidRequestFormat, "%s", err.Error()) return } diff --git a/lambda/rapi/handler/runtimelogs.go b/lambda/rapi/handler/runtimelogs.go index 6b8a67e..4fd534e 100644 --- a/lambda/rapi/handler/runtimelogs.go +++ b/lambda/rapi/handler/runtimelogs.go @@ -30,7 +30,7 @@ func (h *runtimeLogsHandler) ServeHTTP(writer http.ResponseWriter, request *http log.Errorf("Agent Verification Error: %s", err) switch err := err.(type) { case *ErrAgentIdentifierUnknown: - rendering.RenderForbiddenWithTypeMsg(writer, request, errAgentIdentifierUnknown, "Unknown extension "+err.agentID.String()) + rendering.RenderForbiddenWithTypeMsg(writer, request, errAgentIdentifierUnknown, "Unknown extension %s", err.agentID.String()) h.telemetrySubscription.RecordCounterMetric(telemetry.SubscribeClientErr, 1) default: rendering.RenderInternalServerError(writer, request) @@ -55,7 +55,7 @@ func (h *runtimeLogsHandler) ServeHTTP(writer http.ResponseWriter, request *http switch err { case telemetry.ErrTelemetryServiceOff: rendering.RenderForbiddenWithTypeMsg(writer, request, - h.telemetrySubscription.GetServiceClosedErrorType(), h.telemetrySubscription.GetServiceClosedErrorMessage()) + h.telemetrySubscription.GetServiceClosedErrorType(), "%s", h.telemetrySubscription.GetServiceClosedErrorMessage()) h.telemetrySubscription.RecordCounterMetric(telemetry.SubscribeClientErr, 1) default: rendering.RenderInternalServerError(writer, request) diff --git a/lambda/rapid/handlers.go b/lambda/rapid/handlers.go index f379c4c..2e759e9 100644 --- a/lambda/rapid/handlers.go +++ b/lambda/rapid/handlers.go @@ -243,7 +243,7 @@ func (c *rapidContext) watchEvents(events <-chan supvmodel.Event) { if termination.Success() { err = fmt.Errorf("exit code 0") } else { - err = fmt.Errorf(termination.String()) + err = fmt.Errorf("%s", termination.String()) } appctx.StoreFirstFatalError(c.appCtx, fatalerror.AgentCrash) @@ -851,7 +851,7 @@ func handleRestore(execCtx *rapidContext, restore *interop.Restore) (interop.Res // check if there is any error stored in appctx to get the root cause error type // Runtime.ExitError is an example to such a scenario if fatalErrorFound { - err = fmt.Errorf(string(fatalErrorType)) + err = fmt.Errorf("%s", string(fatalErrorType)) } if err != nil { From 85e53022a36cf95bc7f06146fa53617eb9d652f6 Mon Sep 17 00:00:00 2001 From: Frederic Mbea <117131783+mbfreder@users.noreply.github.com> Date: Fri, 8 Aug 2025 14:45:54 -0700 Subject: [PATCH 3/5] chore(deps): Update go-chi to v5.2.2 (#149) * chore(deps): Update go-chi to v5.2.2 --- go.mod | 2 +- go.sum | 4 ++-- lambda/core/directinvoke/directinvoke.go | 2 +- lambda/core/directinvoke/directinvoke_test.go | 2 +- lambda/rapi/handler/invocationerror.go | 2 +- lambda/rapi/handler/invocationerror_test.go | 2 +- lambda/rapi/handler/invocationresponse.go | 2 +- lambda/rapi/middleware/middleware.go | 2 +- lambda/rapi/middleware/middleware_test.go | 2 +- lambda/rapi/router.go | 2 +- lambda/rapi/server.go | 2 +- lambda/rapidcore/standalone/middleware.go | 2 +- lambda/rapidcore/standalone/router.go | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index 5519b8c..5118f72 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.24 require ( github.com/aws/aws-lambda-go v1.46.0 - github.com/go-chi/chi v1.5.5 + github.com/go-chi/chi/v5 v5.2.2 github.com/google/uuid v1.6.0 github.com/jessevdk/go-flags v1.5.0 github.com/sirupsen/logrus v1.9.3 diff --git a/go.sum b/go.sum index 8974775..9fd0886 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ github.com/aws/aws-lambda-go v1.46.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7Rfg github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-chi/chi v1.5.5 h1:vOB/HbEMt9QqBqErz07QehcOKHaWFtuj87tTDVz2qXE= -github.com/go-chi/chi v1.5.5/go.mod h1:C9JqLr3tIYjDOZpzn+BCuxY8z8vmca43EeMgyZt7irw= +github.com/go-chi/chi/v5 v5.2.2 h1:CMwsvRVTbXVytCk1Wd72Zy1LAsAh9GxMmSNWLHCG618= +github.com/go-chi/chi/v5 v5.2.2/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= diff --git a/lambda/core/directinvoke/directinvoke.go b/lambda/core/directinvoke/directinvoke.go index 3510132..6b97cbe 100644 --- a/lambda/core/directinvoke/directinvoke.go +++ b/lambda/core/directinvoke/directinvoke.go @@ -11,7 +11,7 @@ import ( "strconv" "strings" - "github.com/go-chi/chi" + "github.com/go-chi/chi/v5" "go.amzn.com/lambda/core/bandwidthlimiter" "go.amzn.com/lambda/fatalerror" "go.amzn.com/lambda/interop" diff --git a/lambda/core/directinvoke/directinvoke_test.go b/lambda/core/directinvoke/directinvoke_test.go index 94b6323..e6646bf 100644 --- a/lambda/core/directinvoke/directinvoke_test.go +++ b/lambda/core/directinvoke/directinvoke_test.go @@ -17,7 +17,7 @@ import ( "testing" "time" - "github.com/go-chi/chi" + "github.com/go-chi/chi/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.amzn.com/lambda/fatalerror" diff --git a/lambda/rapi/handler/invocationerror.go b/lambda/rapi/handler/invocationerror.go index d434461..afd346d 100644 --- a/lambda/rapi/handler/invocationerror.go +++ b/lambda/rapi/handler/invocationerror.go @@ -18,7 +18,7 @@ import ( "go.amzn.com/lambda/core" "go.amzn.com/lambda/rapi/rendering" - "github.com/go-chi/chi" + "github.com/go-chi/chi/v5" log "github.com/sirupsen/logrus" ) diff --git a/lambda/rapi/handler/invocationerror_test.go b/lambda/rapi/handler/invocationerror_test.go index 72e6719..76a3b4e 100644 --- a/lambda/rapi/handler/invocationerror_test.go +++ b/lambda/rapi/handler/invocationerror_test.go @@ -19,7 +19,7 @@ import ( "go.amzn.com/lambda/rapi/model" "go.amzn.com/lambda/testdata" - "github.com/go-chi/chi" + "github.com/go-chi/chi/v5" "github.com/stretchr/testify/assert" ) diff --git a/lambda/rapi/handler/invocationresponse.go b/lambda/rapi/handler/invocationresponse.go index d267775..ba08b14 100644 --- a/lambda/rapi/handler/invocationresponse.go +++ b/lambda/rapi/handler/invocationresponse.go @@ -12,7 +12,7 @@ import ( "go.amzn.com/lambda/interop" "go.amzn.com/lambda/rapi/rendering" - "github.com/go-chi/chi" + "github.com/go-chi/chi/v5" log "github.com/sirupsen/logrus" ) diff --git a/lambda/rapi/middleware/middleware.go b/lambda/rapi/middleware/middleware.go index d45798b..a83a232 100644 --- a/lambda/rapi/middleware/middleware.go +++ b/lambda/rapi/middleware/middleware.go @@ -12,7 +12,7 @@ import ( "go.amzn.com/lambda/rapi/handler" "go.amzn.com/lambda/rapi/rendering" - "github.com/go-chi/chi" + "github.com/go-chi/chi/v5" "go.amzn.com/lambda/appctx" log "github.com/sirupsen/logrus" diff --git a/lambda/rapi/middleware/middleware_test.go b/lambda/rapi/middleware/middleware_test.go index a0b9134..51c9a90 100644 --- a/lambda/rapi/middleware/middleware_test.go +++ b/lambda/rapi/middleware/middleware_test.go @@ -12,7 +12,7 @@ import ( "net/http/httptest" "testing" - "github.com/go-chi/chi" + "github.com/go-chi/chi/v5" "github.com/google/uuid" "github.com/stretchr/testify/assert" "go.amzn.com/lambda/appctx" diff --git a/lambda/rapi/router.go b/lambda/rapi/router.go index dc036bc..9933550 100644 --- a/lambda/rapi/router.go +++ b/lambda/rapi/router.go @@ -11,7 +11,7 @@ import ( "go.amzn.com/lambda/rapi/middleware" "go.amzn.com/lambda/telemetry" - "github.com/go-chi/chi" + "github.com/go-chi/chi/v5" "go.amzn.com/lambda/core" "go.amzn.com/lambda/rapi/rendering" diff --git a/lambda/rapi/server.go b/lambda/rapi/server.go index d17270a..aafc295 100644 --- a/lambda/rapi/server.go +++ b/lambda/rapi/server.go @@ -9,7 +9,7 @@ import ( "net" "net/http" - "github.com/go-chi/chi" + "github.com/go-chi/chi/v5" "go.amzn.com/lambda/appctx" "go.amzn.com/lambda/core" diff --git a/lambda/rapidcore/standalone/middleware.go b/lambda/rapidcore/standalone/middleware.go index 06baae3..4465a40 100644 --- a/lambda/rapidcore/standalone/middleware.go +++ b/lambda/rapidcore/standalone/middleware.go @@ -6,7 +6,7 @@ package standalone import ( "net/http" - "github.com/go-chi/chi/middleware" + "github.com/go-chi/chi/v5/middleware" log "github.com/sirupsen/logrus" ) diff --git a/lambda/rapidcore/standalone/router.go b/lambda/rapidcore/standalone/router.go index 7957c32..c0b8fc1 100644 --- a/lambda/rapidcore/standalone/router.go +++ b/lambda/rapidcore/standalone/router.go @@ -12,7 +12,7 @@ import ( "go.amzn.com/lambda/rapidcore" "go.amzn.com/lambda/rapidcore/standalone/telemetry" - "github.com/go-chi/chi" + "github.com/go-chi/chi/v5" ) type InteropServer interface { From e5440b64bd74cefd3a70aaff9c7615343ea700f5 Mon Sep 17 00:00:00 2001 From: Frederic Mbea <117131783+mbfreder@users.noreply.github.com> Date: Mon, 11 Aug 2025 15:37:02 -0700 Subject: [PATCH 4/5] Update workflow to run integ-tests in main (#151) --- .github/workflows/integ-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integ-tests.yml b/.github/workflows/integ-tests.yml index 7fddc95..92be22e 100644 --- a/.github/workflows/integ-tests.yml +++ b/.github/workflows/integ-tests.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - develop + - main jobs: go-tests: From c17162c6dd23541f71e7cf529868f51f397e309e Mon Sep 17 00:00:00 2001 From: Roger Zhang Date: Tue, 16 Sep 2025 15:06:58 -0700 Subject: [PATCH 5/5] Update README.md to make it clear RIE binary is meant to be used in linux env (#152) --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3599cc0..3a37485 100644 --- a/README.md +++ b/README.md @@ -31,15 +31,16 @@ Lambda’s orchestrator, or security and authentication configurations. You can ## Installing -Instructions for installing AWS Lambda Runtime Interface Emulator for your platform +The following commands download the RIE binary for your platform. Note that while you can download the binary on any platform, the RIE can only be executed in a Linux environment (typically within a Docker container). -| Platform | Command to install | +| Platform (for downloading) | Command to download | |---------|--------- | macOS/Linux x86\_64 | `mkdir -p ~/.aws-lambda-rie && curl -Lo ~/.aws-lambda-rie/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie && chmod +x ~/.aws-lambda-rie/aws-lambda-rie` | | macOS/Linux arm64 | `mkdir -p ~/.aws-lambda-rie && curl -Lo ~/.aws-lambda-rie/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie-arm64 && chmod +x ~/.aws-lambda-rie/aws-lambda-rie` | | Windows x86\_64 | `Invoke-WebRequest -OutFile 'C:\Program Files\aws lambda\aws-lambda-rie' https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie` | | Windows arm64 | `Invoke-WebRequest -OutFile 'C:\Program Files\aws lambda\aws-lambda-rie' https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie-arm64` | +After downloading, the RIE binary must be used within a Linux environment, typically as part of a Docker container setup. See the Docker configuration instructions below for proper implementation. ## Getting started