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

Make task not found error message for task protection endpoint consistent with Fargate #3748

Merged
merged 1 commit into from
Jun 12, 2023

Conversation

amogh09
Copy link
Contributor

@amogh09 amogh09 commented Jun 12, 2023

Summary

Task Protection API on ECS Agent return a different error message on task lookup failure than Fargate Agent.

ECS Agent -

404 Not Found
{
  "error": {
    "Code": "ResourceNotFoundException",
    "Message": "Invalid request: no task was found"  // <------- THIS
  }
}

Fargate Agent -

404 Not Found
{
  "error": {
    "Code": "ResourceNotFoundException",
    "Message": "Failed to find a task for the request"  // <------- THIS
  }
}

To make the experience provide by ECS Agent and Fargate Agent consistent, we are changing ECS Agent's error message to match Fargate Agent. The HTTP status code and error code in the response is not being changed, so customers depending on the codes will not be affected. Error messages are informational only and customers shouldn't be driving logic based on them.

Implementation details

  • Change the error message string used by task protection handlers when task lookup fails.
  • Update the tests.

Testing

In addition to automated tests, manually invoked GetTaskProtection and UpdateTaskProtection endpoints with an incorrect endpoint ID.

$ curl -s -XPUT http://169.254.170.2/api/bad/task-protection/v1/state -d '{"ExpiresInMinutes": 5, "ProtectionEnabled": false}' | jq
{
  "error": {
    "Code": "ResourceNotFoundException",
    "Message": "Failed to find a task for the request"
  }
}
$ curl -s http://169.254.170.2/api/bad/task-protection/v1/state | jq
{
  "error": {
    "Code": "ResourceNotFoundException",
    "Message": "Failed to find a task for the request"
  }
}

New tests cover the changes: yes

Description for the changelog

Make task not found error message for task protection endpoint consistent with Fargate

Licensing

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

@amogh09 amogh09 marked this pull request as ready for review June 12, 2023 17:56
@amogh09 amogh09 requested a review from a team as a code owner June 12, 2023 17:56
@amogh09 amogh09 merged commit 0e22645 into aws:dev Jun 12, 2023
@prateekchaudhry prateekchaudhry mentioned this pull request Jun 22, 2023
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.

4 participants