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

Honor Network and IPAM plugin #1607

Merged
merged 2 commits into from
Oct 12, 2016
Merged

Honor Network and IPAM plugin #1607

merged 2 commits into from
Oct 12, 2016

Conversation

mavenugo
Copy link
Contributor

In Docker 1.12, swarmkit is hard-coded only to accept overlay network driver and builtin ipam driver. That practically eliminates all other global network and IPAM plugins.

This PR enables the network and ipam plugins be used with swarmkit as well.

@mavenugo
Copy link
Contributor Author

ping @mrjana

@aaronlehmann
Copy link
Collaborator

@mavenugo: There is a unit test failure:

--- FAIL: TestAllocateRemoteDriver (30.01s)
    Error Trace:    networkallocator_test.go:163
            networkallocator_test.go:41
            networkallocator_test.go:176
    Error:      Received unexpected error "mkdir /etc/docker: permission denied"

@mavenugo
Copy link
Contributor Author

@aaronlehmann the test fails due to privileged operation ( creating /etc/docker directory). But in order to test the plugin integration, we need that.

I added the failing test in this PR. If we cannot do privileged operation in the tests, then I would have to remove the test.

@aaronlehmann
Copy link
Collaborator

Would it be possible to rewrite this test as a Docker Engine integration test?

It's important that unit tests can run without root privileges, or touching files in /etc. I think it's really bad if running a unit test has side effects for your Docker installation.

The other thing I can think of is parameterizing this path in libnetwork, so that it doesn't have to be /etc/docker.

@mavenugo
Copy link
Contributor Author

its not a libnetwork requirement. Its the plugin infrastructure requirement.

I could move this IT out of swarmkit and move it into docker engine. That will make it simpler.

@codecov-io
Copy link

codecov-io commented Oct 10, 2016

Current coverage is 54.89% (diff: 64.70%)

Merging #1607 into master will increase coverage by 10.07%

@@             master      #1607   diff @@
==========================================
  Files            33         86     +53   
  Lines          4520      14195   +9675   
  Methods           0          0           
  Messages          0          0           
  Branches          0          0           
==========================================
+ Hits           2026       7793   +5767   
- Misses         2208       5375   +3167   
- Partials        286       1027    +741   

Sunburst

Powered by Codecov. Last update dc3dec0...2176817

@mavenugo
Copy link
Contributor Author

@aaronlehmann okay. that did it.

"github.com/docker/libnetwork/drivers/remote"
)

func getInitializers() []initializer {
Copy link
Contributor

Choose a reason for hiding this comment

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

We need a definition of this for other non-linux OSes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

remoteIpam "github.com/docker/libnetwork/ipams/remote"
)

func initIPAMDrivers(r *drvregistry.DrvRegistry, lDs, gDs interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

We will never have the datastores passed to IPAM from swarmkit so it is better to not even have these args. Just pass nil to ipam Init functions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. done

@@ -633,12 +626,26 @@ func (na *NetworkAllocator) resolveDriver(n *api.Network) (driverapi.Driver, str

d, _ := na.drvRegistry.Driver(dName)
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to ignore all local scope drivers here since a plugin may be local scope and a user might mistakenly ask for it. I know it won't even come here because of the logic in docker/docker but it is better not to assume that and just ignore local scope drivers here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. done.

@mavenugo
Copy link
Contributor Author

@mrjana PR updated with your comments addressed.

@@ -633,12 +627,31 @@ func (na *NetworkAllocator) resolveDriver(n *api.Network) (driverapi.Driver, str

d, _ := na.drvRegistry.Driver(dName)
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to check even in the case where the driver is already in driver registry because the current logic will only check the first time when the plugin is not loaded. Subsequently when the same driver name is used it will not check for the scope since it is already there in driver registry. I'd suggest moving the scope checking logic out of the d == nil { clause below and do it afterward so that it applies for both first time plugin init and subsequent references.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch. fixed it. PTAL

Signed-off-by: Madhu Venugopal <madhu@docker.com>
Signed-off-by: Madhu Venugopal <madhu@docker.com>
Copy link
Contributor

@mrjana mrjana left a comment

Choose a reason for hiding this comment

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

LGTM

@mavenugo
Copy link
Contributor Author

mavenugo commented Oct 11, 2016

ping @anusha-ragunathan Can you please review this as well ?

EDIT : BTW, Based on your comment in my docker/docker changes, I get we should not be using github.com/docker/docker/pkg/plugins package anymore. But swarmkit doesnt seem to be enabled for plugin-v2 yet (similar to your work in libnetwork) ?

@mavenugo
Copy link
Contributor Author

I checked with @anusha-ragunathan and she confirmed that plugin-v2 support is not included in swarmkit yet. So, I guess we can go with the current changes and we can update the import along with the plugin-v2 support.

@mrjana mrjana merged commit 1fed8d2 into moby:master Oct 12, 2016
@aaronlehmann
Copy link
Collaborator

This is causing TestAllocator to fail for me on master:

=== RUN   TestAllocator
WARN[0000] Unable to locate plugin: overlay, retrying in 1s
WARN[0001] Unable to locate plugin: overlay, retrying in 2s
WARN[0003] Unable to locate plugin: overlay, retrying in 4s
--- FAIL: TestAllocator (5.00s)
        allocator_test.go:485: timed out before watchNetwork found expected network state
FAIL
exit status 1
FAIL    github.com/docker/swarmkit/manager/allocator    5.017s

mavenugo added a commit to mavenugo/docker that referenced this pull request Oct 17, 2016
As of moby/swarmkit#1607, swarmkit honors
global network plugins while allocating network resources.

This IT covers the e2e integration between libnetwork, swarmkit and
docker engine to support global network-plugins for swarm-mode

Signed-off-by: Madhu Venugopal <madhu@docker.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants