ECS Managed Instances - Parse ECS /tasks metadata endpoint#47688
Draft
ECS Managed Instances - Parse ECS /tasks metadata endpoint#47688
Conversation
Contributor
Files inventory check summaryFile checks results against ancestor 1dfe3dab: Results for datadog-agent_7.78.0~devel.git.493.7b72a79.pipeline.101754328-1_amd64.deb:No change detected |
Contributor
|
This pull request has been automatically marked as stale because it has not had activity in the past 15 days. It will be closed in 30 days if no further activity occurs. If this pull request is still relevant, adding a comment or pushing new commits will keep it open. Also, you can always reopen the pull request if you missed the window. Thank you for your contributions! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Adds support for parsing the ECS
/tasksmetadata endpoint on ECS Managed Instances, and wires the newDaemonNamefield through to workloadmeta and the orchestrator transformer.pkg/util/ecs/metadata/v3or4DaemonName stringto theTaskstruct (populated from the newDaemonNamefield in the/tasksresponse, analogous toServiceName)tasksMetadataPath = "/tasks"constant andGetTasks(ctx) ([]Task, error)to theClientinterface and implementation — calls${ECS_CONTAINER_METADATA_URI_V4}/tasksto return all host tasks in a single callcomp/core/workloadmetaDaemonName stringto theECSTaskentity indef/types.goDaemonName: task.DaemonNameinParseV4Task(collectors/util/ecs_util.go)comp/core/workloadmeta/collectors/internal/ecsparseTasksFromV4TasksEndpoint: fetches all host tasks viaGetTasks()in a single call and parses them withParseV4Task. This replaces the v1-enumerate + per-task-v4-fetch pattern.setTaskCollectionParserForDaemon: selectsparseTasksFromV4TasksEndpointwhen running on Managed Instances with a v4 endpoint availablepkg/collector/corechecks/cluster/orchestrator/transformers/ecs/task.goDaemonName: task.Task.DaemonNameinExtractECSTaskto populate the agent-payload proto fieldgo.modagent-payloadto pick updaemonName = 22in theECSTaskproto (agent-payload PR #456)Motivation
With the release of Daemon Scheduling on ECS Managed Instances, AWS has added a new host-level
/tasksendpoint that returns all tasks on the host, including aDaemonNamefield for daemon tasks.This is the agent-side prerequisite for correct
ecs_daemon_name,daemon_arn, andtask_definition_arntagging in the backend.Describe how you validated your changes
Unit tests added for:
GetTasksclient method (client_test.go)parseTasksFromV4TasksEndpointin the ECS workloadmeta collector (v4parser_test.go,daemon_parser_test.go)ExtractECSTaskwithDaemonNamepopulated (task_test.go— existing tests still pass)Additional Notes
/tasksendpoint has noWithTagsvariant, so EC2 resource tags are not collected via this path. This is expected —HasEC2ResourceTags()returns false on Managed Instances.