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

Allow task metadata endpoint to return response when certain container doesn't have network metadata #2747

Merged
merged 3 commits into from
Dec 2, 2020

Conversation

fenxiong
Copy link
Contributor

@fenxiong fenxiong commented Nov 30, 2020

Summary

Allow task metadata endpoint to return successful response when certain container doesn't have network metadata.

Currently, when one of the containers in a task doesn't have network metadata available, every container in the task gets error when calling task metadata endpoint. This is not ideal because a container does not have network metadata when:
(1) it's in the process of being created (we add it to our state, but it doesn't have network metadata yet), and sometime it takes time for docker to create a container;
(2) we times out inspecting the container, causing its network metadata to be unavailable (empty).

When we hit either of the two cases above, the task metadata endpoint becomes unavailable for every container because we return error when one of the container in the task misses network metadata.

This pull request made a change such that we don't return error in that case for v4 task metadata (for backward compatibility concern this is not added to v3).

Implementation details

Basically add back #2719 and add a unit test.

Testing

Added unit test.

For manual test, hard to directly test this because it's covering an edge/failure case, so i added some test code in agent to return error for network metadata fenxiong@8a4e912, built the agent with that, ran a task, and verified that we logged a warning, but task metadata endpoint is still available for the task:

level=warn time=2020-11-30T23:47:05Z msg="Error retrieving network metadata for container 8e8dc44164f85864408f44a95ce6be959350ac53c21ebf1775635aaeb6d77d12 - test error" module=task_metadata_handler.go
bash-4.2# curl ${ECS_CONTAINER_METADATA_URI_V4}/task | jq ".TaskARN"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2201    0  2201    0     0  2149k      0 --:--:-- --:--:-- --:--:-- 2149k
"arn:aws:ecs:us-west-2:xxx:task/test-meta-al2/xxx"

New tests cover the changes: yes

Description for the changelog

Enhancement - Allow task metadata endpoint to return metadata for task when some of the container does not have network metadata

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@fenxiong fenxiong changed the title Allow task metadata endpoint to return response when certain container doesn't have network setting Allow task metadata endpoint to return response when certain container doesn't have network metadata Nov 30, 2020
@fenxiong fenxiong requested a review from a team December 1, 2020 17:33
@fenxiong fenxiong marked this pull request as ready for review December 1, 2020 17:34
@fenxiong fenxiong added this to the 1.49.0 milestone Dec 2, 2020
@fenxiong fenxiong merged commit 866301e into aws:dev Dec 2, 2020
@fenxiong fenxiong deleted the meta branch December 2, 2020 17:28
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.

5 participants