[Openstack] net-create issue

Erich Weiler weiler at soe.ucsc.edu
Mon Mar 31 23:29:37 UTC 2014


OK, I think I've solved this, but just for the record, I think there is 
a bug somewhere in the RDO code to create these tables in mysql.

The command:

mysql> CREATE TABLE networkdhcpagentbindings (network_id VARCHAR(36) NOT 
NULL, dhcp_agent_id VARCHAR(36) NOT NULL, PRIMARY KEY (network_id, 
dhcp_agent_id), FOREIGN KEY(network_id) REFERENCES networks (id) ON 
DELETE CASCADE, FOREIGN KEY(dhcp_agent_id) REFERENCES agents (id) ON 
DELETE CASCADE)ENGINE=InnoDB;
ERROR 1005 (HY000): Can't create table 
'neutron.networkdhcpagentbindings' (errno: 150)

Does not work because the neutron.agents table was created as a MyISAM 
table, which does not work with funky stuff like foreign keys or 
something like that:

mysql> show create table agents;
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table  | Create Table 
 
 
 
 
 
 
                                                                   |
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| agents | CREATE TABLE `agents` (
   `id` varchar(36) NOT NULL,
   `agent_type` varchar(255) NOT NULL,
   `binary` varchar(255) NOT NULL,
   `topic` varchar(255) NOT NULL,
   `host` varchar(255) NOT NULL,
   `admin_state_up` tinyint(1) NOT NULL,
   `created_at` datetime NOT NULL,
   `started_at` datetime NOT NULL,
   `heartbeat_timestamp` datetime NOT NULL,
   `description` varchar(255) DEFAULT NULL,
   `configurations` varchar(4095) NOT NULL,
   PRIMARY KEY (`id`),
   UNIQUE KEY `uniq_agents0agent_type0host` (`agent_type`,`host`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

I switched it to InnoDB and voila, things are much better now!

mysql> alter table agents engine=innodb;
Query OK, 4 rows affected (0.01 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> show create table agents;
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table  | Create Table 
 
 
 
 
 
 
                                                                   |
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| agents | CREATE TABLE `agents` (
   `id` varchar(36) NOT NULL,
   `agent_type` varchar(255) NOT NULL,
   `binary` varchar(255) NOT NULL,
   `topic` varchar(255) NOT NULL,
   `host` varchar(255) NOT NULL,
   `admin_state_up` tinyint(1) NOT NULL,
   `created_at` datetime NOT NULL,
   `started_at` datetime NOT NULL,
   `heartbeat_timestamp` datetime NOT NULL,
   `description` varchar(255) DEFAULT NULL,
   `configurations` varchar(4095) NOT NULL,
   PRIMARY KEY (`id`),
   UNIQUE KEY `uniq_agents0agent_type0host` (`agent_type`,`host`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> CREATE TABLE networkdhcpagentbindings (network_id VARCHAR(36) NOT 
NULL, dhcp_agent_id VARCHAR(36) NOT NULL, PRIMARY KEY (network_id, 
dhcp_agent_id), FOREIGN KEY(network_id) REFERENCES networks (id) ON 
DELETE CASCADE, FOREIGN KEY(dhcp_agent_id) REFERENCES agents (id) ON 
DELETE CASCADE) ENGINE=InnoDB;
Query OK, 0 rows affected (0.00 sec)


And now this works:

# neutron net-create ext-net --router:external=True
Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| id                        | a5599b54-dbfc-42fa-b5b9-e8ebd574ded0 |
| name                      | ext-net                              |
| provider:network_type     | vlan                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  | 200                                  |
| router:external           | True                                 |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tenant_id                 | 36687b1d611740bd9e7309432b22dbcd     |
+---------------------------+--------------------------------------+

Nifty.  But that's a dangerous bug somewhere in the neutron Icehouse RDO 
code.  We are using MySQL 5.1, which comes as the default for CentOS 
6.5/RedHat 6.5, and the default engine is MyISAM for 5.1.  Changing the 
default engine to InnoDB in my.cnf would have likely mitigated this.

Heads up.

-erich

On 03/31/14 15:57, Erich Weiler wrote:
> As a follow up on this, neutron seems to be having trouble creating
> other neutron DB tables as well.  I see in the neutron-server startup logs:
>
> 2014-03-31 15:39:42.338 15778 INFO neutron.common.config [-] Logging
> enabled!
> 2014-03-31 15:39:42.339 15778 ERROR neutron.common.legacy [-] Skipping
> unknown group key: firewall_driver
> 2014-03-31 15:39:42.344 15778 INFO neutron.common.config [-] Config
> paste file: /etc/neutron/api-paste.ini
> 2014-03-31 15:39:42.400 15778 INFO neutron.manager [-] Loading core
> plugin: neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2
> 2014-03-31 15:39:42.537 15778 WARNING
> neutron.openstack.common.db.sqlalchemy.session [-] This application has
> not enabled MySQL traditional mode, which means silent data corruption
> may occur. Please encourage the application developers to enable this mode.
> 2014-03-31 15:39:42.581 15778 INFO neutron.db.api [-] Database
> registration exception: (OperationalError) (1005, "Can't create table
> 'neutron.networkdhcpagentbindings' (errno: 150)") '\nCREATE TABLE
> networkdhcpagentbindings (\n\tnetwork_id VARCHAR(36) NOT NULL,
> \n\tdhcp_agent_id VARCHAR(36) NOT NULL, \n\tPRIMARY KEY (network_id,
> dhcp_agent_id), \n\tFOREIGN KEY(network_id) REFERENCES networks (id) ON
> DELETE CASCADE, \n\tFOREIGN KEY(dhcp_agent_id) REFERENCES agents (id) ON
> DELETE CASCADE\n)ENGINE=InnoDB\n\n' ()
>
> The rest of the startup items go OK.  I confirmed that the neutron mysql
> username and password referenced in /etc/neutron/neutron.conf were correct.
>
> I decided to log in as the neutron user to mysql and create the table
> referenced above in the error logs myself - it failed:
>
> # mysql -u neutron -p
> Enter password:
> Welcome to the MySQL monitor.  Commands end with ; or \g.
> Your MySQL connection id is 37
> Server version: 5.1.73-log Source distribution
>
> Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights
> reserved.
>
> Oracle is a registered trademark of Oracle Corporation and/or its
> affiliates. Other names may be trademarks of their respective
> owners.
>
> Type 'help;' or '\h' for help. Type '\c' to clear the current input
> statement.
>
> mysql> show databases;
> +--------------------+
> | Database           |
> +--------------------+
> | information_schema |
> | neutron            |
> +--------------------+
> 2 rows in set (0.00 sec)
>
> mysql> use neutron;
> Reading table information for completion of table and column names
> You can turn off this feature to get a quicker startup with -A
>
> Database changed
> mysql> CREATE TABLE networkdhcpagentbindings (network_id VARCHAR(36) NOT
> NULL, dhcp_agent_id VARCHAR(36) NOT NULL, PRIMARY KEY (network_id,
> dhcp_agent_id), FOREIGN KEY(network_id) REFERENCES networks (id) ON
> DELETE CASCADE, FOREIGN KEY(dhcp_agent_id) REFERENCES agents (id) ON
> DELETE CASCADE)ENGINE=InnoDB;
> ERROR 1005 (HY000): Can't create table
> 'neutron.networkdhcpagentbindings' (errno: 150)
>
> Just for fun I created another table just to be sure I could create
> tables at all:
>
> mysql> CREATE TABLE testtable (c CHAR(20) CHARACTER SET utf8 COLLATE
> utf8_bin);
> Query OK, 0 rows affected (0.01 sec)
>
> mysql> drop table testtable;
> Query OK, 0 rows affected (0.00 sec)
>
> Could this be a bug in the table create code for neutron?  I'm not savvy
> enough in mysql to see where the issue is, maybe something to do with
> the foreign key?
>
> Anyway, if anyone sees something obvious, please let me know...  ;)
>
> -erich
>
> On 03/31/14 15:00, Erich Weiler wrote:
>> Hey Y'all,
>>
>> I'm working on the latest RDO icehouse release of openstack and am
>> following the redhat guide to set this stuff up (which looks almost like
>> all the other guides with a few differences), and am stuck on the
>> Neutron part.  I *think* I have all the backend services set up
>> (neutron-server on the controller, and neutron agents on the network
>> node), and want to create my first public network, but I'm getting an
>> error:
>>
>> # neutron net-create ext-net --router:external=True
>> Request Failed: internal server error while processing your request.
>>
>> Looking in the neutron server logs, I see:
>>
>> 2014-03-31 14:50:47.746 3192 INFO urllib3.connectionpool [-] Starting
>> new HTTP connection (1): my-internal-server.edu
>> 2014-03-31 14:50:47.854 3192 ERROR neutron.api.v2.resource
>> [req-d20aad3f-d200-484c-b73a-9556efe62386 None] create failed
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource Traceback
>> (most recent call last):
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib/python2.6/site-packages/neutron/api/v2/resource.py", line 87,
>> in resource
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     result =
>> method(request=request, **args)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib/python2.6/site-packages/neutron/api/v2/base.py", line 411, in
>> create
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     obj =
>> obj_creator(request.context, **kwargs)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib/python2.6/site-packages/neutron/plugins/openvswitch/ovs_neutron_plugin.py",
>>
>> line 501, in create_network
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     network)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib/python2.6/site-packages/neutron/db/db_base_plugin_v2.py", line
>> 927, in create_network
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     return
>> self._make_network_dict(network, process_extensions=False)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib/python2.6/site-packages/neutron/db/db_base_plugin_v2.py", line
>> 842, in _make_network_dict
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     for
>> subnet in network['subnets']]}
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib/python2.6/site-packages/neutron/openstack/common/db/sqlalchemy/models.py",
>>
>> line 57, in __getitem__
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     return
>> getattr(self, key)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/orm/attributes.py",
>>
>> line 168, in __get__
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     return
>> self.impl.get(instance_state(instance),dict_)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/orm/attributes.py",
>>
>> line 453, in get
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     value =
>> self.callable_(state, passive)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/orm/strategies.py",
>>
>> line 508, in _load_for_state
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     return
>> self._emit_lazyload(session, state, ident_key)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/orm/strategies.py",
>>
>> line 574, in _emit_lazyload
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     result =
>> q.all()
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/orm/query.py",
>>
>> line 2115, in all
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     return
>> list(self)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/orm/query.py",
>>
>> line 2227, in __iter__
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     return
>> self._execute_and_instances(context)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/orm/query.py",
>>
>> line 2242, in _execute_and_instances
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     result =
>> conn.execute(querycontext.statement, self._params)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py",
>>
>> line 1449, in execute
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     params)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py",
>>
>> line 1584, in _execute_clauseelement
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource compiled_sql,
>> distilled_params
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py",
>>
>> line 1698, in _execute_context
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     context)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py",
>>
>> line 1691, in _execute_context
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     context)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/default.py",
>>
>> line 331, in do_execute
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource
>> cursor.execute(statement, parameters)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py", line 173, in
>> execute
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource
>> self.errorhandler(self, exc, value)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource   File
>> "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", line 36, in
>> defaulterrorhandler
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource     raise
>> errorclass, errorvalue
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource
>> ProgrammingError: (ProgrammingError) (1146, "Table
>> 'neutron.ipallocationpools' doesn't exist") 'SELECT subnets.tenant_id AS
>> subnets_tenant_id, subnets.id AS subnets_id, subnets.name AS
>> subnets_name, subnets.network_id AS subnets_network_id,
>> subnets.ip_version AS subnets_ip_version, subnets.cidr AS subnets_cidr,
>> subnets.gateway_ip AS subnets_gateway_ip, subnets.enable_dhcp AS
>> subnets_enable_dhcp, subnets.shared AS subnets_shared,
>> ipavailabilityranges_1.allocation_pool_id AS
>> ipavailabilityranges_1_allocation_pool_id,
>> ipavailabilityranges_1.first_ip AS ipavailabilityranges_1_first_ip,
>> ipavailabilityranges_1.last_ip AS ipavailabilityranges_1_last_ip,
>> ipallocationpools_1.id AS ipallocationpools_1_id,
>> ipallocationpools_1.subnet_id AS ipallocationpools_1_subnet_id,
>> ipallocationpools_1.first_ip AS ipallocationpools_1_first_ip,
>> ipallocationpools_1.last_ip AS ipallocationpools_1_last_ip \nFROM
>> subnets LEFT OUTER JOIN ipallocationpools AS ipallocationpools_1 ON
>> subnets.id = ipallocationpools_1.subnet_id LEFT OUTER JOIN
>> ipavailabilityranges AS ipavailabilityranges_1 ON ipallocationpools_1.id
>> = ipavailabilityranges_1.allocation_pool_id \nWHERE %s =
>> subnets.network_id' ('ca36a372-5d73-420b-ab3c-d4530e2c2a2a',)
>> 2014-03-31 14:50:47.854 3192 TRACE neutron.api.v2.resource
>> 2014-03-31 14:50:47.857 3192 INFO neutron.wsgi
>> [req-d20aad3f-d200-484c-b73a-9556efe62386 None]
>> 112.113.114.115,10.1.1.147 - - [31/Mar/2014 14:50:47] "POST
>> /v2.0/networks.json HTTP/1.1" 500 296 0.113226
>>
>> If I had to guess, I'd say that, based on the above error messages, the
>> mysql "neutron.ipallocationpools" table does not exist (checking...
>> Nope, it's not there).  Other neutron tables are in the neutron database
>> however, just not that one.
>>
>> I thought Neutron sort of automatically creates tables as needed, I
>> wonder why it didn't work here?  Or maybe I'm on the wrong trail?
>>
>> Any hints would be greatly appreciated!!
>>
>> -erich




More information about the Openstack mailing list