Nova create duplicate cells when templates are used

Bug #1923899 reported by Dmitriy Rabotyagov
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
In Progress
Medium
Rajesh Tailor

Bug Description

Description
===========

When you use templates for cell creation and re-run create_cell command, duplicate cell will be created

This happens because logic is broken here for templates: https://opendev.org/openstack/nova/src/commit/9e5feb051c15166988e87b10132927135bd56884/nova/cmd/manage.py#L623-L624

As cell.database_connection and cell.transport_url are already resolved into urls, while transport_url and database_connection are still templates.

Steps to reproduce
==================

Run 2 times: nova-manage cell_v2 create_cell --name cell1 --transport-url {scheme}://{username}:{password}@{hostname}//{path}?{query} --database_connection {scheme}://{username}:{password}@{hostname}/{path}?{query} --verbose

This will result in creating 2 independent cells:

root@aio1:~# /openstack/venvs/nova-22.0.0.0rc2.dev149/bin/nova-manage cell_v2 create_cell --name cell1 --transport-url {scheme}://{username}:{password}@{hostname}//{path}?{query} --database_connection {scheme}://{username}:{password}@{hostname}/{path}?{query} --verbose
046c88f0-097e-4a7c-9eee-45654355ff56
root@aio1:~# /openstack/venvs/nova-22.0.0.0rc2.dev149/bin/nova-manage cell_v2 create_cell --name cell1 --transport-url {scheme}://{username}:{password}@{hostname}//{path}?{query} --database_connection {scheme}://{username}:{password}@{hostname}/{path}?{query} --verbose
b5f1672e-36c7-4d17-90b3-7433842cbbe0
root@aio1:~# /openstack/venvs/nova-22.0.0.0rc2.dev149/bin/nova-manage cell_v2 create_cell --name cell1 --transport-url {scheme}://{username}:{password}@{hostname}//{path}?{query} --database_connection {scheme}://{username}:{password}@{hostname}/{path}?{query} --verbose
cf2efc1c-e091-4c93-96d4-84b3ecfa4647
root@aio1:~#

Expected result
===============

Following error should be raised along with command exit code 2:
The specified transport_url and/or database_connection combination already exists for another cell with uuid

Revision history for this message
Dmitriy Rabotyagov (noonedeadpunk) wrote :
Download full text (3.6 KiB)

Also attaching how database looks like after several runs of the command:

MariaDB [nova_api]> select * from cell_mappings;
+---------------------+---------------------+----+--------------------------------------+-------+-------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+----------+
| created_at | updated_at | id | uuid | name | transport_url | database_connection | disabled |
+---------------------+---------------------+----+--------------------------------------+-------+-------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+----------+
| 2021-04-14 10:49:46 | NULL | 1 | 00000000-0000-0000-0000-000000000000 | cell0 | none:/// | mysql+pymysql://nova_api:e83ceeb01f3093de3f23de63c4a9d229eb78ce49a15acfb1894b754397d@172.29.236.101/nova_cell0?charset=utf8 | 0 |
| 2021-04-14 10:50:17 | 2021-04-14 14:54:24 | 2 | ef89aebc-142d-4755-a377-6ed23b6c1ed4 | cell1 | {scheme}://{username}:{password}@{hostname}//{path}?{query} | {scheme}://{username}:{password}@{hostname}/{path}?{query} | 0 |
| 2021-04-14 19:39:33 | NULL | 4 | e22e06d5-b668-47a6-943c-169c2ed976a4 | cell1 | {scheme}://{username}:{password}@{hostname}//{path}?{query} | {scheme}://{username}:{password}@{hostname}/{path}?{query} | 0 |
| 2021-04-14 19:39:40 | NULL | 5 | 8be204c1-0710-4b0a-a1c5-9a42707bbaa7 | cell1 | {scheme}://{username}:{password}@{hostname}//{path}?{query} | {scheme}://{username}:{password}@{hostname}/{path}?{query} | 0 |
| 2021-04-14 19:39:49 | NULL | 6 | f34f0e6c-98e8-4da6-91c5-46d0234afd0e | cell1 | {scheme}://{username}:{password}@{hostname}//{path}?{query} | {scheme}://{username}:{password}@{hostname}/{path}?{query} | 0 |
| 2021-04-14 19:41:50 | NULL | 7 | 046c88f0-097e-4a7c-9eee-45654355ff56 | cell1 | {scheme}://{username}:{password}@{hostname}//{path}?{query} | {scheme}://{username}:{password}@{hostname}/{path}?{query} | 0 |
| 2021-04-14 19:41:54 | NULL | 8 | b5f1672e-36c7-4d17-90b3-7433842cbbe0 | cell1 | {scheme}://{username}:{password}@{hostname}//{path}?{query} | {scheme}://{username}:{password}@{hostname}/{path}?{query} | 0 |
| 2021-04-14 19:41:58 | NULL | 9 | cf2efc1c-e091-4c93-96d4-84b3ecfa4647 | cell1 | {scheme}...

Read more...

Revision history for this message
Balazs Gibizer (balazs-gibizer) wrote :

Looking at the code I confirm that it is a bug.

Changed in nova:
status: New → Triaged
importance: Undecided → Medium
tags: added: low-hanging-fruit nova-manage
Rajesh Tailor (ratailor)
Changed in nova:
assignee: nobody → Rajesh Tailor (ratailor)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/nova/+/876940

Changed in nova:
status: Triaged → In Progress
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.