Skip to content
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

dockerapi: Migrated VolumeRemove and APIVersion to Docker SDK #1468

Merged
merged 1 commit into from
Jul 26, 2018
Merged

dockerapi: Migrated VolumeRemove and APIVersion to Docker SDK #1468

merged 1 commit into from
Jul 26, 2018

Conversation

voorka
Copy link
Contributor

@voorka voorka commented Jul 25, 2018

Summary

Migration for VolumeRemove and APIVersion from go-dockerclient to the DockerSDK

Implementation details

Changes were implemented by swapping API calls to new SDK Client. All changes could be done under the DockerClient interface making this migration fairly straightforward.

The VolumeRemove API call takes in a boolean for the force flag to remove a volume. Go-dockerclient did not support this flag, so 'false' is used as a placeholder.

Testing

  • Builds on Linux (make release)
  • Builds on Windows (go build -out amazon-ecs-agent.exe ./agent)
  • Unit tests on Linux (make test) pass
  • Unit tests on Windows (go test -timeout=25s ./agent/...) pass
  • Integration tests on Linux (make run-integ-tests) pass
  • Integration tests on Windows (.\scripts\run-integ-tests.ps1) pass
  • Functional tests on Linux (make run-functional-tests) pass
  • Functional tests on Windows (.\scripts\run-functional-tests.ps1) pass

New tests cover the changes: yes

Description for the changelog

Enhancement - VolumeRemove and APIVersion migrated to Docker SDK

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@voorka voorka changed the title dockerapi: Migrated VolumeRemove and APIVersion dockerapi: Migrated VolumeRemove and APIVersion to Docker SDK Jul 25, 2018
@voorka voorka requested a review from a team July 25, 2018 08:35
if err != nil {
return &CannotGetDockerClientError{version: dg.version, err: err}
}

ok := client.RemoveVolume(name)
ok := client.VolumeRemove(ctx, name, false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the third argument indicate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's means force remove: https://godoc.org/github.com/docker/docker/client#Client.VolumeRemove

The previous docker client that we use doesn't specify force remove: https://github.com/fsouza/go-dockerclient/blob/05828842f94da0aef6ad140aa3fe777d23d17139/volume.go#L123

The default is false from docker api doc:
https://docs.docker.com/engine/api/v1.36/#operation/VolumeDelete

So if the purpose is to achieve the same functionality, make it false is safe here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If removal fails for a task scoped volume, force removing it seems like the way to go. But this PR is not the right place for making this decision. We'll leave this as it is for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add this as a TODO to my development plan for this project.

@@ -1266,11 +1266,11 @@ func (dg *dockerGoClient) listPlugins(ctx context.Context) ListPluginsResponse {

// APIVersion returns the client api version
func (dg *dockerGoClient) APIVersion() (dockerclient.DockerVersion, error) {
client, err := dg.dockerClient()
client, err := dg.sdkDockerClient()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have two different clients, how do we know if APIVersion() is returning the sdk client's version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sdkDockerClient() returns the client generated by the docker/docker library. The function, FindClientAPIVersion() was changed from a for loop over all clients to an API call and therefore, FindClientAPIVersion will be called on the sdkClient. We can test this because if the go-dockerclient tried to make the API call ClientVersion() in FindClientAPIVersion, an error would be thrown because go-dockerclient does not implement this function.

@voorka voorka merged commit 2e2f18d into aws:moby Jul 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants