Skip to content

Commit

Permalink
Add --memory option to paasta local-run to allow overriding of memory…
Browse files Browse the repository at this point in the history
… limit set in yelpsoa-configs.
  • Loading branch information
EvanKrall committed Apr 3, 2024
1 parent 1579952 commit 6dca06c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions paasta_tools/cli/cmds/local_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,16 @@ def add_subparser(subparsers):
required=False,
default=None,
)
list_parser.add_argument(
"--memory",
help=(
"Specify a memory limit (in megabytes) for the container."
" If not specified, the memory limit is pulled from yelpsoa-configs for your --instance/--cluster."
),
required=False,
default=None,
type=int,
)
list_parser.add_argument(
"-i",
"--instance",
Expand Down Expand Up @@ -1174,6 +1184,9 @@ def configure_and_run_docker_container(
)
return 1

if args.memory:
instance_config.config_dict["mem"] = args.memory

if docker_sha is not None:
instance_config.branch_dict = {
"git_sha": docker_sha,
Expand Down
2 changes: 2 additions & 0 deletions tests/cli/test_cmds_local_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ def test_configure_and_run_pulls_image_when_asked(
fake_instance_config.get_docker_registry.return_value = "fake_registry"
fake_instance_config.get_docker_image.return_value = "fake_image"
fake_instance_config.get_docker_url.return_value = "fake_registry/fake_image"
fake_instance_config.config_dict = {}
mock_get_instance_config.return_value = fake_instance_config
fake_service = "fake_service"
args = mock.MagicMock()
Expand Down Expand Up @@ -633,6 +634,7 @@ def test_configure_and_run_docker_container_defaults_to_interactive_instance(
args.use_okta_role = False

mock_config = mock.create_autospec(AdhocJobConfig)
mock_config.config_dict = {}
mock_get_default_interactive_config.return_value = mock_config
return_code = configure_and_run_docker_container(
docker_client=mock_docker_client,
Expand Down

0 comments on commit 6dca06c

Please sign in to comment.