unnecessary if condition in nova/cmd/manage.py

Bug #1943795 reported by Rahul Singh
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
In Progress
Low
Rajesh Tailor

Bug Description

In 'nova/cmd/manage.py' file, the function '_check_orphaned_allocations_for_provider()' inside 'PlacementCommands' class has below if condition:

-------------------
class PlacementCommands(object):
...
...
    def _check_orphaned_allocations_for_provider(self, ctxt, placement,
                                                 output, provider,
                                                 delete):
        ...
        ...
        # We reset the consumer type for each allocation
        consumer_type = None
        # This is an allocation for Nova resources
        # We need to guess whether the instance was deleted
        # or if the instance is currently migrating
        if not (consumer_uuid in inst_uuids or
                consumer_uuid in mig_uuids):
            # By default we suspect the orphaned allocation was for a
            # migration...
            consumer_type = 'migration'
            if not(consumer_uuid in inst_uuids):
                # ... but if we can't find it either for an instance,
                # that means it was for this.
                consumer_type = 'instance'
        ...
--------------------

Refer: https://github.com/openstack/nova/blob/master/nova/cmd/manage.py#L2546-L2554

The first 'if' condition will be 'true' only when :
1. 'consumer_uuid' is not present in 'inst_uuids' and
2. 'consumer_uuid' is not present in 'mig_uuids'

Once this is true, the 'if' condition inside will always be 'true'. So, the 'consumer_type' will always be set to 'instance'. It will never be set to 'migration'.

tags: added: nova-manage
Revision history for this message
Balazs Gibizer (balazs-gibizer) wrote :

Analysis looks correct. Feel free to propose a small patch to remove the unnecessary if.

tags: added: low-hanging-fruit
Changed in nova:
status: New → Confirmed
importance: Undecided → Low
Rajesh Tailor (ratailor)
Changed in nova:
assignee: nobody → Rajesh Tailor (ratailor)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/nova/+/844418

Changed in nova:
status: Confirmed → In Progress
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.