Skip to content
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

SIGTERM events should be emitted in sandbox mode to improve testing of plugins #1485

Open
dakota002 opened this issue May 23, 2024 · 5 comments
Labels
enhancement @sandbox @architect/sandbox

Comments

@dakota002
Copy link

In trying to implement functions with graceful shutdowns like this example, it is impossible to execute cleanup functions in a way that is consistent with the expected behavior of a lambda actually running on AWS.

When invoking plugins in sandbox mode, the shutdown phase of the invoked lambda should emit (or at least have a means of emulating?) SIGTERM events.

Additional context or notes
This is the project/PR where I started running into this: nasa-gcn/gcn.nasa.gov#2248
I am invoking a tables-stream event with the invoker plugin.

@ryanblock
Copy link
Member

ryanblock commented May 23, 2024

I'm unclear, is this a bug or a feature request? Can you expand on this a bit more technically with what's not happening as you'd expect?

@lpsinger
Copy link

Our Lambda has some cleanup code that we must execute when the runtime is preparing to shut down, which we are putting in a SIGTERM or beforeExit event handler. We are requesting that Architect should simulate Lambda's lifecycle by starting a process to execute the handler and then terminating the process when the handler is done, or when the Lambda reaches its configured timeout.

@lpsinger
Copy link

In the @architect/sandbox source code, it looks like there is an undocumented coldstart function config. What does it do? If it is supported, would you please document it?

@ryanblock
Copy link
Member

Architect should simulate Lambda's lifecycle by starting a process to execute the handler and then terminating the process when the handler is done, or when the Lambda reaches its configured timeout

That is presently how Sandbox works! Perhaps this feature request should come in the form of a broken test PR to the Sandbox repo?

@ryanblock ryanblock added enhancement @sandbox @architect/sandbox labels May 23, 2024
@lpsinger
Copy link

It looks like Architect sends the child process SIGINT: https://github.com/architect/sandbox/blob/main/src/invoke-lambda/exec/spawn.js#L98-L106

However, for consistency with Lambda it should probably send SIGTERM: https://docs.aws.amazon.com/lambda/latest/dg/lambda-python.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement @sandbox @architect/sandbox
Development

No branches or pull requests

3 participants