ERROR sqlalchemy.exc.InvalidRequestError: No such event 'pending_to_persistent' for target '<class 'sqlalchemy.orm.session.Session'>'
OpenStack-Controller 节点 neutron 相关服务重启失败
排查报错如下
[root@controller ~]# su -g neutron -c '/usr/bin/neutron-server --config-file /usr/share/neutron/neutron-dist.conf --config-dir /usr/share/neutron/server --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini --config-dir /etc/neutron/conf.d/common --config-dir /etc/neutron/conf.d/neutron-server --log-file /var/log/neutron/server.log'
Traceback (most recent call last):
File "/usr/bin/neutron-server", line 6, in <module>
from neutron.cmd.eventlet.server import main
File "/usr/lib/python2.7/site-packages/neutron/cmd/eventlet/server/__init__.py", line 13, in <module>
from neutron import server
File "/usr/lib/python2.7/site-packages/neutron/server/__init__.py", line 25, in <module>
from neutron.common import config
File "/usr/lib/python2.7/site-packages/neutron/common/config.py", line 23, in <module>
from neutron_lib.api import validators
File "/usr/lib/python2.7/site-packages/neutron_lib/__init__.py", line 15, in <module>
from neutron_lib.db import api # noqa
File "/usr/lib/python2.7/site-packages/neutron_lib/db/api.py", line 420, in <module>
@event.listens_for(orm.session.Session, "pending_to_persistent")
File "/usr/lib64/python2.7/site-packages/sqlalchemy/event/api.py", line 124, in decorate
listen(target, identifier, fn, *args, **kw)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/event/api.py", line 89, in listen
_event_key(target, identifier, fn).listen(*args, **kw)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/event/api.py", line 28, in _event_key
(identifier, target))
sqlalchemy.exc.InvalidRequestError: No such event 'pending_to_persistent' for target '<class 'sqlalchemy.orm.session.Session'>'
...继续
在sqlalchemy官方文档, 找到了 pending_to_persistent 定义
https://docs.sqlalchemy.org/en/14/orm/events.html?highlight=pending_to_persistent#sqlalchemy.orm.SessionEvents.pending_to_persistent
发现: 'pending_to_persistent' New in version 1.1.
排查服务器
[root@controller ~]# pip show sqlalchemy
---
Metadata-Version: 1.1
Name: SQLAlchemy
Version: 1.0.19
Summary: Database Abstraction Library
Home-page: http://www.sqlalchemy.org
Author: Mike Bayer
Author-email: mike_mp@zzzcomputing.com
License: MIT License
Location: /usr/lib64/python2.7/site-packages
Requires:
Classifiers:
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: Jython
Programming Language :: Python :: Implementation :: PyPy
Topic :: Database :: Front-Ends
Operating System :: OS Independent
虚拟机里装了很多乱起八糟的依赖, 估计是哪个包导致 sqlalchemy 版本降了, neutron 被殃及了
解决方案
确定 sqlalchemy 版本范围
官方依赖版本要求如下
https://github.com/openstack/neutron/blob/stable/train/requirements.txt
...
SQLAlchemy>=1.2.0 # MIT
...
升级 sqlalchemy
[root@controller ~]# pip install sqlalchemy==1.3.8
Collecting sqlalchemy==1.3.8
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fc/49/82d64d705ced344ba458197dadab30cfa745f9650ee22260ac2b275d288c/SQLAlchemy-1.3.8.tar.gz (5.9MB)
100% |████████████████████████████████| 5.9MB 2.0MB/s
Installing collected packages: sqlalchemy
Found existing installation: SQLAlchemy 1.0.19
Uninstalling SQLAlchemy-1.0.19:
Successfully uninstalled SQLAlchemy-1.0.19
Running setup.py install for sqlalchemy ... done
Successfully installed sqlalchemy-1.3.8
重启服务
[root@controller ~]# systemctl restart neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service
[root@controller ~]# systemctl restart neutron-l3-agent.service
验证
[root@controller ~]# systemctl -a | grep neutron
neutron-dhcp-agent.service loaded active running OpenStack Neutron DHCP Agent
neutron-l3-agent.service loaded active running OpenStack Neutron Layer 3 Agent
neutron-linuxbridge-agent.service loaded active running OpenStack Neutron Linux Bridge Agent
neutron-metadata-agent.service loaded active running OpenStack Neutron Metadata Agent
neutron-server.service loaded active running OpenStack Neutron Server
ok
(☞゚ヮ゚)☞ ☜(゚ヮ゚☜))