-
Notifications
You must be signed in to change notification settings - Fork 613
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
Set router skip clean to false #1844
Conversation
I don't see any tests in the pull request. Can you add a functional test covering this change? |
v3 tests are failing, is this causing different regression? |
Great call out! Added tests, there is actually unit tests that covers router |
Can you add a functional test as well? |
a0d61db
to
c997144
Compare
updated with functional tests |
@@ -0,0 +1,7 @@ | |||
FROM ubuntu:latest |
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.
Locking this to a version would be a good idea. We are using 16.04 at other places.
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.
make sense :)
@@ -1101,11 +1128,11 @@ func TestTaskHTTPEndpointErrorCode400(t *testing.T) { | |||
"/v3/wrong-v3-endpoint-id", | |||
"/v3/", | |||
"/v3/wrong-v3-endpoint-id/stats", | |||
"/v3//stats", | |||
"/v3/stats", |
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.
Why was this changed? Shouldn't "/v3//stats"
work as well?
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.
we handle double/muti slash with a redirect prior to 1.20.3 release. at 1.21.0 release we changed the router and added the behavior to not clean double/multi slash. This is the root cause of this issue #1839.
"networkMode": "host", | ||
"containerDefinitions": [{ | ||
"image": "127.0.0.1:51670/amazon/task-server-endpoint-validator:latest", | ||
"name": "container_1", |
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.
nit: rename this to a more descripritive one.
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.
do you have a suggestion? i thought the task definition and image name is descriptive enough and i didn't want to introduce similar/same name to cause confusion as it is the only container in the test.
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.
Ah what about something like task_server_endpoint_validator_container? 🤔
muxRouter.SkipClean(true) | ||
// Set this to false so that for request like "//v3//metadata/task" | ||
// to permanently redirect(301) to "/v3/metadata/task" handler | ||
muxRouter.SkipClean(false) |
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.
Since this defaults to false
(from the docs: SkipClean defines the path cleaning behaviour for new routes. The initial value is false.
) I initially wondered if we even need the explicit setting here.
But I like it here. It's deliberate.
I would make the comment clearer (like the one in the docs: When false, the path will be cleaned, so //v3//metadata/task will become /v3/metadata/task
)
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.
I think a 301 redirect is more clear as it is not "becoming" the new url. it is a specific 301 redirect to the new url. let me know how you think
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.
I see w.WriteHeader(http.StatusMovedPermanently)
aka 301. Cool.
@@ -1427,3 +1427,45 @@ func TestElasticInferenceValidator(t *testing.T) { | |||
exitCode, _ := task.ContainerExitcode("container_1") | |||
assert.Equal(t, 42, exitCode, fmt.Sprintf("Expected exit code of 42 for container; got %d", exitCode)) | |||
} | |||
|
|||
// TestServerEndpointValidator tests the workflow of task server endpoint | |||
func TestServerEndpointValidator(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.
Is there a particular reason you hand-wrote this code instead of using the simpletests package? I would recommend using that instead.
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.
I believe it is for setting the task iam roles configuration.
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.
Discussed with Sam offline, we might not need network mode setup for it to work.
But I'm thinking for now, let's keep test file as hand-written to release it today to solve our customers' issue. I will keep troubleshooting to see if I can make functional test work with simpletests file
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.
Task IAM roles are supported with "host", "bridge", and "awsvpc" network modes, and we have existing functional tests that validate this. There should not be a dependency on using the "host" network mode.
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.
Read some document, agree on this should not depend on host mode. I will dive deep to see if my host needs some config to make it functional test on other modes, and I will follow up with another pr to address it once i get it figured out.
@@ -0,0 +1,7 @@ | |||
FROM ubuntu:latest |
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.
If you use an image like busybox
which already includes wget
or an image like amazonlinux:2
which already includes curl
, you can avoid having to construct a new image and instead can just override the command.
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.
awesome! will change it to al2 image
scripts/setup-test-registry
Outdated
@@ -45,7 +45,7 @@ mirror_local_image() { | |||
docker rmi $2 | |||
} | |||
|
|||
for image in "amazon/amazon-ecs-netkitten" "amazon/amazon-ecs-volumes-test" "amazon/amazon-ecs-pid-namespace-test" "amazon/amazon-ecs-ipc-namespace-test" "amazon/squid" "amazon/awscli" "amazon/image-cleanup-test-image1" "amazon/image-cleanup-test-image2" "amazon/image-cleanup-test-image3" "amazon/fluentd" "amazon/amazon-ecs-agent-introspection-validator" "amazon/amazon-ecs-taskmetadata-validator" "amazon/amazon-ecs-v3-task-endpoint-validator" "amazon/amazon-ecs-container-metadata-file-validator" "amazon/amazon-ecs-elastic-inference-validator"; do | |||
for image in "amazon/amazon-ecs-netkitten" "amazon/amazon-ecs-volumes-test" "amazon/amazon-ecs-pid-namespace-test" "amazon/amazon-ecs-ipc-namespace-test" "amazon/squid" "amazon/awscli" "amazon/image-cleanup-test-image1" "amazon/image-cleanup-test-image2" "amazon/image-cleanup-test-image3" "amazon/fluentd" "amazon/amazon-ecs-agent-introspection-validator" "amazon/amazon-ecs-taskmetadata-validator" "amazon/amazon-ecs-v3-task-endpoint-validator" "amazon/amazon-ecs-container-metadata-file-validator" "amazon/amazon-ecs-elastic-inference-validator" "amazon/task-server-endpoint-validator"; do |
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.
Maybe it is trivial but I am wondering why this diff is the only line that specific changes are not highlighted in the deeper green for "amazon/task-server-endpoint-validator"? Or just it happens once in a while...
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.
not sure, maybe it is a github bug lol
could you please shorten the commit message to 75 characters or less? |
1ea6e91
to
2751aee
Compare
This will redirect request like //v2/credential to /v2/credential for the correct handler to handle it
Will do |
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.
once tests pass
failed on flaky test TestDockerStopTimeout for both linux and arm. merge the change |
Is there an issue tracking that? How long can we expect these tests to be flaky? |
It is tracked in our sprint board. |
Can you please create an issue in this repo because that's where we track these things? That way, you can tie that into releases, track when it surfaced, when it was fixed etc. Also, as a customer, or as someone who doesn't have visibility into your sprint board, it's hard to track if there's nothing in the github repo related to that. |
Github issue created. #1855 |
Summary
This enables agent to handle request like "//v2/credential" correctly. This brings back the support for //path that agent version 1.20.3 or before
#1839
Implementation details
set router skip clean to false
doc for skip clean https://godoc.org/github.com/gorilla/mux#Router.SkipClean
Testing
New tests cover the changes:
yes,
unit test, functional test
Description for the changelog
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.