diff --git a/plugins/glusterfs/handler_volume.go b/plugins/glusterfs/handler_volume.go index 609232f6eec3b2e50ecf1983052e76bcf8714e0f..f95cb07265c5c22095f81faf5c1d135d3c5bf823 100644 --- a/plugins/glusterfs/handler_volume.go +++ b/plugins/glusterfs/handler_volume.go @@ -195,19 +195,30 @@ func (m *GlusterFSPlugin) VolumeCreate(v *requests.VolumeCreateRequest) (*reques func (m *GlusterFSPlugin) VolumeDelete(id string) error { - return m.db.Writer(func() error { - if v, ok := m.db.volumes[id]; ok { - - // :TODO: This can probably be done outside the transaction - v.Destroy() + var volume *VolumeEntry + // Remove from database, then destroy the volume + err := m.db.Writer(func() error { + if v, ok := m.db.volumes[id]; ok { + volume = v delete(m.db.volumes, id) } else { return errors.New("Volume id not found") } - return nil }) + if err != nil { + return err + } + + // Destroy volume + err = volume.Destroy() + if err != nil { + // :TODO: Add back to database with a Zombie state + return err + } + + return nil }