Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

Proposal: Roadmap to replace samalba/dockerclient with engine-api/client #1879

Closed
10 tasks done
nishanttotla opened this issue Feb 25, 2016 · 7 comments
Closed
10 tasks done

Comments

@nishanttotla
Copy link
Contributor

nishanttotla commented Feb 25, 2016

Problem

Swarm has been using samalba/dockerclient to send requests to Engines in the cluster so far. This has been a limiting factor for supporting new features of the Engine API, since dockerclient is outdated and does not fully support the current Engine API.

Solution

engine-api/client contains the officially supported Docker API, along with the relevant type structs and client. We need to be using that instead.

Challenge

All Swarm changes currently go through dockerclient, all of which need to be moved over to use engine-api, along with new using new type structs defined in engine-api/types and updating unit and integration tests. This is a large change that will take time to fully accomplish and test for correctness.

Proposal

The simplest way to start is to add a new engine-api/client object in the Engine struct in Swarm, which uses the same underlying HTTP connection that is used by dockerclient. This means that the two clients will co-exist in Swarm while using the same underlying connection.

Once this is done, we should start moving over individual API endpoints to use the new client. We must make sure that this does not affect or cause any issues to existing Swarm users, except for the addition of new features that engine-api allows us to implement.

Roadmap

The proposal will be implemented in the following steps:

Important considerations

  1. Is there a way to ensure that users can roll back to use the old client if they want, especially if things are failing? Unfortunately, it's not as simple as abstracting the client object and then choosing which client to use based on the API endpoint, because the arguments and return types are all different between dockerclient and engine-api (Thanks to @dongluochen for bringing this up)
  2. Backward compatibility will break, because engine-api and 'dockerclient` have different types, and this affects the JSON returned by the Swarm API. (Thanks to @amitshukla for bringing this up)
@nishanttotla
Copy link
Contributor Author

cc @docker/core-swarm-maintainers

@MHBauer
Copy link
Contributor

MHBauer commented Feb 25, 2016

same as #1560?

@nishanttotla
Copy link
Contributor Author

@MHBauer thanks, I'd missed that issue. We can start a fresh discussion here, and close that issue, or continue there if others prefer that.

Looking over the comments there, I can see that engine-api has been updated significantly and added a mock client, but not a nop client, though we can push for it if it's necessary.

@MHBauer
Copy link
Contributor

MHBauer commented Feb 25, 2016

I think this effort is a great testbed for how we address the needs of people outside the docker cli itself. There isn't a nopClient, but I think it should be able to be rigged up internally for now, giving it a mock type client. Definitely something we can get into engine-api if it's a pain to configure.

@nishanttotla
Copy link
Contributor Author

Here are some good comments regarding the nopclient, from an issue I opened in engine-api: docker/engine-api#117

For now, I'm going to create our own nopclient, but we could consider moving away from it in the future.

@MHBauer
Copy link
Contributor

MHBauer commented Apr 30, 2016

What I see left. I think it would be 'okay' to leave the tests, if only to have some diversity.

λ ag samalba/dockerclient --ignore vendor --ignore Godeps
api/handlers.go
27: "github.com/samalba/dockerclient"

cluster/cluster.go
7:  "github.com/samalba/dockerclient"

cluster/engine.go
28: "github.com/samalba/dockerclient"
29: "github.com/samalba/dockerclient/nopclient"

cluster/engine_test.go
20: "github.com/samalba/dockerclient"
21: "github.com/samalba/dockerclient/mockclient"
22: "github.com/samalba/dockerclient/nopclient"

cluster/mesos/cluster.go
27: "github.com/samalba/dockerclient"

cluster/swarm/cluster_test.go
15: "github.com/samalba/dockerclient/mockclient"

cluster/swarm/cluster.go
25: "github.com/samalba/dockerclient"

@nishanttotla
Copy link
Contributor Author

nishanttotla commented Apr 30, 2016

@MHBauer thanks. Based on the checklist above, all of the items you listed should fall under the following two categories

  • Passing HostConfig on /start which needs dockerclient
  • Creating the http client independent of dockerclient, which I'm currently working on, and which should allow us to get rid of most of those things

There may still be minor things left, but the major part of the work should be done.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants