Skip to content
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

Update Boto3 API calls in ECSOperator #16050

Merged
merged 8 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions airflow/providers/amazon/aws/operators/ecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,11 @@ def _start_task(self):
self.arn = response['tasks'][0]['taskArn']

def _try_reattach_task(self):
task_def_resp = self.client.describe_task_definition(self.task_definition)
task_def_resp = self.client.describe_task_definition(taskDefinition=self.task_definition)
ecs_task_family = task_def_resp['taskDefinition']['family']

list_tasks_resp = self.client.list_tasks(
cluster=self.cluster, launchType=self.launch_type, desiredStatus='RUNNING', family=ecs_task_family
cluster=self.cluster, desiredStatus='RUNNING', family=ecs_task_family
Copy link
Contributor

Choose a reason for hiding this comment

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

How did you decide which of the two arguments to drop?

Copy link
Contributor

Choose a reason for hiding this comment

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

the op explained it in the PR description. I think it makes sense

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, must have missed that!

)
running_tasks = list_tasks_resp['taskArns']

Expand Down
6 changes: 2 additions & 4 deletions tests/providers/amazon/aws/operators/test_ecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,9 @@ def test_reattach_successful(self, launch_type, tags, start_mock, check_mock, wa
if tags:
extend_args['tags'] = [{'key': k, 'value': v} for (k, v) in tags.items()]

client_mock.describe_task_definition.assert_called_once_with('t')
client_mock.describe_task_definition.assert_called_once_with(taskDefinition='t')

client_mock.list_tasks.assert_called_once_with(
cluster='c', launchType=launch_type, desiredStatus='RUNNING', family='f'
)
client_mock.list_tasks.assert_called_once_with(cluster='c', desiredStatus='RUNNING', family='f')

start_mock.assert_not_called()
wait_mock.assert_called_once_with()
Expand Down