-
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
handlers: Add Volumes to v1 and v2 metadata #1531
Conversation
agent/api/container/container.go
Outdated
@@ -190,6 +190,9 @@ type Container struct { | |||
// KnownPortBindingsUnsafe is an array of port bindings for the container. | |||
KnownPortBindingsUnsafe []PortBinding `json:"KnownPortBindings"` | |||
|
|||
// VolumesUnsafe is an array of volume mounts in the container. | |||
VolumesUnsafe []docker.Mount |
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.
correct me if im wrong: this ends up in the statefile yea? if yes - needs a statefile version bump?
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 field is not required in the statefile. Added json ignore tag.
i think since we add a new field in container response, the functional test for agent introspection endpoint should be updated? |
agreed with @fenxiong, the functional test for introspection endpoint should be updated as well. |
f7df7f4
to
858b13d
Compare
Updated the functional tests |
@@ -190,6 +190,9 @@ type Container struct { | |||
// KnownPortBindingsUnsafe is an array of port bindings for the container. | |||
KnownPortBindingsUnsafe []PortBinding `json:"KnownPortBindings"` | |||
|
|||
// VolumesUnsafe is an array of volume mounts in the container. | |||
VolumesUnsafe []docker.Mount `json:"-"` |
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.
Please update this unit test to cover this:
func TestSynchronizeContainerStatus(t *testing.T) { |
agent/handlers/v1/response.go
Outdated
// NewVolumesResponse creates VolumeResponse for a container | ||
func NewVolumesResponse(dockerContainer *apicontainer.DockerContainer) []VolumeResponse { | ||
container := dockerContainer.Container | ||
resp := []VolumeResponse{} |
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.
You may want to use var resp []VolumeResponse
instead, as the marshal of resp := []VolumeResponse
would be []
instead of null
.
@@ -243,6 +251,11 @@ func main() { | |||
} | |||
} | |||
|
|||
if containerMetadata.Volumes == nil { |
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.
Can you check some of the fields that were specified in the task definition?
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.
the docker name and source are difficult to be verified, since the volume name is created with some task information and random ID at the end. Hence checking for nil
here. Do you have other suggestions?
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 you can test with the shared volume, which we specify the name, and the destination should be also specified in the task definition? We may not able to specify the source though.
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.
LGTM as long as the tests pass.
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.
thanks for updating the functional test
Summary
Expose volumes metadata as part of each container in task through v1 and v2 metadata endpoint.
This addresses #1516
Implementation details
new task metadata(from functional tests):
Testing
make release
)go build -out amazon-ecs-agent.exe ./agent
)make test
) passgo test -timeout=25s ./agent/...
) passmake run-integ-tests
) pass.\scripts\run-integ-tests.ps1
) passmake run-functional-tests
) pass.\scripts\run-functional-tests.ps1
) passNew tests cover the changes: yes
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.