Skip to content

[Lambda DevX] Support for Config Hot Reloading #10

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lizard-boy
Copy link

Motivation

Currently the configuration for Lambda Debug Mode is loaded on startup and cannot be changed until the next restart of LocalStack. This may not only be inconvenient whenever changes to the configuration may be required after startup, but also means that it is impossible for the user to provide configurations for Lambda functions for which the arn is unknown before startup. Such scenario may occur when using dynamic naming in cloud formation. Hence, these changes add initial support for the hot reloading of the Lambda Debug Mode configuration file. This is achieved by updating the config when changes are detected in the file, and stopping a lambda container after evaluation iff this is being debugged. Stopping the container after evaluation is encouraged by the difficulty/feasibility or reconfiguring the container (consider ports), and has the added benefit of unblocking the scenario of debugging the same lambda function more than once.

Changes

  • Added watch and reload logic to the Lambda Debug Mode session class
  • Add environment stop after environment execution iff the lambda function being run is target of the debug session

Testing

As the development of a testing stack for Lambdas debugging is being developed, I refer to manual testing using the Lambda Debug Mode sampled provided here: localstack-samples/localstack-pro-samples#253

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR introduces hot reloading support for Lambda Debug Mode configuration in LocalStack, allowing dynamic updates without restarting the service.

  • Added file watching mechanism in lambda_debug_mode_session.py to detect and reload configuration changes
  • Implemented environment stopping after execution for debugged Lambda functions in assignment.py
  • Enhanced flexibility for debugging dynamically named Lambda functions
  • Improved error handling and logging for configuration loading issues
  • Note: Potential performance impact due to increased frequency of environment stops

2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings

Comment on lines +115 to +117
except Exception as e:
print("Lambda Debug Mode could not access the configuration file: %s", e)
epoch_now = int(time.time())
Copy link

Choose a reason for hiding this comment

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

style: Use LOG.error instead of print for consistency with error handling elsewhere in the file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants