Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
ciao-controller: Update internal state after DB state
Browse files Browse the repository at this point in the history
Ensure consistency by only updating the internal state of the datastore
after the datebase state has been updated.

Signed-off-by: Rob Bradford <[email protected]>
  • Loading branch information
rbradford committed Nov 22, 2016
1 parent f2d7ca4 commit d44c862
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ciao-controller/internal/datastore/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -1503,12 +1503,6 @@ func (ds *Datastore) CreateStorageAttachment(instanceID string, blockID string,
Ephemeral: ephemeral,
}

// add it to our links map
ds.attachLock.Lock()
ds.attachments[a.ID] = a
ds.instanceVolumes[link] = a.ID
ds.attachLock.Unlock()

err := ds.db.createStorageAttachment(a)
if err != nil {
return types.StorageAttachment{}, fmt.Errorf("error creating storage attachment: %v", err)
Expand All @@ -1528,6 +1522,12 @@ func (ds *Datastore) CreateStorageAttachment(instanceID string, blockID string,
return types.StorageAttachment{}, fmt.Errorf("error creating storage attachment: %v", err)
}

// add it to our links map
ds.attachLock.Lock()
ds.attachments[a.ID] = a
ds.instanceVolumes[link] = a.ID
ds.attachLock.Unlock()

return a, nil
}

Expand Down

0 comments on commit d44c862

Please sign in to comment.