Skip to content

fix: Explicitly stop ESM workers on LocalStack shutdown #12203

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

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

gregfurman
Copy link
Contributor

Motivation

ESM workers were not being explicitly shut down when LocalStack was being closed. This PR fixes this by explicilty closing all workers on the on_before_stop hook prior to the Lambda service.

Changes

  • Loop over all ESM workers and signal them for graceful shutdown in on_before_stop
  • Add a stop_for_shutdown method that signals to close the poller_loop

@gregfurman gregfurman self-assigned this Jan 29, 2025
@gregfurman gregfurman added semver: patch Non-breaking changes which can be included in patch releases aws:lambda:event-source-mapping AWS Lambda Event Source Mapping (ESM) labels Jan 29, 2025
Copy link

LocalStack Community integration with Pro

    2 files  ±  0      2 suites  ±0   1h 31m 22s ⏱️ - 19m 42s
3 085 tests  - 986  2 867 ✅  - 889  218 💤  - 97  0 ❌ ±0 
3 087 runs   - 986  2 867 ✅  - 889  220 💤  - 97  0 ❌ ±0 

Results for commit b8a9e23. ± Comparison against base commit 6d9597a.

This pull request removes 986 tests.
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_lambda_dynamodb
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_opensearch_crud
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_search_books
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_setup
tests.aws.scenario.kinesis_firehose.test_kinesis_firehose.TestKinesisFirehoseScenario ‑ test_kinesis_firehose_s3
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_destination_sns
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_infra
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_prefill_dynamodb_table
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input0-SUCCEEDED]
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input1-SUCCEEDED]
…

@gregfurman gregfurman marked this pull request as ready for review January 29, 2025 15:03
Copy link
Member

@joe4dev joe4dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What an oversight 🙀
Thank you for fixing the missing ESM shutdown during our pairing session.

Do we need to add the poller FuncThread to TMP_THREADS for eventual cleanup upon shutdown or is the current shutdown event (i.e., planned shutdown) sufficient 🤔

EventBridge Pipes needs the same fix 😬
/cc @tiurin

Copy link
Member

@dfangl dfangl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think stopping it as part of the service is preferable to using the global TMP_THREADS, nice work!

@gregfurman gregfurman merged commit 97ad700 into master Jan 29, 2025
35 of 36 checks passed
@gregfurman gregfurman deleted the fix/esm/blocking-threads branch January 29, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws:lambda:event-source-mapping AWS Lambda Event Source Mapping (ESM) semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants