Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add support for overriding Django container name #27

Merged
merged 2 commits into from
Oct 13, 2020

Conversation

hectcastro
Copy link
Contributor

@hectcastro hectcastro commented Oct 10, 2020

Overview

Allow users to override the previously hard-coded name of the Django enabled container inside of the provided task definition.

Closes #21

Demo

When the container name is overwritten to a container name that does not exist, the AWS ECS API returns an error:

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.7/site-packages/ecsmanage/management/commands/ecsmanage.py", line 48, in handle
    task_id = self.run_task(config, task_def_arn, security_group_id, subnet_id, cmd)
  File "/usr/local/lib/python3.7/site-packages/ecsmanage/management/commands/ecsmanage.py", line 199, in run_task
    task = self.parse_response(self.ecs_client.run_task(**kwargs), "tasks", 0)
  File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 661, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.InvalidParameterException: An error occurred (InvalidParameterException) when calling the RunTask operation: Override for container named test is not a container in the TaskDefinition.

Testing Instructions

See: opensupplyhub/open-apparel-registry#1129

@@ -164,40 +166,37 @@ def run_task(self, config, task_def_arn, security_group_id, subnet_id, cmd):
Run a task for a given task definition ARN using the given security
group and subnets, and return the task ID.
"""
overrides = {"containerOverrides": [{"name": "django", "command": cmd}]}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This variable wasn't being in multiple places, so I opted to include it in the kwargs dictionary structure.

Copy link
Contributor

@colekettler colekettler left a comment

Choose a reason for hiding this comment

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

OAR tests all pass, good to merge :shipit:

Allow users to override the previously hard-coded name of the Django
enabled container inside of the provided task definition.
@hectcastro hectcastro force-pushed the feature/hmc/override-container-name branch from 692461c to 230e3ea Compare October 13, 2020 15:32
@hectcastro hectcastro merged commit e40c980 into develop Oct 13, 2020
@hectcastro hectcastro deleted the feature/hmc/override-container-name branch October 13, 2020 16:32
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Override for container named django is not a container in the TaskDefinition
2 participants