mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
endpoint_cnt store updates should not create an object
endpoint_cnt object is created during network create and destroyed when network is deleted. But the updateToStore function creates an object when it is not present in the store. endpoint_cnt is a mutable object and is updated during endpoint create and delete events. If endpoint create or delete happens after the network is deleted, it can incorrectly create an endpoint_cnt object in the store and that can cause problems when the same network is created again later. The fix is to not create the endpoint_cnt object when endpoint_cnt is incremented or decremented Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
parent
e3048b52c7
commit
2c8670b496
2 changed files with 10 additions and 5 deletions
|
@ -138,6 +138,15 @@ func (ec *endpointCnt) setCnt(cnt uint64) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *endpointCnt) atomicIncDecEpCnt(inc bool) error {
|
func (ec *endpointCnt) atomicIncDecEpCnt(inc bool) error {
|
||||||
|
store := ec.n.getController().getStore(ec.DataScope())
|
||||||
|
if store == nil {
|
||||||
|
return fmt.Errorf("store not found for scope %s", ec.DataScope())
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp := &endpointCnt{n: ec.n}
|
||||||
|
if err := store.GetObject(datastore.Key(ec.Key()...), tmp); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
retry:
|
retry:
|
||||||
ec.Lock()
|
ec.Lock()
|
||||||
if inc {
|
if inc {
|
||||||
|
@ -149,11 +158,6 @@ retry:
|
||||||
}
|
}
|
||||||
ec.Unlock()
|
ec.Unlock()
|
||||||
|
|
||||||
store := ec.n.getController().getStore(ec.DataScope())
|
|
||||||
if store == nil {
|
|
||||||
return fmt.Errorf("store not found for scope %s", ec.DataScope())
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := ec.n.getController().updateToStore(ec); err != nil {
|
if err := ec.n.getController().updateToStore(ec); err != nil {
|
||||||
if err == datastore.ErrKeyModified {
|
if err == datastore.ErrKeyModified {
|
||||||
if err := store.GetObject(datastore.Key(ec.Key()...), ec); err != nil {
|
if err := store.GetObject(datastore.Key(ec.Key()...), ec); err != nil {
|
||||||
|
|
|
@ -256,6 +256,7 @@ retry:
|
||||||
if err := cs.GetObject(datastore.Key(kvObject.Key()...), kvObject); err != nil {
|
if err := cs.GetObject(datastore.Key(kvObject.Key()...), kvObject); err != nil {
|
||||||
return fmt.Errorf("could not update the kvobject to latest when trying to delete: %v", err)
|
return fmt.Errorf("could not update the kvobject to latest when trying to delete: %v", err)
|
||||||
}
|
}
|
||||||
|
logrus.Errorf("Error (%v) deleting object %v, retrying....", err, kvObject.Key())
|
||||||
goto retry
|
goto retry
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue