dbcounter plugin fails with SQLAlchemy 2.x

Bug #2009521 reported by Michael Johnson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
devstack
Fix Released
Undecided
Michael Johnson

Bug Description

SQLAlchemy has changed the CreateEnginePlugin plugin signature to require an "update_url" method[1].

This causes the dbcounter plugin to fail when running on SQLAlchemy 2.x with a NotImplementedError:

2023-03-06 17:40:07.775171 | controller | INFO dbcounter [None designate-manage None None] Registered counter for database designate
2023-03-06 17:40:07.789974 | controller | An error has occurred:
2023-03-06 17:40:07.790047 | controller | Traceback (most recent call last):
2023-03-06 17:40:07.790080 | controller | File "/opt/stack/designate/designate/cmd/manage.py", line 122, in main
2023-03-06 17:40:07.790141 | controller | fn(*fn_args)
2023-03-06 17:40:07.790171 | controller | File "/opt/stack/designate/designate/manage/database.py", line 79, in sync
2023-03-06 17:40:07.790206 | controller | alembic_command.upgrade(
2023-03-06 17:40:07.790234 | controller | File "/usr/local/lib/python3.10/dist-packages/alembic/command.py", line 322, in upgrade
2023-03-06 17:40:07.790259 | controller | script.run_env()
2023-03-06 17:40:07.790284 | controller | File "/usr/local/lib/python3.10/dist-packages/alembic/script/base.py", line 569, in run_env
2023-03-06 17:40:07.790310 | controller | util.load_python_file(self.dir, "env.py")
2023-03-06 17:40:07.790336 | controller | File "/usr/local/lib/python3.10/dist-packages/alembic/util/pyfiles.py", line 94, in load_python_file
2023-03-06 17:40:07.790371 | controller | module = load_module_py(module_id, path)
2023-03-06 17:40:07.790398 | controller | File "/usr/local/lib/python3.10/dist-packages/alembic/util/pyfiles.py", line 110, in load_module_py
2023-03-06 17:40:07.790423 | controller | spec.loader.exec_module(module) # type: ignore
2023-03-06 17:40:07.790448 | controller | File "<frozen importlib._bootstrap_external>", line 883, in exec_module
2023-03-06 17:40:07.790474 | controller | File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
2023-03-06 17:40:07.790499 | controller | File "/opt/stack/designate/designate/storage/impl_sqlalchemy/alembic/env.py", line 83, in <module>
2023-03-06 17:40:07.790531 | controller | run_migrations_online()
2023-03-06 17:40:07.790558 | controller | File "/opt/stack/designate/designate/storage/impl_sqlalchemy/alembic/env.py", line 64, in run_migrations_online
2023-03-06 17:40:07.790582 | controller | connectable = engine_from_config(
2023-03-06 17:40:07.790607 | controller | File "/opt/stack/.local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 817, in engine_from_config
2023-03-06 17:40:07.790632 | controller | return create_engine(url, **options)
2023-03-06 17:40:07.790656 | controller | File "<string>", line 2, in create_engine
2023-03-06 17:40:07.790688 | controller | File "/opt/stack/.local/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 277, in warned
2023-03-06 17:40:07.790715 | controller | return fn(*args, **kwargs) # type: ignore[no-any-return]
2023-03-06 17:40:07.790740 | controller | File "/opt/stack/.local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 554, in create_engine
2023-03-06 17:40:07.790765 | controller | u, plugins, kwargs = u._instantiate_plugins(kwargs)
2023-03-06 17:40:07.790789 | controller | File "/opt/stack/.local/lib/python3.10/site-packages/sqlalchemy/engine/url.py", line 735, in _instantiate_plugins
2023-03-06 17:40:07.790813 | controller | new_u = plugin.update_url(u)
2023-03-06 17:40:07.790838 | controller | File "/opt/stack/.local/lib/python3.10/site-packages/sqlalchemy/engine/interfaces.py", line 2852, in update_url
2023-03-06 17:40:07.790870 | controller | raise NotImplementedError()
2023-03-06 17:40:07.790897 | controller | NotImplementedError

[1] https://docs.sqlalchemy.org/en/20/changelog/migration_14.html#changes-to-createengineplugin

Changed in devstack:
assignee: nobody → Michael Johnson (johnsom)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to devstack (master)

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

Changed in devstack:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to devstack (master)

Reviewed: https://review.opendev.org/c/openstack/devstack/+/876601
Committed: https://opendev.org/openstack/devstack/commit/f834f9adaf9c228ff4ec6a5e24e6d4cf3ca6a992
Submitter: "Zuul (22348)"
Branch: master

commit f834f9adaf9c228ff4ec6a5e24e6d4cf3ca6a992
Author: Michael Johnson <email address hidden>
Date: Mon Mar 6 18:47:03 2023 +0000

    Fix NotImplementedError in dbcounter on SQLA 2.x

    This patch fixes a NotImplementedError raised in the dbcounter plugin when using SQLAlchemy 2.x. The plugin signature has changed and now requires an "update_url" method as part of the plugin[1].
    This patch also updates the do_incr() explicit SQL string to use a TextClause and the new requirement for named bound parameters[2].

    Closes-Bug: #2009521

    [1] https://docs.sqlalchemy.org/en/20/changelog/migration_14.html#changes-to-createengineplugin
    [2] https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#execute-method-more-strict-execution-options-are-more-prominent

    Change-Id: Ie5484597057a3306757cc46b657446ad61ac2098

Changed in devstack:
status: In Progress → Fix Released
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.