Uh oh!
There was an error while loading. Please reload this page.
Fix moby/moby #37229 allowing to create networks even there are no services attached to it when deploying stacks - #1120
Fix moby/moby #37229 allowing to create networks even there are no services attached to it when deploying stacks#1120jaswdr wants to merge 3 commits into
Conversation
| network := networks[networkName] | ||
| if network.External.External { | ||
| externalNetworks = append(externalNetworks, network.Name) | ||
| continue |
There was a problem hiding this comment.
nit:
ifnetwork.External.External {
externalNetworks=append(externalNetworks, network.Name)
} else{
result[networkName] =networkCreateOptions(namespace, network)
}silvin-lubecki
commented
Jun 11, 2018
Thank you @jaswdr for this PR! The design is ok for me, what do you think of this feature @thaJeztah@vdemeester ? |
thaJeztah
commented
Jun 11, 2018
Design works for me as well; I don't think we stated that a compose file must contain services, so a file that only has networks (or other objects) should work. I see the second commit doesn't have a |
thaJeztah
commented
Jun 11, 2018
We should also have a test added for this 👍 |
jaswdr
commented
Jun 12, 2018
of course @thaJeztah, sorry for this, I will correct this now |
Signed-off-by: Jonathan A. Schweder <jonathanschweder@gmail.com>
jaswdr
commented
Jun 12, 2018
@thaJeztah done |
Signed-off-by: Jonathan A. Schweder <jonathanschweder@gmail.com>
jaswdr
commented
Jun 12, 2018
test created |
| namespace := Namespace{name: "foo"} | ||
| serviceNetworks := map[string]struct{}{} | ||
| source := networkMap{ | ||
| "normal": composetypes.NetworkConfig{ |
There was a problem hiding this comment.
I think only one NetworkConfig, whatever it is, is enough to test the feature? The test would be then more compact and less redundant.
There was a problem hiding this comment.
@silvin-lubecki did you mean, add the content of the TestNetworksCreatedWithoutServices into the TestNetworks?
There was a problem hiding this comment.
No, I meant remove all network configs except one, like named, in this test 😄
There was a problem hiding this comment.
Something like this should do the job I guess
funcTestNetworksCreatedWithoutServices(t*testing.T) {
namespace:=Namespace{name: "foo"}
serviceNetworks:=map[string]struct{}{}
source:=networkMap{
"named": composetypes.NetworkConfig{
Name: "othername",
},
}
expected:=map[string]types.NetworkCreate{
"named": {
Labels: map[string]string{
LabelNamespace: "foo",
},
},
}
networks, externals:=Networks(namespace, source, serviceNetworks)
assert.DeepEqual(t, expected, networks)
assert.DeepEqual(t, []string{"special"}, externals)
}WDYT?
There was a problem hiding this comment.
Agree, I'll change this and remove the unecessary content
Signed-off-by: Jonathan A. Schweder <jonathanschweder@gmail.com>
jaswdr
commented
Jun 13, 2018
@silvin-lubecki simplified test 😄 |
silvin-lubecki
commented
Jun 13, 2018
Thank you @jaswdr 👍 ! |
vdemeester
commented
Jun 13, 2018
The problem I can think of with this PR is that it doesn't act the same as That said I would be in favor of this PR so let me ping @shin-@dnephin and @thaJeztah to have their thoughts on that 👼 |
jaswdr
commented
Jun 13, 2018
@vdemeester if I make another PR to compose to handle the same behavior has this one, did you agree it is ok? |
vdemeester
commented
Jun 13, 2018
@jaswdr yes 👼 I wanted to have @shin-@thaJeztah or @dnephin's opinion before suggesting you that though (so that you don't work on something if we don't reach consensus on whether we wanna do that or not). |
thaJeztah
commented
Jun 21, 2018
Yes we should match the behavior in compose as well (also see my earlier comment #1120 (comment)) |
- What I did
Make
docker stack deploycreate networks even if there are no services attached to it, so you can create stack files for networks only- How I did it
Change
cli/compose/convert/compose.goto consider thenetworksmap whenservicesNetworkslenght is equals 0- How to verify it
The issue #37229 in moby repo has more information about how to reproduce the error
- Description for the changelog
Support deploy network only stacks