-
Notifications
You must be signed in to change notification settings - Fork 880
Support dockerd and system restarts for ipvlan and macvlan networks #2415
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,10 +60,14 @@ func (d *driver) CreateNetwork(nid string, option map[string]interface{}, nInfo | |
// empty parent and --internal are handled the same. Set here to update k/v | ||
config.Internal = true | ||
} | ||
err = d.createNetwork(config) | ||
foundExisting, err := d.createNetwork(config) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if foundExisting { | ||
return types.InternalMaskableErrorf("restoring existing network %s", config.ID) | ||
} | ||
// update persistent db, rollback on fail | ||
err = d.storeUpdate(config) | ||
if err != nil { | ||
|
@@ -76,22 +80,34 @@ func (d *driver) CreateNetwork(nid string, option map[string]interface{}, nInfo | |
} | ||
|
||
// createNetwork is used by new network callbacks and persistent network cache | ||
func (d *driver) createNetwork(config *configuration) error { | ||
func (d *driver) createNetwork(config *configuration) (bool, error) { | ||
foundExisting := false | ||
networkList := d.getNetworks() | ||
for _, nw := range networkList { | ||
if config.Parent == nw.config.Parent { | ||
return fmt.Errorf("network %s is already using parent interface %s", | ||
getDummyName(stringid.TruncateID(nw.config.ID)), config.Parent) | ||
if config.ID != nw.config.ID { | ||
return false, fmt.Errorf("network %s is already using parent interface %s", | ||
getDummyName(stringid.TruncateID(nw.config.ID)), config.Parent) | ||
} | ||
logrus.Debugf("Create Network for the same ID %s\n", config.ID) | ||
foundExisting = true | ||
break | ||
} | ||
} | ||
if !parentExists(config.Parent) { | ||
// if the --internal flag is set, create a dummy link | ||
if config.Internal { | ||
err := createDummyLink(config.Parent, getDummyName(stringid.TruncateID(config.ID))) | ||
if err != nil { | ||
return err | ||
if !dummyLinkExists(getDummyName(stringid.TruncateID(config.ID))) { | ||
err := createDummyLink(config.Parent, getDummyName(stringid.TruncateID(config.ID))) | ||
if err != nil { | ||
return false, err | ||
} | ||
config.CreatedSlaveLink = true | ||
|
||
} else { | ||
logrus.Debugf("Dummy Link %s for ipvlan already exists", getDummyName(stringid.TruncateID(config.ID))) | ||
} | ||
config.CreatedSlaveLink = true | ||
|
||
arkodg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// notify the user in logs they have limited communications | ||
if config.Parent == getDummyName(stringid.TruncateID(config.ID)) { | ||
logrus.Debugf("Empty -o parent= and --internal flags limit communications to other containers inside of network: %s", | ||
|
@@ -100,24 +116,31 @@ func (d *driver) createNetwork(config *configuration) error { | |
} else { | ||
// if the subinterface parent_iface.vlan_id checks do not pass, return err. | ||
// a valid example is 'eth0.10' for a parent iface 'eth0' with a vlan id '10' | ||
err := createVlanLink(config.Parent) | ||
if err != nil { | ||
return err | ||
if !vlanLinkExists(config.Parent) { | ||
err := createVlanLink(config.Parent) | ||
if err != nil { | ||
return false, err | ||
} | ||
// if driver created the networks slave link, record it for future deletion | ||
config.CreatedSlaveLink = true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am hoping CreateSlaveLink will be already set to true vlanLinkExists returns True. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ip mac vlan code I see there is else condition with debug log "vlan already exists" . should we add similar log here for consistent purpose ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added the missing logs, also |
||
} else { | ||
logrus.Debugf("Parent Sub Interface %s already Exists NetID %s", config.Parent, config.ID) | ||
} | ||
// if driver created the networks slave link, record it for future deletion | ||
config.CreatedSlaveLink = true | ||
|
||
} | ||
} | ||
n := &network{ | ||
id: config.ID, | ||
driver: d, | ||
endpoints: endpointTable{}, | ||
config: config, | ||
if !foundExisting { | ||
n := &network{ | ||
id: config.ID, | ||
driver: d, | ||
endpoints: endpointTable{}, | ||
config: config, | ||
} | ||
// add the network | ||
d.addNetwork(n) | ||
} | ||
// add the *network | ||
d.addNetwork(n) | ||
|
||
return nil | ||
return foundExisting, nil | ||
} | ||
|
||
// DeleteNetwork the network for the specified driver type | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,10 +64,15 @@ func (d *driver) CreateNetwork(nid string, option map[string]interface{}, nInfo | |
// empty parent and --internal are handled the same. Set here to update k/v | ||
config.Internal = true | ||
} | ||
err = d.createNetwork(config) | ||
foundExisting, err := d.createNetwork(config) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if foundExisting { | ||
return types.InternalMaskableErrorf("restoring existing network %s", config.ID) | ||
} | ||
|
||
// update persistent db, rollback on fail | ||
err = d.storeUpdate(config) | ||
if err != nil { | ||
|
@@ -80,22 +85,32 @@ func (d *driver) CreateNetwork(nid string, option map[string]interface{}, nInfo | |
} | ||
|
||
// createNetwork is used by new network callbacks and persistent network cache | ||
func (d *driver) createNetwork(config *configuration) error { | ||
func (d *driver) createNetwork(config *configuration) (bool, error) { | ||
foundExisting := false | ||
networkList := d.getNetworks() | ||
for _, nw := range networkList { | ||
if config.Parent == nw.config.Parent { | ||
return fmt.Errorf("network %s is already using parent interface %s", | ||
getDummyName(stringid.TruncateID(nw.config.ID)), config.Parent) | ||
if config.ID != nw.config.ID { | ||
return false, fmt.Errorf("network %s is already using parent interface %s", | ||
getDummyName(stringid.TruncateID(nw.config.ID)), config.Parent) | ||
} | ||
logrus.Debugf("Create Network for the same ID %s\n", config.ID) | ||
foundExisting = true | ||
break | ||
} | ||
} | ||
if !parentExists(config.Parent) { | ||
// if the --internal flag is set, create a dummy link | ||
if config.Internal { | ||
err := createDummyLink(config.Parent, getDummyName(stringid.TruncateID(config.ID))) | ||
if err != nil { | ||
return err | ||
if !dummyLinkExists(getDummyName(stringid.TruncateID(config.ID))) { | ||
arkodg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
err := createDummyLink(config.Parent, getDummyName(stringid.TruncateID(config.ID))) | ||
if err != nil { | ||
return false, err | ||
} | ||
config.CreatedSlaveLink = true | ||
} else { | ||
logrus.Debugf("Dummy Link %s for Mac Vlan already exists", getDummyName(stringid.TruncateID(config.ID))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we have . config.CreatedSlaveLink = true in this else loop too? ( same as ipvlan code )? just to make sure "config.CreatedSlaveLink is set to True. |
||
} | ||
config.CreatedSlaveLink = true | ||
// notify the user in logs they have limited communications | ||
if config.Parent == getDummyName(stringid.TruncateID(config.ID)) { | ||
logrus.Debugf("Empty -o parent= and --internal flags limit communications to other containers inside of network: %s", | ||
|
@@ -104,24 +119,33 @@ func (d *driver) createNetwork(config *configuration) error { | |
} else { | ||
// if the subinterface parent_iface.vlan_id checks do not pass, return err. | ||
// a valid example is 'eth0.10' for a parent iface 'eth0' with a vlan id '10' | ||
err := createVlanLink(config.Parent) | ||
if err != nil { | ||
return err | ||
|
||
if !vlanLinkExists(config.Parent) { | ||
// if the subinterface parent_iface.vlan_id checks do not pass, return err. | ||
// a valid example is 'eth0.10' for a parent iface 'eth0' with a vlan id '10' | ||
err := createVlanLink(config.Parent) | ||
if err != nil { | ||
return false, err | ||
} | ||
// if driver created the networks slave link, record it for future deletion | ||
config.CreatedSlaveLink = true | ||
} else { | ||
logrus.Debugf("Parent Sub Interface %s already Exists NetID %s", config.Parent, config.ID) | ||
} | ||
// if driver created the networks slave link, record it for future deletion | ||
config.CreatedSlaveLink = true | ||
} | ||
} | ||
n := &network{ | ||
id: config.ID, | ||
driver: d, | ||
endpoints: endpointTable{}, | ||
config: config, | ||
if !foundExisting { | ||
n := &network{ | ||
id: config.ID, | ||
driver: d, | ||
endpoints: endpointTable{}, | ||
config: config, | ||
} | ||
// add the network | ||
d.addNetwork(n) | ||
} | ||
// add the *network | ||
d.addNetwork(n) | ||
|
||
return nil | ||
return foundExisting, nil | ||
} | ||
|
||
// DeleteNetwork deletes the network for the specified driver type | ||
|
Uh oh!
There was an error while loading. Please reload this page.