Move v4 task metadata handler to ecs-agent module #3733
Merged
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
Add v4 task metadata handler to ecs-agent module and consume it in agent module. The new handler provides the same functionality as the current handler in agent module, however, it is more generic and better decouples Agent state from the HTTP handler logic.
Also add
ClockDrift
andEphemeralStorageMetrics
optional fields to v4 Task Metadata response model. These fields are not supported by ECS Agent and it won't be populating them. However, they are supported by Fargate Agent and we want to add them here for consistency.Note that the current v4 task metadata handler in agent module is not being removed in this PR as it is used for taskWithTags endpoint. We will remove it when we add taskWithTags support to ecs-agent module in future.
Implementation details
TaskMetadataHandler
function toecs-agent/tmds/handlers/v4
package. This is the v4 task metadata handler function.GetTaskMetadata
method toAgentState
interface. The handler uses this method to get task metadata from Agent in v4 format.GetTaskMetadata
method forTMDSAgentState
struct in agent module. This struct implementsAgentState
interface.ClockDrift
andEphemeralStorageMetrics
structs toecs-agent/tmds/handlers/v4
package and add them as optional fields to v4TaskResponse
.Testing
Test driven development practice was followed and unit tests for task metadata endpoints were improved in #3722 as a part of that. The improved unit tests, existing integration tests, and existing functional tests are passing.
In addition to automated tests, regression, stress, and performance testing was performed manually. For manual testing, Agent was built and run on an EC2 instance from the source in this PR. Another EC2 instance was provisioned with Agent v1.71.1.
Manual regression testing was done by calling v4 task metadata endpoints on the two instances for the same task (two replicas under a service), and the responses were compared using
diff
. No regression was detected.For stress testing, v4 task metadata endpoint was called on both instances at 3000 rps for 30 seconds. 100% success rate was achieved on both instances and no significant differences were seen in the throughput (both instances achieved ~3000 rps throughput).
For performance testing, profiling data was collected for heap and cpu usage from the two Agents while stress testing (same rate and duration as for stress testing above) v4 task metadata endpoints. No significant differences were seen in CPU and heap usage.
New tests cover the changes: yes
Description for the changelog
Move v4 task metadata handler to ecs-agent module
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.