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

Refactor introspection api to consume shared implementation #4483

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

willmyrs
Copy link

Summary

As part of the effort to bring the Agent Introspection Server to the Fargate Agent, this change refactors the agent introspection server to consume the shared implementation in ecs-agent.

Implementation details

The http server logic for the introspection server has been moved to the shared ecs-agent library. The server depends on the AgentState interface which will be implemented in the ECS and Fargate agents. The AgentState implementations will supply the server with the data it needs to construct responses. This change refactors the ECS agent's introspection server to consume the shared introspection server.

Testing

Unit and integration tests

Existing unit and integration tests have been modified, and where applicable, additional tests have been added. Existing unit tests for introspection_server in agent/handlers/v1 were moved to an integration test file with the intent to:

  1. Not lose test coverage and,
  2. Verify that the behavior on the client-end is not affected by the refactored server implementation.

Manual tests

Outputs from the Agent introspection server were recorded from two test clusters: one using the current version of the ECS agent, and the other using a modified build with the shared introspection server implementation. E.g.,

/v1/metadata

Current implementation

curl -s http://localhost:51678/v1/metadata | python3 -mjson.tool
{
    "Cluster": "ecs",
    "ContainerInstanceArn": "arn:aws:ecs:us-west-2:337909766174:container-instance/ecs/9d800cebdaba4380a21de1ec90add214",
    "Version": "Amazon ECS Agent - v1.89.2 (*41d593c6)"
}

Shared implementation

curl -s http://localhost:51678/v1/metadata | python3 -mjson.tool
{
    "Cluster": "ecs-test",
    "ContainerInstanceArn": "arn:aws:ecs:us-west-2:337909766174:container-instance/ecs-test/0f8883751d474a62aefbc3e945ad857a",
    "Version": "Amazon ECS Agent - v1.89.3 (*c46c0f4d)"
}

New tests cover the changes: yes

Description for the changelog

Enhancement - Refactor introspection api to consume shared server in ecs-agent

Additional Information

Does this PR include breaking model changes? If so, Have you added transformation functions?
No

Does this PR include the addition of new environment variables in the README?
No

Licensing

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

@willmyrs
Copy link
Author

willmyrs commented Jan 28, 2025

This PR was split off from Move introspection server to ecs-agent into two pull requests:

  1. Implement agent introspection server in ecs-agent #4482
  2. Refactor introspection server to consume shared library (this PR)

@sparrc sparrc changed the base branch from master to dev January 28, 2025 17:36
@willmyrs willmyrs marked this pull request as draft January 31, 2025 21:32
@willmyrs willmyrs force-pushed the refactor_introspection branch from ad3329f to 7ad2564 Compare February 6, 2025 19:48
@willmyrs willmyrs marked this pull request as ready for review February 7, 2025 17:55
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.

6 participants