-
Notifications
You must be signed in to change notification settings - Fork 301
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
Support "local ps" to list running local ECS task containers #779
Conversation
Manual Tests1. Nothing running locally$ dev-ecs-cli local ps
CONTAINER ID IMAGE STATUS PORTS NAMES TASKDEFINITIONARN TASKFILEPATH
$ dev-ecs-cli local ps --json
[] 2. With a task container running$ dev-ecs-cli local ps
CONTAINER ID IMAGE STATUS PORTS NAMES TASKDEFINITIONARN TASKFILEPATH
2ddaeed688aa ecs-local-other_app Up 2 seconds 0.0.0.0:6000->80/tcp /ecs-local-other_app_1 arn:aws:ecs:us-east-1:685593908319:task-definition/efe-test:1
$ dev-ecs-cli local ps --json local/ps ⬆ ✭
[
{
"Id": "2ddaeed688aac5297d13dd1dc2dda4e9a8a1baebeb4b4fc2198da783e122a023",
"Names": [
"/ecs-local-other_app_1"
],
"Image": "ecs-local-other_app",
"ImageID": "sha256:0ac30848f74a68b442cee205df0b20e8a038bb061776a1786363510dbc2c6f85",
"Command": "/bin/sh -c '/bin/bash -c 'while true; do sleep 30; done;''",
"Created": 1558723259,
"Ports": [
{
"IP": "0.0.0.0",
"PrivatePort": 80,
"PublicPort": 6000,
"Type": "tcp"
}
],
"Labels": {
"ECSLocalTask": "True",
"com.docker.compose.config-hash": "1d67f24db5737d34353d6112e9cf51d9fd5713e7e52eae81eb6c0bd9873caafc",
"com.docker.compose.container-number": "1",
"com.docker.compose.oneoff": "False",
"com.docker.compose.project": "ecs-local-other",
"com.docker.compose.service": "app",
"com.docker.compose.version": "1.23.2",
"taskDefinitionARN": "arn:aws:ecs:us-east-1:685593908319:task-definition/efe-test:1"
},
"State": "running",
"Status": "Up 34 seconds",
"HostConfig": {
"NetworkMode": "ecs-local-network"
},
"NetworkSettings": {
"Networks": {
"ecs-local-network": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "cb43b4445f11ac4e8f337f68904e3d1eb2b900b80deabe4c62cea56c063ad029",
"EndpointID": "a4b718d0cc53f171e5e5220f81d6647d24990724b7439d78be0438c2decdab97",
"Gateway": "169.254.170.1",
"IPAddress": "169.254.170.3",
"IPPrefixLen": 24,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:a9:fe:aa:03",
"DriverOpts": null
}
}
},
"Mounts": []
}
] |
|
||
// TODO These labels should be defined part of the local.Create workflow. | ||
// Refactor to import these constants instead of re-defining them here. | ||
const ( |
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.
@SoManyHs These are the Docker object labels that I'm expecting to be part of each container. Let me know if you're planing to use a different value for them :)
tests := map[string]struct { | ||
sequence []commandTest | ||
}{ | ||
"clean state": { |
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 reason why this is a table driven test?
Looks like it only has one test case...
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.
soon™ we'll have full ecs-cli local workflows as integration tests :P.
This sequence for example will make up on test case: "ecs-cli local create --arn" -> "ecs-cli local up" -> "ecs-cli local ps" -> "ecs-cli local stop"
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.
😎
// 1. read in task def (from file or arn) | ||
// 2. parse task def into go object | ||
// 3. write to docker-compose.local.yml file | ||
fmt.Println("foo") // placeholder |
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.
lol
|
||
const ( | ||
// minDockerAPIVersion is the oldest Docker API version supporting the operations used by "local" sub-commands. | ||
minDockerAPIVersion = "1.27" |
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.
How'd you pick this version?
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 picked the same version that the endpoints container requires. The operations that we use so far in "ecs local" are all supported in v1.27.
I can say that the endpoints container uses 1.27 and link to the code ?
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.
Sure 👍🏻
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.
Done!
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.
Actually I'd prefer it if the comment also said that all the operations in ecs local are supported in v1.27
Its hypothetically possible that the "ecs local" commands would need a newer Docker client version than the endpoints container.
The current comment might lead future maintainers to think that the commands and the endpoints container have to use the same Docker Client version. And that's not true.
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.
👍 makes sense, done!
Description of changes: Lists the running containers part of the ECS tasks running locally.
Enter
[N/A]
in the box, if an item is not applicable to your change.Testing
Documentation
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.