-
Notifications
You must be signed in to change notification settings - Fork 301
Support Docker Volume Configuration in ECS Params #587
Conversation
6a17850 to
3a7339b
Compare
| - name: string | ||
| scope: string ("shared" or "task") | ||
| autoprovision: boolean (only valid if scope = "shared") | ||
| driver: string |
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 discrete list of valid entries for this field (or others) and we can call out with a comment? Thinking about how we annotated task placement args.
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.
There are a bunch of volume plugins out there (aka volume 'drivers'), and new ones will be created in the future; and putting a list here would be misleading because ECS accepts any string for this value.
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. Thanks!
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 was referring to having comments versus parentheticals, e.g. scope: string // Valid values: "shared" | "task"
| for _, dockerVol := range ecsParams.TaskDefinition.DockerVolumes { | ||
| if dockerVol.Name != "" { | ||
| log.Info("is it right here:") | ||
| log.Info(dockerVol) |
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'm guessing the 2 comment above were for debugging and should be removed?
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.
oops...
| if dockerVol.Name != "" { | ||
| log.Info("is it right here:") | ||
| log.Info(dockerVol) | ||
| volumesWithoutHost[dockerVol.Name] = dockerVol |
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.
Seems this would override the value of a volume name specified in composeVolumes with the value of a vol with the same name specified in ecs-params. In this case, do we want to log a msg like "Using ecs-params values specified for volume %s" ?
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.
With this PR, there are no fields valid except for name from Compose, so ECS Params is adding fields, not duplicated anything, so at the moment there is no overriding happening. This might change if we support more fields from compose volumes.
| ecsVolume := &ecs.Volume{ | ||
| Name: aws.String(volName), | ||
| } | ||
| if dVol.Name != "" { |
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 we have validation before this that any volume specified in ecs-params includes a Name (or other required fields) ?
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.
...and can we add a test for error case(s) handling if/when we do add validation?
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.
Good point
| } | ||
| options := map[string]string{ | ||
| "pudding": "is Clyde's best friend", | ||
| "clyde": "is too nervous to tell her that he loves her", |
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.
😭
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 dockerVol.Name != "" { | ||
| volumesWithoutHost[dockerVol.Name] = dockerVol | ||
| } else { | ||
| return nil, fmt.Errorf("docker_volume.name is a required field") |
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 docker_volume.name is not the name of a specific ECS volume field (and the closest volume.name is listed as not required), can we rephrase this err msg to something like: "Name is required when specifying a docker volume" ?
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, I'll change it to that. I was thinking that user's would understand that docker_volume.name is the ECS Params yaml.
| - name: string | ||
| scope: string ("shared" or "task") | ||
| autoprovision: boolean (only valid if scope = "shared") | ||
| driver: string |
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 was referring to having comments versus parentheticals, e.g. scope: string // Valid values: "shared" | "task"
README.md
Outdated
| * In Docker compose version 2, the `cpu_shares`, `mem_limit`, and `mem_reservation` fields can be specified in either the compose or ECS params file. If they are specified in the ECS params file, the values will override values present in the compose file. | ||
|
|
||
| * `docker_volumes` allows you to create volumes with a [DockerVolumeConfiguration](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-volumes.html). The volumes can be referenced in your compose file by name, even if they were not also specified in the compose 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.
I wonder if this should be moved to after the example, since line 463 says "Example ecs-params.yml with service resources specified:" and it's a little confusing for that to come after the section that talks about docker_volumes when there is no example of docker volumes.
Also, the link you provide here shows the JSON for how to specify dockerVolumeConfiguration as a top-level member of a volume undervolumes, but our schema doesn't seem to quite match that. It might be useful to have a bulleted list that explains each of our fields explicitly if we're breaking from the ECS JSON schema.
Also, can you remind me again why we aren't nesting the relevant fields under the dockerVolumeConfiguration subkey?
Finally, I see in the docs there is field called host. Is that not needed here?
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 decided in the design review that docker_volumes looks nicer than having docker_volume_configuration as the key. We also decided that it looked better if all of the fields were under that key, and not to have an extra layer of nesting (which the Task Def does for backwards compatibility with the old volumes and forwards compatibility with any other types of non-docker volumes that could hypothetically be used in the future).
Host is not compatible with docker volume configuration, AFAIK. The ECS docs might actually need to be edited... let me get back to you on this.
| - name: my_volume | ||
| scope: shared | ||
| autoprovision: true | ||
| driver: doggyromcom |
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.
🐶 ❤️ 🐶
| for _, volName := range hostPaths.VolumeEmptyHost { | ||
|
|
||
| // process docker volumes | ||
| dockerVolumes := make(map[string]DockerVolume) |
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.
dockerVolumes does not appear to be used after it's populated?
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.
oh ughh oops, this is because I originally wrote this as one function and then did a bad job of copy pasting it into the separate function...
| } | ||
|
|
||
| if ecsParams != nil { | ||
| for _, dockerVol := range ecsParams.TaskDefinition.DockerVolumes { |
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.
This code seems to be a repeat of the code in lines 312-318. Could we extract that code into its own method that just has the responsibility of processing Docker Volumes from the ecs params? Then if you choose to call it before mergeVolumesWithoutHost, you can pass it into that function directly instead of re-parsing it here.
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.
oh ughh oops, this is because I originally wrote this as one function and then did a bad job of copy pasting it into the separate function...
| it: does-not-go-well | ||
| this: is-not-a-movie | ||
| labels: | ||
| pudding: mad |
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 mean, i feel like tum tum would be the mad pup in this scenario...🐶
d70b3a0 to
a872cfe
Compare
|
Tested it: Compose file: ECS Params: Mountpoints on containers: Task Def Volumes section: |
| * In Docker compose version 2, the `cpu_shares`, `mem_limit`, and `mem_reservation` fields can be specified in either the compose or ECS params file. If they are specified in the ECS params file, the values will override values present in the compose file. | ||
| * If you are using a private repository for pulling images, `repository_credentials` allows you to specify an AWS Secrets Manager secret ARN for the name of the secret containing your private repository credentials as a `credential_parameter`. | ||
|
|
||
| Example `ecs-params.yml` with service resources specified: |
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 you're removing this services example, can you add another sub-bullet under services that says something like: "See sample ecs-params.yml below for example uses."
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 that really needed? The way it reads right now is that we have the schema, then we have explanations, then we have a bunch of examples. I think that makes complete sense and there doesn't need to be a special bullet under services noting that there are examples for this field.
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 this is the case of all schema field examples (and not just that you moved or omitted the service one) than I agree it's fine as is.
6ba5a56 to
9fea4a5
Compare
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.