-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Integrate with upstream #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: localstack
Are you sure you want to change the base?
Changes from all commits
fcbb59f
41da780
8562f80
5d7c7ec
aae9602
94b1ec7
352adb7
c6aebd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,12 +14,12 @@ import ( | |
| "strings" | ||
| "time" | ||
|
|
||
| "github.com/go-chi/chi" | ||
| "github.com/aws/aws-lambda-runtime-interface-emulator/internal/lambda/core/statejson" | ||
| "github.com/aws/aws-lambda-runtime-interface-emulator/internal/lambda/interop" | ||
| "github.com/aws/aws-lambda-runtime-interface-emulator/internal/lambda/rapidcore" | ||
| "github.com/aws/aws-lambda-runtime-interface-emulator/internal/lambda/rapidcore/standalone" | ||
| "github.com/go-chi/chi/v5" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ Was this the necessary HTTP router dependency fix? Any context worth adding why we differ here?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to apply this change ourselves, given that AWS has already done that upstream? https://github.com/aws/aws-lambda-runtime-interface-emulator/pull/149/files
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is our custom interop server, not the AWS defined one. So it wouldn't be affected by the upstream changes and requires we manually change it around 🙂 |
||
| log "github.com/sirupsen/logrus" | ||
| "go.amzn.com/lambda/core/statejson" | ||
| "go.amzn.com/lambda/interop" | ||
| "go.amzn.com/lambda/rapidcore" | ||
| "go.amzn.com/lambda/rapidcore/standalone" | ||
| ) | ||
|
|
||
| type CustomInteropServer struct { | ||
|
|
@@ -52,7 +52,7 @@ func (l *LocalStackAdapter) SendStatus(status LocalStackStatus, payload []byte) | |
|
|
||
| // The InvokeRequest is sent by LocalStack to trigger an invocation | ||
| type InvokeRequest struct { | ||
| InvokeId string `json:"invoke-id"` | ||
| InvokeId string `json:"request-id"` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like that we fixed this inconsistent naming. ❓ Are we safe to ship this without breaking K8 images, which are not directly tied to LocalStack versions?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll make a corresponding change in LocalStack for this once the latest RIE changes are shipped. Then, in a single PR, we switch over RIE in addition to changing the param on |
||
| InvokedFunctionArn string `json:"invoked-function-arn"` | ||
| Payload string `json:"payload"` | ||
| TraceId string `json:"trace-id"` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,9 +10,10 @@ import ( | |
| "strings" | ||
| "time" | ||
|
|
||
| "github.com/aws/aws-lambda-runtime-interface-emulator/internal/lambda/interop" | ||
| "github.com/aws/aws-lambda-runtime-interface-emulator/internal/lambda/rapidcore" | ||
| "github.com/aws/aws-lambda-runtime-interface-emulator/internal/lambda/rie" | ||
| log "github.com/sirupsen/logrus" | ||
| "go.amzn.com/lambda/interop" | ||
| "go.amzn.com/lambda/rapidcore" | ||
| ) | ||
|
|
||
| type LsOpts struct { | ||
|
|
@@ -244,7 +245,7 @@ func main() { | |
| // start runtime init. It is important to start `InitHandler` synchronously because we need to ensure the | ||
| // notification channels and status fields are properly initialized before `AwaitInitialized` | ||
| log.Debugln("Starting runtime init.") | ||
| InitHandler(sandbox.LambdaInvokeAPI(), GetEnvOrDie("AWS_LAMBDA_FUNCTION_VERSION"), int64(invokeTimeoutSeconds), bootstrap, lsOpts.AccountId) // TODO: replace this with a custom init | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ Why is |
||
| rie.InitHandler(sandbox.LambdaInvokeAPI(), GetEnvOrDie("AWS_LAMBDA_FUNCTION_VERSION"), int64(invokeTimeoutSeconds), bootstrap) // TODO: replace this with a custom init | ||
|
|
||
| log.Debugln("Awaiting initialization of runtime init.") | ||
| if err := interopServer.delegate.AwaitInitialized(); err != nil { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package agents | ||
|
|
||
| import ( | ||
| "log/slog" | ||
| "path" | ||
| "path/filepath" | ||
|
|
||
| "github.com/aws/aws-lambda-runtime-interface-emulator/internal/lambda-managed-instances/utils" | ||
| ) | ||
|
|
||
| const ( | ||
| ExtensionsDir = "/opt/extensions" | ||
| ) | ||
|
|
||
| func ListExternalAgentPaths(fileutils utils.FileUtil, dir string, root string) []string { | ||
| var agentPaths []string | ||
| if !isCanonical(dir) || !isCanonical(root) { | ||
| slog.Warn("Agents base paths are not absolute and in canonical form", "dir", dir, "root", root) | ||
| return agentPaths | ||
| } | ||
| fullDir := path.Join(root, dir) | ||
| files, err := fileutils.ReadDirectory(fullDir) | ||
| if err != nil { | ||
| if fileutils.IsNotExist(err) { | ||
| slog.Info("The extension's directory does not exist, assuming no extensions to be loaded", "fullDir", fullDir) | ||
| } else { | ||
|
|
||
| slog.Error("Cannot list external agents", "err", err) | ||
| } | ||
|
|
||
| return agentPaths | ||
| } | ||
|
|
||
| for _, file := range files { | ||
| if !file.IsDir() { | ||
|
|
||
| p := path.Join("/", dir, file.Name()) | ||
| agentPaths = append(agentPaths, p) | ||
| } | ||
| } | ||
| return agentPaths | ||
| } | ||
|
|
||
| func isCanonical(path string) bool { | ||
| absPath, err := filepath.Abs(path) | ||
| return err == nil && absPath == path | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👍
So we basically need to change the imports to our fork instead of using upstream via
go.amzn.com. I guess these imports might be a frequent area of conflict, so it's worth documenting the rationale in our LocalStack readme.