nova-status doesn't render cell DB connection strings before use

Bug #1818047 reported by Lee Yarwood
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Matt Riedemann
Rocky
Fix Committed
Medium
Matt Riedemann

Bug Description

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

I've been working on introducing basic upgrade check calls in TripleO but have encountered the following issue now template based db connection strings are being used by TripleO in support of cellsv2:

$ nova-status upgrade check
[..]
ArgumentError: Could not parse rfc1738 URL from string '{scheme}://{username}:{password}@{hostname}/nova?{query}'

http://logs.openstack.org/39/635139/2/check/tripleo-ci-centos-7-standalone/91d4b45/logs/undercloud/home/zuul/standalone_deploy.log.txt.gz#_2019-02-26_22_04_00

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

http://logs.openstack.org/39/635139/2/check/tripleo-ci-centos-7-standalone/91d4b45/logs/reproducer-quickstart.sh

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

Connection string is formatted correctly before use.

Actual result
=============

Connection string is not formatted before use leading to `nova-status` errors.

Environment
===========
1. Exact version of OpenStack you are running. See the following
  list for all releases: http://docs.openstack.org/releases/

   Master / Stein

2. Which hypervisor did you use?
   (For example: Libvirt + KVM, Libvirt + XEN, Hyper-V, PowerKVM, ...)
   What's the version of that?

   N/A

2. Which storage type did you use?
   (For example: Ceph, LVM, GPFS, ...)
   What's the version of that?

   N/A

3. Which networking type did you use?
   (For example: nova-network, Neutron with OpenVSwitch, ...)

   N/A

Logs & Configs
==============

See above.

Revision history for this message
Matt Riedemann (mriedem) wrote :

OK this is the useful part of the error:

2019-02-26 22:04:00 | "Traceback (most recent call last):",
2019-02-26 22:04:00 | " File \"/usr/lib/python2.7/site-packages/nova/cmd/status.py\", line 494, in main",
2019-02-26 22:04:00 | " ret = fn(*fn_args, **fn_kwargs)",
2019-02-26 22:04:00 | " File \"/usr/lib/python2.7/site-packages/oslo_upgradecheck/upgradecheck.py\", line 98, in check",
2019-02-26 22:04:00 | " result = func(self)",
2019-02-26 22:04:00 | " File \"/usr/lib/python2.7/site-packages/nova/cmd/status.py\", line 238, in _check_ironic_flavor_migration",
2019-02-26 22:04:00 | " meta = MetaData(bind=db_session.get_engine(context=cctxt))",
2019-02-26 22:04:00 | " File \"/usr/lib/python2.7/site-packages/nova/db/sqlalchemy/api.py\", line 139, in get_engine",
2019-02-26 22:04:00 | " return ctxt_mgr.writer.get_engine()",
2019-02-26 22:04:00 | " File \"/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py\", line 833, in get_engine",
2019-02-26 22:04:00 | " return self._factory.get_writer_engine()",
2019-02-26 22:04:00 | " File \"/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py\", line 372, in get_writer_engine",
2019-02-26 22:04:00 | " self._start()",
2019-02-26 22:04:00 | " File \"/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py\", line 510, in _start",
2019-02-26 22:04:00 | " engine_args, maker_args)",
2019-02-26 22:04:00 | " File \"/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py\", line 534, in _setup_for_connection",
2019-02-26 22:04:00 | " sql_connection=sql_connection, **engine_kwargs)",
2019-02-26 22:04:00 | " File \"/usr/lib/python2.7/site-packages/debtcollector/renames.py\", line 43, in decorator",
2019-02-26 22:04:00 | " return wrapped(*args, **kwargs)",
2019-02-26 22:04:00 | " File \"/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/engines.py\", line 153, in create_engine",
2019-02-26 22:04:00 | " url = sqlalchemy.engine.url.make_url(sql_connection)",
2019-02-26 22:04:00 | " File \"/usr/lib64/python2.7/site-packages/sqlalchemy/engine/url.py\", line 225, in make_url",
2019-02-26 22:04:00 | " return _parse_rfc1738_args(name_or_url)",
2019-02-26 22:04:00 | " File \"/usr/lib64/python2.7/site-packages/sqlalchemy/engine/url.py\", line 287, in _parse_rfc1738_args",
2019-02-26 22:04:00 | " \"Could not parse rfc1738 URL from string '%s'\" % name",
2019-02-26 22:04:00 | "ArgumentError: Could not parse rfc1738 URL from string '{scheme}://{username}:{password}@{hostname}/nova?{query}'"

Changed in nova:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Matt Riedemann (mriedem) wrote :

OK I see the problem, the template is only applied when using the CellMapping object, and the nova-status code is intentionally not using the objects, it is using the data models:

https://github.com/openstack/nova/blob/047f8c71c2bc45e4a2c00394f23cd953236f6050/nova/cmd/status.py#L191

Changed in nova:
status: Confirmed → Triaged
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/641021

Changed in nova:
assignee: nobody → Matt Riedemann (mriedem)
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/641021
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=38f2ce549ce4b21d5085824df701f9d2392b5604
Submitter: Zuul
Branch: master

commit 38f2ce549ce4b21d5085824df701f9d2392b5604
Author: Matt Riedemann <email address hidden>
Date: Tue Mar 5 09:00:20 2019 -0500

    Handle templated cell mappings in nova-status

    The nova-status upgrade check code is intentionally written
    to not use versioned objects and just work with the data model
    directly.

    However, CellMapping database_connection template support was
    added in Rocky and the template URL is only formatted when using
    the object on read from the database, which means if you are using
    a template for the database_connection nova-status will break since
    the get_engine() code is getting a template string rather than a
    properly formatted URL.

    This change fixes the bug by using the CellMapping object code to
    pull the mappings from the database which will format the database
    connection URL. Note that we cannot simply update the sqlalchemy
    RowProxy objects we get normally since those are read-only, and
    because of how the mappings are used as objects with attribute
    access rather than as a dict we cannot just convert the RowProxy
    to a dict - we would have to put it in some kind of object for
    attribute access and if we are going to do that we might as well
    just use the CellMapping objects we have so that's what we do in
    this change.

    Change-Id: I5ce175517f6feb6e82ba507078a565b71427a4b0
    Closes-Bug: #1818047

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/rocky)

Fix proposed to branch: stable/rocky
Review: https://review.openstack.org/642611

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/rocky)

Reviewed: https://review.openstack.org/642611
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=cfad7a1faae9aec6041c49149ad923c407f30219
Submitter: Zuul
Branch: stable/rocky

commit cfad7a1faae9aec6041c49149ad923c407f30219
Author: Matt Riedemann <email address hidden>
Date: Tue Mar 5 09:00:20 2019 -0500

    Handle templated cell mappings in nova-status

    The nova-status upgrade check code is intentionally written
    to not use versioned objects and just work with the data model
    directly.

    However, CellMapping database_connection template support was
    added in Rocky and the template URL is only formatted when using
    the object on read from the database, which means if you are using
    a template for the database_connection nova-status will break since
    the get_engine() code is getting a template string rather than a
    properly formatted URL.

    This change fixes the bug by using the CellMapping object code to
    pull the mappings from the database which will format the database
    connection URL. Note that we cannot simply update the sqlalchemy
    RowProxy objects we get normally since those are read-only, and
    because of how the mappings are used as objects with attribute
    access rather than as a dict we cannot just convert the RowProxy
    to a dict - we would have to put it in some kind of object for
    attribute access and if we are going to do that we might as well
    just use the CellMapping objects we have so that's what we do in
    this change.

    Change-Id: I5ce175517f6feb6e82ba507078a565b71427a4b0
    Closes-Bug: #1818047
    (cherry picked from commit 38f2ce549ce4b21d5085824df701f9d2392b5604)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 19.0.0.0rc1

This issue was fixed in the openstack/nova 19.0.0.0rc1 release candidate.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 18.2.0

This issue was fixed in the openstack/nova 18.2.0 release.

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.