Should not read config options while update cells

Bug #1793423 reported by Zhenyu Zheng
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Invalid
Undecided
Zhenyu Zheng

Bug Description

When perform ``nova-manage cell_v2 update_cell`` command,
we read the ``database_connection`` and ``transport_url`` from
configuration file if the caller don't provide this info:
http://git.openstack.org/cgit/openstack/nova/tree/nova/cmd/manage.py?h=stable/rocky#n1631
and they are latter saved with cell_mapping.save()

this is problematic because:
1.If I did not pass config file with --config-file, it will use the file from default route and most probably it will be cell0 file, when I did not pass ``transport_url``
and/or ``database_connection`` this will lead to that those file will be overridden
by the value in the conf, which will fail in the latter uniqueness check as we already
have the cell_0 db mapped.
2.If I pass the nova-cell1.conf with --config-file, the command will probably unable to
run because I do not have api_database connection in the config file as I should not
perform upcall.
3. It seems not appropriate at all that I have to always provide the config file for
the cell I want to update when I call update cell, as I'm only updating a record in
the API_DB.

example:
root@ubuntu:/opt/stack/nova# nova-manage cell_v2 list_cells
+-------+--------------------------------------+---------------------------------------------------------+-------------------------------------------------------------+----------+
| Name | UUID | Transport URL | Database Connection | Disabled |
+-------+--------------------------------------+---------------------------------------------------------+-------------------------------------------------------------+----------+
| cell0 | 00000000-0000-0000-0000-000000000000 | none:/ | mysql+pymysql://root:****@127.0.0.1/nova_cell0?charset=utf8 | False |
| cell1 | 8eea3d64-2624-4d55-aa81-996fc8017402 | rabbit://stackrabbit:****@10.76.150.197:5672/nova_cell1 | mysql+pymysql://root:****@127.0.0.1/nova_cell1?charset=utf8 | False |
+-------+--------------------------------------+---------------------------------------------------------+-------------------------------------------------------------+----------+

for case 1:
root@ubuntu:/opt/stack/nova# nova-manage --config-file /etc/nova/nova.conf cell_v2 update_cell --cell_uuid 8eea3d64-2624-4d55-aa81-996fc8017402 --disable
transport_url and/or database_connection combination already exists for another cell with uuid 00000000-0000-0000-0000-000000000000.

for case2:
root@ubuntu:/opt/stack/nova# nova-manage --config-file /etc/nova/nova_cell1.conf cell_v2 update_cell --cell_uuid 8eea3d64-2624-4d55-aa81-996fc8017402 --disable
An error has occurred:
Traceback (most recent call last):
  File "/opt/stack/nova/nova/cmd/manage.py", line 2323, in main
    ret = fn(*fn_args, **fn_kwargs)
  File "/opt/stack/nova/nova/cmd/manage.py", line 1629, in update_cell
    cell_mapping = objects.CellMapping.get_by_uuid(ctxt, cell_uuid)
  File "/usr/local/lib/python2.7/dist-packages/oslo_versionedobjects/base.py", line 184, in wrapper
    result = fn(cls, context, *args, **kwargs)
  File "/opt/stack/nova/nova/objects/cell_mapping.py", line 182, in get_by_uuid
    db_mapping = cls._get_by_uuid_from_db(context, uuid)
  File "/usr/local/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 992, in wrapper
    with self._transaction_scope(context):
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/local/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 1042, in _transaction_scope
    context=context) as resource:
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/local/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 645, in _session
    bind=self.connection, mode=self.mode)
  File "/usr/local/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 409, in _create_session
    self._start()
  File "/usr/local/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 496, in _start
    engine_args, maker_args)
  File "/usr/local/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 518, in _setup_for_connection
    "No sql_connection parameter is established")
CantStartEngineError: No sql_connection parameter is established

description: updated
description: updated
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/603998

Changed in nova:
assignee: nobody → Zhenyu Zheng (zhengzhenyu)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Zhenyu Zheng (<email address hidden>) on branch: master
Review: https://review.openstack.org/603998
Reason: This is made this way on purpose

Changed in nova:
status: In Progress → Invalid
Revision history for this message
Matt Riedemann (mriedem) wrote :

I've marked this as a duplicate of bug 1829852 since it's related. Though this bug came first, there is an active change for bug 1829852.

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.