Skip to content

Commit

Permalink
Ensuring endpoint resources are freed even on delete failures
Browse files Browse the repository at this point in the history
Came across a code path where we might not be releasing ip
address assigned to an endpoint if we have a failure with
deleteEndpoint. Even if there is a failure it is better to
release the resource rather than holding them. This might
lead to issues where ip never gets released even though
the container has exited and the only way of recovery is a
reload.

Signed-off-by: Abhinandan Prativadi <[email protected]>
  • Loading branch information
abhi committed Jul 24, 2017
1 parent 6426d1e commit d5bf201
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,12 @@ func (ep *endpoint) Delete(force bool) error {
logrus.Warnf("failed to recreate endpoint in store %s : %v", name, e)
}
}

ep.releaseAddress()

if err := n.getEpCnt().DecEndpointCnt(); err != nil {
logrus.Warnf("failed to decrement endpoint count for ep %s: %v", ep.ID(), err)
}
}()

// unwatch for service records
Expand All @@ -842,12 +848,6 @@ func (ep *endpoint) Delete(force bool) error {
return err
}

ep.releaseAddress()

if err := n.getEpCnt().DecEndpointCnt(); err != nil {
logrus.Warnf("failed to decrement endpoint count for ep %s: %v", ep.ID(), err)
}

return nil
}

Expand Down

0 comments on commit d5bf201

Please sign in to comment.