yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #73776
[Bug 1781430] [NEW] AllocationList.delete_all() incorrectly assumes a single consumer
Public bug reported:
AllocationList.delete_all() looks like this:
```
def delete_all(self):
# Allocations can only have a single consumer, so take advantage of
# that fact and do an efficient batch delete
consumer_uuid = self.objects[0].consumer.uuid
_delete_allocations_for_consumer(self._context, consumer_uuid)
consumer_obj.delete_consumers_if_no_allocations(
self._context, [consumer_uuid])
```
the problem with the above is that it is based on an old assumption:
that a list of allocations will only ever involve a single consumer.
This hasn't been the case ever since we introduced the ability to do
`POST /allocations` which was 1.12 or 1.13 IIRC.
The safety concern about the above is that if someone in code does this:
```
allocs = AllocationList.get_all_by_resource_provider(self.ctx, compute_node_provider)
allocs.delete_all()
```
they would reasonable expect all of the allocations for a provider to be
deleted. However, this is not the case. Only the allocations against the
"first" consumer will be deleted.
The fix is simple... check to see if there are >1 consumers in the
allocation list's objects and if so, don't call
_delete_allocations_for_consumer(). Instead, call
_delete_allocations_by_id() and do a DELETE FROM allocations WHERE id IN
(...).
** Affects: nova
Importance: High
Assignee: Jay Pipes (jaypipes)
Status: Triaged
** Tags: placement
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1781430
Title:
AllocationList.delete_all() incorrectly assumes a single consumer
Status in OpenStack Compute (nova):
Triaged
Bug description:
AllocationList.delete_all() looks like this:
```
def delete_all(self):
# Allocations can only have a single consumer, so take advantage of
# that fact and do an efficient batch delete
consumer_uuid = self.objects[0].consumer.uuid
_delete_allocations_for_consumer(self._context, consumer_uuid)
consumer_obj.delete_consumers_if_no_allocations(
self._context, [consumer_uuid])
```
the problem with the above is that it is based on an old assumption:
that a list of allocations will only ever involve a single consumer.
This hasn't been the case ever since we introduced the ability to do
`POST /allocations` which was 1.12 or 1.13 IIRC.
The safety concern about the above is that if someone in code does
this:
```
allocs = AllocationList.get_all_by_resource_provider(self.ctx, compute_node_provider)
allocs.delete_all()
```
they would reasonable expect all of the allocations for a provider to
be deleted. However, this is not the case. Only the allocations
against the "first" consumer will be deleted.
The fix is simple... check to see if there are >1 consumers in the
allocation list's objects and if so, don't call
_delete_allocations_for_consumer(). Instead, call
_delete_allocations_by_id() and do a DELETE FROM allocations WHERE id
IN (...).
To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1781430/+subscriptions
Follow ups