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

Clean up --config-only networks after --config-from networks have ungracefully exited #2373

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,11 +706,17 @@ const overlayDSROptionString = "dsr"
// NewNetwork creates a new network of the specified network type. The options
// are network specific and modeled in a generic way.
func (c *controller) NewNetwork(networkType, name string, id string, options ...NetworkOption) (Network, error) {
var (
cap *driverapi.Capability
err error
t *network
)

if id != "" {
c.networkLocker.Lock(id)
defer c.networkLocker.Unlock(id)

if _, err := c.NetworkByID(id); err == nil {
if _, err = c.NetworkByID(id); err == nil {
return nil, NetworkNameError(id)
}
}
Expand Down Expand Up @@ -739,15 +745,10 @@ func (c *controller) NewNetwork(networkType, name string, id string, options ...
}

network.processOptions(options...)
if err := network.validateConfiguration(); err != nil {
if err = network.validateConfiguration(); err != nil {
return nil, err
}

var (
cap *driverapi.Capability
err error
)

// Reset network types, force local scope and skip allocation and
// plumbing for configuration networks. Reset of the config-only
// network drivers is needed so that this special network is not
Expand Down Expand Up @@ -794,11 +795,11 @@ func (c *controller) NewNetwork(networkType, name string, id string, options ...
// From this point on, we need the network specific configuration,
// which may come from a configuration-only network
if network.configFrom != "" {
t, err := c.getConfigNetwork(network.configFrom)
t, err = c.getConfigNetwork(network.configFrom)
if err != nil {
return nil, types.NotFoundErrorf("configuration network %q does not exist", network.configFrom)
}
if err := t.applyConfigurationTo(network); err != nil {
if err = t.applyConfigurationTo(network); err != nil {
return nil, types.InternalErrorf("Failed to apply configuration: %v", err)
}
defer func() {
Expand Down