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

Ensuring endpoint resources are freed even on delete failures #1853

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ func (ep *endpoint) Delete(force bool) error {
}
}

if err = n.getController().deleteFromStore(ep); err != nil {
if err = n.getController().deleteFromStore(ep); err != nil && !force {
return err
}

Expand Down
16 changes: 5 additions & 11 deletions sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ func (sb *sandbox) Statistics() (map[string]*types.InterfaceStatistics, error) {
}

func (sb *sandbox) Delete() error {
return sb.delete(false)
return sb.delete()
}

func (sb *sandbox) delete(force bool) error {
func (sb *sandbox) delete() error {
sb.Lock()
if sb.inDelete {
sb.Unlock()
Expand All @@ -208,10 +208,10 @@ func (sb *sandbox) delete(force bool) error {
retain := false
for _, ep := range sb.getConnectedEndpoints() {
// gw network endpoint detach and removal are automatic
if ep.endpointInGWNetwork() && !force {
if ep.endpointInGWNetwork() {
continue
}
// Retain the sanbdox if we can't obtain the network from store.
// Retain the sandbox if we can't obtain the network from store.
if _, err := c.getNetworkFromStore(ep.getNetwork().ID()); err != nil {
if c.isDistributedControl() {
retain = true
Expand All @@ -220,13 +220,7 @@ func (sb *sandbox) delete(force bool) error {
continue
}

if !force {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering, this was never done then?

Copy link
Contributor Author

@abhi abhi Aug 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be done during delete sandbox.
On the the contrary this would have been skipped during sandboxCleanup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually we should be skipping this by default now. Let me check this again.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @abhi did you check on this?

if err := ep.Leave(sb); err != nil {
logrus.Warnf("Failed detaching sandbox %s from endpoint %s: %v\n", sb.ID(), ep.ID(), err)
}
}

if err := ep.Delete(force); err != nil {
if err := ep.Delete(true); err != nil {
logrus.Warnf("Failed deleting endpoint %s: %v\n", ep.ID(), err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion sandbox_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (c *controller) sandboxCleanup(activeSandboxes map[string]interface{}) {

if _, ok := activeSandboxes[sb.ID()]; !ok {
logrus.Infof("Removing stale sandbox %s (%s)", sb.id, sb.containerID)
if err := sb.delete(true); err != nil {
if err := sb.delete(); err != nil {
logrus.Errorf("Failed to delete sandbox %s while trying to cleanup: %v", sb.id, err)
}
continue
Expand Down