Allow task metadata endpoint to return response when certain container doesn't have network metadata #2747
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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.