mirror of https://github.com/docker/compose.git
Ignore NotFound for external overlay networks
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
8d96980ba4
commit
344003a2f9
|
@ -42,6 +42,11 @@ class Network(object):
|
|||
|
||||
def ensure(self):
|
||||
if self.external:
|
||||
if self.driver == 'overlay':
|
||||
# Swarm nodes do not register overlay networks that were
|
||||
# created on a different node unless they're in use.
|
||||
# See docker/compose#4399
|
||||
return
|
||||
try:
|
||||
self.inspect()
|
||||
log.debug(
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import pytest
|
||||
|
||||
from .testcases import DockerClientTestCase
|
||||
from compose.config.errors import ConfigurationError
|
||||
from compose.const import LABEL_NETWORK
|
||||
from compose.const import LABEL_PROJECT
|
||||
from compose.network import Network
|
||||
|
@ -15,3 +18,20 @@ class NetworkTest(DockerClientTestCase):
|
|||
labels = net_data['Labels']
|
||||
assert labels[LABEL_NETWORK] == net.name
|
||||
assert labels[LABEL_PROJECT] == net.project
|
||||
|
||||
def test_network_external_default_ensure(self):
|
||||
net = Network(
|
||||
self.client, 'composetest', 'foonet',
|
||||
external=True
|
||||
)
|
||||
|
||||
with pytest.raises(ConfigurationError):
|
||||
net.ensure()
|
||||
|
||||
def test_network_external_overlay_ensure(self):
|
||||
net = Network(
|
||||
self.client, 'composetest', 'foonet',
|
||||
driver='overlay', external=True
|
||||
)
|
||||
|
||||
assert net.ensure() is None
|
||||
|
|
Loading…
Reference in New Issue