Skip to content

Commit d5bf201

Browse files
committed
Ensuring endpoint resources are freed even on delete failures
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]>
1 parent 6426d1e commit d5bf201

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

endpoint.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,12 @@ func (ep *endpoint) Delete(force bool) error {
833833
logrus.Warnf("failed to recreate endpoint in store %s : %v", name, e)
834834
}
835835
}
836+
837+
ep.releaseAddress()
838+
839+
if err := n.getEpCnt().DecEndpointCnt(); err != nil {
840+
logrus.Warnf("failed to decrement endpoint count for ep %s: %v", ep.ID(), err)
841+
}
836842
}()
837843

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

845-
ep.releaseAddress()
846-
847-
if err := n.getEpCnt().DecEndpointCnt(); err != nil {
848-
logrus.Warnf("failed to decrement endpoint count for ep %s: %v", ep.ID(), err)
849-
}
850-
851851
return nil
852852
}
853853

0 commit comments

Comments
 (0)