我在k8s
和istio
上使用头盔创建了一个应用。
它由2个微服务(前端/ api和db(postgres))组成。
api使用uwsgi
服务。
启动时失败,并显示以下错误:
alerta-5d7db46658-jpdkm alerta Traceback (most recent call last):
alerta-5d7db46658-jpdkm alerta server closed the connection unexpectedly
alerta-5d7db46658-jpdkm alerta This probably means the server terminated abno
rmally
alerta-5d7db46658-jpdkm alerta before or while processing the request.
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,360 DEBG 'uwsgi' stdout out
put:
alerta-5d7db46658-jpdkm alerta Traceback (most recent call last):
alerta-5d7db46658-jpdkm alerta File "./wsgi.py", line 1, in <module>
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,360 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta from alerta import app
alerta-5d7db46658-jpdkm alerta File "/venv/lib/python3.7/site-packages/alerta/__init__.py", line 29, in <module>
alerta-5d7db46658-jpdkm alerta app = create_app()
alerta-5d7db46658-jpdkm alerta File "/venv/lib/python3.7/site-packages/alerta/app.py", line 67, in create_app
alerta-5d7db46658-jpdkm alerta db.init_db(app)
alerta-5d7db46658-jpdkm alerta File "/venv/lib/python3.7/site-packages/alerta/database/base.py", line 47, in init_db
alerta-5d7db46658-jpdkm alerta self.create_engine(app, uri=app.config['DATABASE_URL'], dbname=app.config['DATABASE_NAME'])
alerta-5d7db46658-jpdkm alerta File "/venv/lib/python3.7/site-packages/alerta/database/backends/postgres/base.py", line 64, in create_engine
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,361 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta conn = self.connect()
alerta-5d7db46658-jpdkm alerta File "/venv/lib/python3.7/site-packages/alerta/database/backends/postgres/base.py", line 104, in connect
alerta-5d7db46658-jpdkm alerta raise RuntimeError('Database connect error. Failed to connect after {} retries.'.format(MAX_RETRIES))
alerta-5d7db46658-jpdkm alerta RuntimeError: Database connect error. Failed to connect after 5 retries.
alerta-5d7db46658-jpdkm alerta unable to load app 0 (mountpoint='') (callable not found or import error)
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,361 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta mounting wsgi:app on /api
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,365 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta Traceback (most recent call last):
alerta-5d7db46658-jpdkm alerta File "/usr/local/lib/python3.7/logging/config.py", line 388, in resolve
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,365 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta found = getattr(found, frag)
alerta-5d7db46658-jpdkm alerta AttributeError: module 'alerta' has no attribute 'utils'
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta During handling of the above exception, another exception occurred:
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta Traceback (most recent call last):
alerta-5d7db46658-jpdkm alerta File "/usr/local/lib/python3.7/logging/config.py", line 543, in configure
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,365 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta formatters[name])
alerta-5d7db46658-jpdkm alerta File "/usr/local/lib/python3.7/logging/config.py", line 654, in configure_formatter
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,366 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta result = self.configure_custom(config)
alerta-5d7db46658-jpdkm alerta File "/usr/local/lib/python3.7/logging/config.py", line 469, in configure_custom
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,366 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta c = self.resolve(c)
alerta-5d7db46658-jpdkm alerta File "/usr/local/lib/python3.7/logging/config.py", line 391, in resolve
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,366 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta found = getattr(found, frag)
alerta-5d7db46658-jpdkm alerta AttributeError: module 'alerta' has no attribute 'utils'
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta The above exception was the direct cause of the following exception:
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,366 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta Traceback (most recent call last):
alerta-5d7db46658-jpdkm alerta File "./wsgi.py", line 1, in <module>
alerta-5d7db46658-jpdkm alerta from alerta import app
alerta-5d7db46658-jpdkm alerta File "/venv/lib/python3.7/site-packages/alerta/__init__.py", line 29, in <module>
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,366 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta app = create_app()
alerta-5d7db46658-jpdkm alerta File "/venv/lib/python3.7/site-packages/alerta/app.py", line 53, in create_app
alerta-5d7db46658-jpdkm alerta logger.setup_logging(app)
alerta-5d7db46658-jpdkm alerta File "/venv/lib/python3.7/site-packages/alerta/utils/logging.py", line 97, in setup_logging
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,367 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta 'handlers': app.config['LOG_HANDLERS']
alerta-5d7db46658-jpdkm alerta File "/usr/local/lib/python3.7/logging/config.py", line 800, in dictConfig
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,367 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta dictConfigClass(config).configure()
alerta-5d7db46658-jpdkm alerta File "/usr/local/lib/python3.7/logging/config.py", line 546, in configure
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,367 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta 'formatter %r' % name) from e
alerta-5d7db46658-jpdkm alerta ValueError: Unable to configure formatter 'default'
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,367 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta unable to load app 0 (mountpoint='/api') (callable not found or import error)
alerta-5d7db46658-jpdkm alerta *** no app loaded. going in full dynamic mode ***
alerta-5d7db46658-jpdkm alerta *** uWSGI is running in multiple interpreter mode ***
alerta-5d7db46658-jpdkm alerta spawned uWSGI master process (pid: 11)
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,369 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta spawned uWSGI worker 1 (pid: 20, cores: 1)
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,369 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta spawned uWSGI worker 2 (pid: 21, cores: 1)
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,370 DEBG 'uwsgi' stdout output:
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,367 DEBG 'uwsgi' stdout out
put:
alerta-5d7db46658-jpdkm alerta 'formatter %r' % name) from e
alerta-5d7db46658-jpdkm alerta ValueError: Unable to configure formatter 'defa
ult'
alerta-5d7db46658-jpdkm alerta
alerta-5d7db46658-jpdkm alerta 2020-05-03 13:31:43,367 DEBG 'uwsgi' stdout out
put:
alerta-5d7db46658-jpdkm alerta unable to load app 0 (mountpoint='/api') (calla
ble not found or import error)
alerta-5d7db46658-jpdkm alerta *** no app loaded. going in full dynamic mode *
**
此微服务使用一个连接字符串,当尝试利用它从api pod连接到数据库时,出现以下错误:
alerta@alerta-758bc87dcf-4r9bz:/$ psql postgresql://alerta:changeme@alerta-postgresql:5432/monitoring
psql: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
在尝试进行任何连接时,postgres
日志中都会出现以下内容
alerta-postgresql-0 alerta-postgresql 2020-05-03 15:02:46.787 GMT [1274] LOG: invalid length of startup packet
有什么建议吗?
编辑:postgres
启动期间的日志
alerta-postgresql-0 alerta-postgresql 2020-05-03 14:47:47.444 GMT [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
alerta-postgresql-0 alerta-postgresql 2020-05-03 14:47:47.444 GMT [1] LOG: listening on IPv6 address "::", port 5432