8000 [Lambda DevX] Control Lambda Container Startup Timeout when In Lambda Debug Mode by MEPalma · Pull Request #11398 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

[Lambda DevX] Control Lambda Container Startup Timeout when In Lambda Debug Mode #11398

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 17 commits into from
Aug 28, 2024

Conversation

MEPalma
Copy link
Contributor
@MEPalma MEPalma commented Aug 21, 2024

* Depends on #11363

Motivation

Currently, when a Lambda function is executed in debug mode, the system increases the evaluation timeout, which works well if the debugger connects after the function handler is invoked. However, this approach fails in scenarios where the debugger needs to connect during the container's startup phase, specifically when the debugger connection code resides outside the Lambda function handler.

To address this limitation, these changes propose to automatically extend the Lambda container startup timeout when the system detects it is running in Lambda Debug Mode, and the target lambda function is being debugged on some remote port.

Changes

  • Add control logic for startup timeout value

@MEPalma MEPalma added the semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases label Aug 21, 2024
@MEPalma MEPalma added this to the 3.7 milestone Aug 21, 2024
@MEPalma MEPalma self-assigned this Aug 21, 2024
Copy link
github-actions bot commented Aug 21, 2024

S3 Image Test Results (AMD64 / ARM64)

  2 files    2 suites   3m 36s ⏱️
420 tests 368 ✅  52 💤 0 ❌
840 runs  736 ✅ 104 💤 0 ❌

Results for commit e9c6081.

♻️ This comment has been updated with latest results.

Copy link
github-actions bot commented Aug 21, 2024

LocalStack Community integration with Pro

    2 files  ±  0      2 suites  ±0   1h 14m 19s ⏱️ - 19m 12s
2 495 tests  - 917  2 194 ✅  - 820  301 💤  - 97  0 ❌ ±0 
2 497 runs   - 917  2 194 ✅  - 820  303 💤  - 97  0 ❌ ±0 

Results for commit 30d07ed. ± Comparison against base commit 8068e9d.

This pull request removes 917 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]
…

♻️ This comment has been updated with latest results.

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.

Thanks for considering the startup timeout as well 👍 (I just looked at the last commit)

Kudos to @dfangl for pointing it out.

# Returns the timeout value in seconds to be enforced during lambda container startups.
# This is the value defined through LAMBDA_RUNTIME_ENVIRONMENT_TIMEOUT or the LAMBDA
# DEBUG MODE default if this is enabled.
if is_lambda_debug_timeout_for(self.function_version.qualified_arn):
Copy link
Member

Choose a reason for hiding this comment

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

I think we should create a follow-up docs PR and list the implications of the Lambda debug mode.
We could also add a debug log here to make the config adjustment traceable at runtime (similar for other potentially implicit config updates) 🤔 Do you think logging is helpful or verbose clutter @dfangl @dominikschubert?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's a nice idea to see those changes live. However, currently users are using debug mode very often, which might lead to being too verbose. As long as the config changes are limited to a handful, I think it is fine, once it gets too much, maybe one consolidated line of changes?


class LambdaDebugConfig(BaseModel):
debug_port: Optional[int] = Field(None, alias="debug-port")
timeout_disable: bool = Field(False, alias="timeout-disable")
Copy link
Member
@joe4dev joe4dev Aug 22, 2024

Choose a reason for hiding this comment

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

EDIT: wrong PR, migrated to the original PR in this new comment

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.

LGTM, thanks for adding this!

# Returns the timeout value in seconds to be enforced during lambda container startups.
# This is the value defined through LAMBDA_RUNTIME_ENVIRONMENT_TIMEOUT or the LAMBDA
# DEBUG MODE default if this is enabled.
if is_lambda_debug_timeout_for(self.function_version.qualified_arn):
Copy link
Member

Choose a reason for hiding this comment

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

I think it's a nice idea to see those changes live. However, currently users are using debug mode very often, which might lead to being too verbose. As long as the config changes are limited to a handful, I think it is fine, once it gets too much, maybe one consolidated line of changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0