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/3] 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/3] 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 9be92e099e99c9973f2e1730d1af6d4ffd769bb2 Mon Sep 17 00:00:00 2001 From: Daniel Fangl Date: Thu, 24 Apr 2025 16:33:15 +0200 Subject: [PATCH 3/3] Pull upstream changes, upgrade go to 1.24, add codeowners (#39) --- .github/workflows/build.yml | 2 +- CODEOWNERS | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 CODEOWNERS diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4603319..919a2d0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.22' + go-version: '1.24' - name: Build env: diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..e912ea1 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,2 @@ +# Add default reviewers for community PRs +* @dfangl @joe4dev @gregfurman @dominikschubert