FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Allow manual specification of filewatcher behavior by dfangl · Pull Request #29 · localstack/lambda-runtime-init · GitHub

Allow manual specification of filewatcher behavior - #29

Merged
dfangl merged 2 commits into
localstackfrom
poller-type-config
Feb 6, 2024
Merged

Allow manual specification of filewatcher behavior#29
dfangl merged 2 commits into
localstackfrom
poller-type-config

Conversation

dfangl commented Jan 30, 2024
edited
Loading

Copy link
Copy Markdown
Member

Motivation

As seen with PR #28, there are some performance problems with the polling filewatcher.

It seems, that in newer macos versions, we have fsnotify events available as well. However, to avoid a braking change, and until we can verify what docker desktop version and which settings enable this, we are for now introducing an environment variable so users can manually override the automatic decision.

This will also be useful once we change the default behavior (e.g. with #28), to give users an option to go back to the current behavior.

Changes

  • Introduce new LOCALSTACK_FILE_WATCHER_STRATEGY config, with to possible options: event and polling. Event uses file system events, polling our poller like currently on Docker Desktop. Specifying this option will override the default handling, if it is empty, the current behavior is preserved. If set to something other than event or polling, the init binary will crash to indicate an incorrect configuration.

dominikschubert left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM with some minor nits. Let's give users a few options to fine-tune things :)

Comment thread cmd/localstack/main.go Outdated
Comment thread cmd/localstack/hotreloading.go Outdated
func NewChangeListener(debouncingInterval time.Duration) (*ChangeListener, error) {
watcher, err := filenotify.New(200 * time.Millisecond)
func NewChangeListener(debouncingInterval time.Duration, fileWatcher string) (*ChangeListener, error) {
watcher, err := filenotify.New(200*time.Millisecond, fileWatcher)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Should we maybe make the interval configurable as well while we're at it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I am kind of conflicted. On the one hand, it might make sense to do, if they want to increase it when running huge folders. On the other hand, I am not sure how much it will really impact.

dfangl merged commit ba28a02 into localstack Feb 6, 2024
dfangl deleted the poller-type-config branch February 6, 2024 09:52

joe4dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM 👍

Tested with tests.aws.services.lambda_.test_lambda_developer_tools.TestHotReloading.test_hot_reloading on macOS:

  • Both polling and event work (e.g., LAMBDA_DOCKER_FLAGS=-e LOCALSTACK_FILE_WATCHER_STRATEGY=event)
  • A wrong configuration does not crash the binary but just hangs 😒
  • I needed to bump the sleeps from 0.6 to 1 second to make the test pass on macOS

} else if fileWatcherStrategy == "polling" {
return NewPollingWatcher(interval), nil
} else {
log.Fatalf("Invalid filewatcher strategy %s. Only event and polling are allowed.\n", fileWatcherStrategy)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Would it make sense to crash the init binary rather than just log here?
Currently, it just hangs until a timeout kills the container :(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

A fatal log should indeed crash the init binary

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I see.
Then it's likely one of the error cases we do not (yet) handle actively in the init. Reporting back to LocalStack would be nice in the future to short-circuit the timeout (which is likely high when debugging).

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL