Implement missing network api options for v1.22#484
Implement missing network api options for v1.22#484marcuslinke merged 1 commit intodocker-java:masterfrom
Conversation
be71e31 to
9b37a00
Compare
Current coverage is 21.37%
@@ master #484 diff @@
=======================================
Files 296 290 -6
Lines 6125 6017 -108
Methods 0 0
Branches 532 535 +3
=======================================
- Hits 1459 1286 -173
- Misses 4581 4648 +67
+ Partials 85 83 -2
|
9b37a00 to
14dec7a
Compare
|
Uhh, used the wrong object... I have fixed that! |
|
I will review and continue 1.22 sync after i resolve and merge my PR. |
|
please rebase |
14dec7a to
e3c4675
Compare
|
I have rebased onto the master. Tested against our cluster and still works for me ;-) |
e3c4675 to
01ad30b
Compare
| */ | ||
| @Override | ||
| public CreateContainerResponse exec() throws NotFoundException, ConflictException { | ||
| //code flow taken from https://github.com/docker/docker/blob/master/runconfig/opts/parse.go |
There was a problem hiding this comment.
I doubt that this logic should be part of the command. Commands in general are just dumb wrappers of the appropriate remote API resource (here: https://docs.docker.com/engine/reference/api/docker_remote_api_v1.22/#create-a-container). They should only take arguments/parameters that are needed to execute the request and nothing else.
There was a problem hiding this comment.
Had no time to end review, but i also against of extra logic. In general would be glad to see models and porcelain API separation in future.
There was a problem hiding this comment.
So what is your suggestion to handle this properly? The problem is, that links must be set on different objects, whenever the link is made on the old legacy network or on a new user defined network.
I'm also not very happy with this lines of code, but i do not have any better idea up to now
There was a problem hiding this comment.
Set them from client side? The idea of exec() and CMD is to do the call just by sending defined objects.
There was a problem hiding this comment.
You mean, that the user must know this kind of internal logic docker requires?
It is bad design by dockers remote api, because it is not abstracted by the api.
It tooks me really a lot of time to figure out this issue. And it is not documented anywhere. The docker cli takes the same --link argument for new and old networks and handle it in the client.
There was a problem hiding this comment.
So what is your suggestion? Completely remove the CreateContainerCmd#withLinks method and expose the HostConfig and ContainerNetwork directly? And how you would like to expose the ContainerNetwork? CreateContainerCmd#withContainerNetwork() will not work if i follow your guideline, since it must be set on an Map under a key which has the same name as the user defined network. In addition using any other keys on this Map has no effect.
The Remote API is really not developer friendly and it is not understandable right form the API when to use HostConfig#withLinks or ContainerNetwork#withLinks. And since network API is the great new feature of docker it should get a good usable API.
There was a problem hiding this comment.
So how to continue? It will be also okay for me, if we expose the two objects directly and remove the CreateContainerCmd#withLink and other HostConfig delegating methods. I can make this changes in this pull requests, if you like?
There was a problem hiding this comment.
Maybe place additional methods in CMD, then ExecCmd wouldn't be filled with logic that would never allow set plain model data?
There was a problem hiding this comment.
The main problem is, that the CMD is a builder and therefore should be call independent.
Let me explain the main issue i have by implementing the logic directly in the CreateContainerCmd#withLinks method.
//will correctly create links on myNet
client.createContainerCmd(...)
.withNetworkMode("myNet")
.withLinks(...)
//will faulty create links on the legacy bridge
client.createContainerCmd(...)
.withLinks(...)
.withNetworkMode("myNet")The issue is that the decision can't be made in the #withLinks method, because we do not know which NetworkMode is finally used.
There was a problem hiding this comment.
Maybe create additional cmd method that will "update references" between objects after they was set?
|
Could you implement tests? |
|
@fbuecklers If you could provide some integration test I'm sure we will find a way to integrate your PR. |
add missing network options add tests
01ad30b to
4d60550
Compare
|
Hi, sorry for my long delay. I have add integration tests which tests the new flags and options |
|
|
||
| @JsonProperty("Config") | ||
| List<Config> config = new ArrayList<>(); | ||
| private List<Config> config = new ArrayList<>(); |
There was a problem hiding this comment.
why it need to be initialized?
This pull request is based on your wip pull request #469
I needed the additional networks options, while we are migrating to docker 1.10
I would like to give the outcome of my research back to you, since the complicated part was that docker handle links differently for the default network and user defined networks.
The most interesting part is in the CreateContainerCmdImpl#exec() method.
I do not know if it is the best place to put this specific code there. If i can help you with further tasks, please let me now it.