-
Notifications
You must be signed in to change notification settings - Fork 619
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
Update error response codes for v4 metadata and stats endpoints #3644
Conversation
157e3e3
to
c1bec29
Compare
5a8e31f
to
b46da10
Compare
b562751
to
5fdcb0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to have these tests! LGTM.
} | ||
|
||
// Tests that v4 stats endpoints return a 500 error on unexpected failures | ||
func TestV4Stats500Error(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if we can cover all other v4 endpoints as well for 500? like the task metadata, container metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's a great idea. I will add new tests for other endpoints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added new test cases.
Summary
Implements changes for ECS/EC2 proposed in aws/containers-roadmap#2001. The proposal is for fixing misleading error response codes for v4 metadata and stats endpoints and align them with ECS/Fargate's codes.
With these changes
404 Not Found
is returned when the task/container was not found instead of500 Internal Server Error
and400 Bad Request
that are returned currently, and500 Internal Server Error
is returned for unexpected failures instead of400 Bad Request
that is returned for some endpoints currently.Implementation details
404 Not Found
response code on lookup failures.500 Internal Server Error
on unexpected failures.500 Internal Server Error
.Testing
New unit tests are added to cover all the changes. Existing unit tests are updated as needed.
Also tested changes for container/task not found cases manually by installing ECS Agent from source on an EC2 machine and sending requests with a bad
v3EndpointID
to TMDE. Results are shown below.Before
After
New tests cover the changes: yes
Description for the changelog
Fix misleading error response codes for v4 metadata and stats endpoints for TMDE. The endpoints will now return a
404 Not Found
error code when task/container is not found and a500 Internal Server Error
on unexpected failures. TMDE clients that branch logic based on error response status codes will behave differently. For example, clients that retry on 5XX errors but not on 4XX errors will no longer perform futile retries.Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.