← Back to team overview

openstack team mailing list archive

melange_ipam : get_tenant_id_by_net_id - possible bug (and fix)

 

Troy,

I've setup nova+quantum+mélange using devstack.
devstack creates networks using tenant_id ="default" (This in itself looks incorrect, since it should be valid UUID for one of the tenant from keystone DB - but I can imagine that stack.sh can't get UUID for demo or admin tenants easily)

So I updated nova.networks, quantum.networks and mélange.ip_blocks tables manually and put tenant_id to use UUID of the "demo" tenant.
Question : What is the right way to create network entries for "demo" tenant, that are used by nova/quantum as well as mélange DB ?
(I tried "mélange ip-block create" for 10.0.0.0/24 but I got an error that that cidr is already being used (by tenant_id="default") - so I updated the DB manually. Also this would work only take care of mélange DB - what about nova and quantum DB ?)

Once I did these changes, my instances could not launch, they would get stuck in Networking/Error state - with "NetworkNotFound" error in the logs for network UUID which I know is valid for tenant "demo"

Tracing this further, I came across the following code which tries to "get_allocated_ips" for "default" tenant, before user specified project_id
In my opinion, this is incorrect.
Once I switched the order i.e. try project_id before "default" everything started working.

Please comment whether the following code change makes sense (I'm not even sure, if I were to submit this code change - what would I write in the bug description - hence need comments from you)

diff --git a/nova/network/quantum/melange_ipam_lib.py b/nova/network/quantum/melange_ipam_lib.py
index c68d83c..ea39f60 100644
--- a/nova/network/quantum/melange_ipam_lib.py
+++ b/nova/network/quantum/melange_ipam_lib.py
@@ -152,7 +152,8 @@ class QuantumMelangeIPAMLib(object):

     def get_tenant_id_by_net_id(self, context, net_id, vif_id, project_id):
         ipam_tenant_id = None
-        tenant_ids = [FLAGS.quantum_default_tenant_id, project_id, None]
+        #tenant_ids = [FLAGS.quantum_default_tenant_id, project_id, None]
+        tenant_ids = [project_id,FLAGS.quantum_default_tenant_id, None]
         # This is confusing, if there are IPs for the given net, vif,
         # tenant trifecta we assume that is the tenant for that network
         for tid in tenant_ids:


Regards,
-Mandar


Follow ups