auto_allocate_network is not called when external shared network exists

Bug #1647629 reported by Yushiro FURUKAWA
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Invalid
Undecided
Yushiro FURUKAWA

Bug Description

When I try to boot an instance with '--nic auto', a network isn't created
automatically. In neutron side, in order to automatically allocate
network/subnet/router, following network is necessary in advance:

    * router:external is True(it means an external network)
    * is_default is True
    * subnet is associated

However, if I prepared above default network, nova doesn't call
'_can_auto_allocate_network'[1]. As a result, the VM instance is attached that
external network.(not generated a network automatically)

[1] https://github.com/openstack/nova/blob/master/nova/network/neutronv2/api.py#L1532

[Steps to reproduce]
1. Delete all network/subnet/port/router in neutron

2. Try to create an instance
  $ nova boot --flavor 1 --image 198384a2-9ece-4d24-a509-4ce02f183b63 vm1 --nic auto

ERROR (BadRequest): Unable to automatically allocate a network for project c8607bb7e4334b43aede76831b91ca03 (HTTP 400) (Request-ID: req-2d4088f6-d9aa-492d-a645-02327a058a47)
In n-api.log, we can see following error message:
Error message: {"NeutronError": {"message": "Deployment error: No default router:external network.", "type": "AutoAllocationFailure", "detail": ""}}

3. I see. OK, let's create default external network(router:external)
  $ neutron net-create public --is_default --router:external --shared
  $ neutron subnet-create public --subnetpool a811bf33-dacc-42b9-b44a-d424f37023df

4. Try it again 'nova boot'
  $ nova boot --flavor 1 --image 198384a2-9ece-4d24-a509-4ce02f183b63 vm1 --nic auto

5. You can check the result with 'nova list'
  $ nova list
+--------------------------------------+------+--------+------------+-------------+-----------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------+--------+------------+-------------+-----------------+
| 4e83f9d0-acbf-4440-8563-17dd6ec0cde5 | vm1 | BUILD | spawning | NOSTATE | public=10.0.0.9 |
+--------------------------------------+------+--------+------------+-------------+-----------------+

summary: - auto_allocate_network doesn't call when external network exists
+ auto_allocate_network is not called when external network exists
Changed in nova:
assignee: nobody → Yushiro FURUKAWA (y-furukawa-2)
Revision history for this message
Matt Riedemann (mriedem) wrote : Re: auto_allocate_network is not called when external network exists

You're getting the public external network because you marked it as shared=True so it's pulled in here:

https://github.com/openstack/nova/blob/a67af1f110f160861f5cbbff987766c46d60198a/nova/network/neutronv2/api.py#L343

And you pass this check for the external shared network on the compute:

https://github.com/openstack/nova/blob/a67af1f110f160861f5cbbff987766c46d60198a/nova/network/neutronv2/api.py#L466

So the port for the server gets created in that network. I'm not sure what else you expect to happen here.

tags: added: neutron
Changed in nova:
status: New → Invalid
summary: - auto_allocate_network is not called when external network exists
+ auto_allocate_network is not called when external shared network exists
Revision history for this message
Yushiro FURUKAWA (y-furukawa-2) wrote :

Hi Matt, thanks for your reply. I understood that following condition should be satisfied to run auto_allocate_topology.

1. There is no networks in a target project(ex. "demo" project)
2. There is a network in different project with following conditions(ex. in "admin" project:
    * "router:external" is True(it is equal to external network)
    * "is_default" is True
    * A subnet is associated with the network

After that, I executed "nova boot" with "--nic auto" into "demo" project. As a result, auto_allocated_network is generated.

Revision history for this message
Yushiro FURUKAWA (y-furukawa-2) wrote :

^^^
    * "shared" is False

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.