Skip sending internal task events to ECS control plane #3772
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
The internal task events should not be sent to ECS control plane.
Current behavior
For a container instance that had/has run a Service Connect enabled task, ecs-agent.log will show
after ECS Agent is updated/restarted.
Here, ECS Agent will go though a list with task events, and try to make SubmitTaskStateChange API calls to submit any un-reported events to ECS control plane. As this internal task, which is designed for setting up an AppNet relay container for Service Connect, was not reported previously, ECS Agent will now try to report it to ECS control plane. However, making a STSC call will return an error because this internal task is constructed with mock data.
See how we construct this AppNet relay internal task here.
After this PR
ECS Agent will not submit internal task events to ECS control plane after it is updated/restarted. Logs shown in the "Current behavior" section will not show up in ecs-agent.log.
Implementation details
Code path
startDrainEventsTicker <- AddStateChangeEvent <- flushBatchUnsafe <- sendChange <- submitTaskEvents <- submitFirstEvent <- taskShouldBeSent
agent/eventhandler/task_handler_types.go
agent/eventhandler/task_handler_types_test.go
TestShouldTaskEventBeSent
.Testing
Manually testing
amzn2-ami-ecs-hvm-2.0.20230606-x86_64-ebs
, which has ECS Agent version 1.73.0, to an empty ECS cluster.1.71.0
on the same container instance.level=warn time=xxx msg="Could not submit task state change: [arn:::::/service-connect-relay-xxx
orlevel=error time=xxx msg="Unretriable error sending state change to ECS" xxx error="InvalidParameterException: Invalid identifier: Identifier is for cluster arn:::::. Your cluster is xxx"
New tests cover the changes: yes
Description for the changelog
Skip sending internal task events to ECS control plane
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.