8000 Add Lambda runtime parity configuration for ulimit by joe4dev · Pull Request #7871 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

Add Lambda runtime parity configuration for ulimit #7871

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 14 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add argparse custom action refactoring comment
Requires more testing to ensure consistent behavior (e.g., with multiple arguments, empty arguments, and combinations).
  • Loading branch information
joe4dev committed Mar 20, 2023
commit 4301369969b93ecc125e79aee3daa4df92d02d3c
3 changes: 3 additions & 0 deletions localstack/utils/container_utils/container_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,9 @@ def parse_additional_flags(
:return: A DockerRunFlags object that will return new objects if respective parameters were None an 8000 d
additional flags contained a flag for that object or the same which are passed otherwise.
"""
# Argparse refactoring opportunity: custom argparse actions can be used to modularize parsing (e.g., key=value)
# https://docs.python.org/3/library/argparse.html#action

# Configure parser
parser = NoExitArgumentParser(description="Docker run flags parser")
parser.add_argument(
Expand Down
10 changes: 6 additions & 4 deletions localstack/utils/no_exit_argument_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
LOG = logging.getLogger(__name__)


# Implements the `exit_on_error=False` behavior introduced in Python 3.9 to support older Python versions
# and prevents further SystemExit for other error categories.
# Limitations of error cases: https://stackoverflow.com/a/67891066/6875981
# Subclassing workaround example: https://stackoverflow.com/a/59072378/6875981
class NoExitArgumentParser(argparse.ArgumentParser):
"""Implements the `exit_on_error=False` behavior introduced in Python 3.9 to support older Python versions
and prevents further SystemExit for other error categories.
* Limitations of error categories: https://stackoverflow.com/a/67891066/6875981
* ArgumentParser subclassing example: https://stackoverflow.com/a/59072378/6875981
"""

def exit(self, status: int = ..., message: Optional[str] = ...) -> NoReturn:
LOG.warning(f"Error in argument parser but preventing exit: {message}")

Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_dockerclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ def test_labels(self):
argument_string = r'--label ""' # assert that we gracefully handle invalid labels
flags = Util.parse_additional_flags(argument_string)
assert flags.labels == {}
argument_string = r"--label =bar" # assert that we ignore empty labels
flags = Util.parse_additional_flags(argument_string)
assert flags.labels == {}

def test_network(self):
argument_string = r'-v "/tmp/test.jar:/tmp/foo bar/test.jar" --network mynet123'
Expand Down
0