openstack same_host & different_host does not take effect if specify only one uuid for the hint

Bug #1028314 reported by Guangya Liu
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Invalid
Undecided
Unassigned

Bug Description

I was using same_host and different_host as schedule hint when create new instance, but found that same_host and different_host does not take effect if only specify only one uuid for hint.

The case is as following:
1) Create a new instance and the instance uuid is ff81ed99-78bb-4285-87a0-33e12a919ebc
2) Create another instance and I want the new instance running on the same host with the first instance.
nova boot --image 796503bf-536a-4bbf-b34c-f7b302636ba4 --flavor 1 myserver --hint same_host=ff81ed99-78bb-4285-87a0-33e12a919ebc

The result is that the new instance will failed because nova cannot find a valid host, checking code for the filter.

class SameHostFilter(AffinityFilter):
    '''Schedule the instance on the same host as another instance in a set of
    of instances.
    '''

    def host_passes(self, host_state, filter_properties):
        context = filter_properties['context']
        scheduler_hints = filter_properties['scheduler_hints']
        me = host_state.host

        affinity_uuids = scheduler_hints.get('same_host', [])
        if affinity_uuids:
            return any([i for i
                          in affinity_uuids
                          if self._affinity_host(context, i) == me]) <<<<<<<<<< Here caused the problem. If only one uuid, then the filter will take affinity_uuids as f,f,8,1,e....., this caused the scheduler failed to find a target host
        # With no same_host key
        return True

Revision history for this message
Russell Bryant (russellb) wrote :

It looks like this is just a usage issue. You need to put square brackets around the single UUID.

So, instead of:

--hint same_host=ff81ed99-78bb-4285-87a0-33e12a919ebc

do:

--hint same_host=[ff81ed99-78bb-4285-87a0-33e12a919ebc]

Changed in nova:
status: New → Invalid
Revision history for this message
Russell Bryant (russellb) wrote :

Actually, it would be good to accept what you tried, as well. So I went to check the code and see that it has already been fixed. This code has since been added:

        if isinstance(affinity_uuids, basestring):
            affinity_uuids = [affinity_uuids]

So what you did will work now.

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.