Update group status
In the volume manager, the group status is updated before the group_id is set/unset in the volumes during update_group. This is wrong because there's a slight chance that the group could be modified after it becomes 'available' but before group_id is updated in all the volumes. This patch fixes it by updating the group status after the group_id in all volumes are updated. Closes-Bug: #1704810 Change-Id: I451db1c8c49c4319323e5e0328c89c115d6047d1
This commit is contained in:
parent
18f81357b7
commit
845cbd7dc0
|
@ -951,7 +951,9 @@ class GroupsAPITestCase(test.TestCase):
|
||||||
|
|
||||||
add_volume.destroy()
|
add_volume.destroy()
|
||||||
|
|
||||||
def test_update_group_invalid_state(self):
|
@ddt.data(fields.GroupStatus.CREATING, fields.GroupStatus.UPDATING)
|
||||||
|
def test_update_group_invalid_state(self, status):
|
||||||
|
self.group1.status = status
|
||||||
req = fakes.HTTPRequest.blank('/v3/%s/groups/%s/update' %
|
req = fakes.HTTPRequest.blank('/v3/%s/groups/%s/update' %
|
||||||
(fake.PROJECT_ID, self.group1.id),
|
(fake.PROJECT_ID, self.group1.id),
|
||||||
version=GROUP_MICRO_VERSION)
|
version=GROUP_MICRO_VERSION)
|
||||||
|
|
|
@ -3583,14 +3583,14 @@ class VolumeManager(manager.CleanableManager,
|
||||||
rem_vol.status = 'error'
|
rem_vol.status = 'error'
|
||||||
rem_vol.save()
|
rem_vol.save()
|
||||||
|
|
||||||
group.status = fields.GroupStatus.AVAILABLE
|
|
||||||
group.save()
|
|
||||||
for add_vol in add_volumes_ref:
|
for add_vol in add_volumes_ref:
|
||||||
add_vol.group_id = group.id
|
add_vol.group_id = group.id
|
||||||
add_vol.save()
|
add_vol.save()
|
||||||
for rem_vol in remove_volumes_ref:
|
for rem_vol in remove_volumes_ref:
|
||||||
rem_vol.group_id = None
|
rem_vol.group_id = None
|
||||||
rem_vol.save()
|
rem_vol.save()
|
||||||
|
group.status = fields.GroupStatus.AVAILABLE
|
||||||
|
group.save()
|
||||||
|
|
||||||
self._notify_about_group_usage(
|
self._notify_about_group_usage(
|
||||||
context, group, "update.end")
|
context, group, "update.end")
|
||||||
|
|
Loading…
Reference in New Issue