Remove only the endpoint owned interfaces
Only remove the interfaces owned by the endpoint from the sandbox when the container leaves the endpoint. Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
This commit is contained in:
parent
0d2632e0e2
commit
ea8580d1e2
1 changed files with 19 additions and 3 deletions
|
@ -326,6 +326,19 @@ func (ep *endpoint) Join(containerID string, options ...EndpointOption) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (ep *endpoint) hasInterface(iName string) bool {
|
||||
ep.Lock()
|
||||
defer ep.Unlock()
|
||||
|
||||
for _, iface := range ep.iFaces {
|
||||
if iface.srcName == iName {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (ep *endpoint) Leave(containerID string, options ...EndpointOption) error {
|
||||
var err error
|
||||
|
||||
|
@ -361,9 +374,12 @@ func (ep *endpoint) Leave(containerID string, options ...EndpointOption) error {
|
|||
|
||||
sb := ctrlr.sandboxGet(container.data.SandboxKey)
|
||||
for _, i := range sb.Interfaces() {
|
||||
err = sb.RemoveInterface(i)
|
||||
if err != nil {
|
||||
logrus.Debugf("Remove interface failed: %v", err)
|
||||
// Only remove the interfaces owned by this endpoint from the sandbox.
|
||||
if ep.hasInterface(i.SrcName) {
|
||||
err = sb.RemoveInterface(i)
|
||||
if err != nil {
|
||||
logrus.Debugf("Remove interface failed: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue