testbed nova instance flavor selection

Bug #1288617 reported by Vincent Ladeuil
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu CI Engine
Confirmed
High
Vincent Ladeuil

Bug Description

Selecting the testbed nova instance flavor broke when we moved from canonistack to hpcloud because those clouds use different names.

In the general case, tests don't consume a lot of resources so we can default to m1.small for canonistack and standard.small for hpcloud (fix in progress for bug #1287955).

Points to consider:
- we want a sane default that works for supported clouds (see below),
- we need a way to override that default for specific packages/tickets while providing some way to avoid abuses (how do we prevent someone from picking an xxl image so their tests complete faster than everyone elses)

ev proposed:
from novaclient.v1_1 import client
import os
import sys

def find_flavour(client, min_vcpu, min_mem):
    '''Find the most minimal flavour that meets the vCPU and memory
    constraints.'''

    flavors = nova_client.flavors.list()
    filtered = [x for x in flavors if x.vcpus >= min_vcpu and x.ram >= min_mem]
    if len(filtered) < 1:
        msg = 'Could not find any flavors that matched the constraints'
        msg = '%s (%d vCPU, %d mem)' % (msg, min_vcpu, min_mem)
        raise KeyError, msg

    by_cpu = sorted(filtered, cmp=lambda x, y: cmp(x.vcpus, y.vcpus))
    by_mem = sorted(by_cpu, cmp=lambda x, y: cmp(x.ram, y.ram))

    return by_mem[0]

if __name__ == '__main__':
    args = [
            os.environ['OS_USERNAME'],
            os.environ['OS_PASSWORD'],
            os.environ['OS_TENANT_NAME'],
            os.environ['OS_AUTH_URL'],
    ]
    nova_client = client.Client(*args)
    print find_flavour(client, int(sys.argv[1]), int(sys.argv[2]))

Which would give us a cloud agnostic default (well, based on min_vcpu and min_mem but that's better than using cloud specific names).

Tags: airline
Vincent Ladeuil (vila)
Changed in ubuntu-ci-services-itself:
assignee: nobody → Vincent Ladeuil (vila)
Vincent Ladeuil (vila)
summary: - testbed nova instance selection
+ testbed nova instance flavor selection
Vincent Ladeuil (vila)
tags: added: airline
Changed in uci-engine:
status: New → Confirmed
importance: Undecided → High
assignee: nobody → Vincent Ladeuil (vila)
milestone: none → backlog
Evan (ev)
no longer affects: ubuntu-ci-services-itself
Vincent Ladeuil (vila)
description: updated
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.