Commit Graph

19 Commits

Author SHA1 Message Date
wanghao 88f0dd7c8f Introduce the Topic resource into Zaqar-1
This patch will Introduce the Topic resource into Zaqar
and implement the storage in mongodb.

Change-Id: I6d37c93aa75d7df78d3939044b0e8fefa5d9a5f5
Implements: bp introduce-topic-resource-for-notification
2019-03-07 10:16:39 +08:00
xywang a7df08deb9 CONF file structure refactor
This is the openstack governance goal that the config files should
be merged into one folder to make the code to be better understood
and managed.

Change-Id: I33dd85145d9f5b0384323ffa51b4d68de0aeb5b7
2018-06-04 09:11:46 +08:00
Mike Bayer 8c374b1e7f Use oslo_db for create_engine
The use of plain SQLAlchemy create_engine in Zaqar bypasses
lots of oslo_db features that are associated with its
version of create_engine, some useful and some critical.

Among favorable behaviors that are added:

* The SQLite PRAGMA FOREIGN KEYS call is abstracted into the
  sqlite_fk flag
* The engine is given a pessimistic "ping" event, which emits
  a "SELECT 1" upon connection checkout which will then recycle
  the connection if the backing database is no longer connected.
  As we are using a connection pool, if the database has been
  restarted, or in the case of MySQL a default timeout of eight
  hours idle has passed, existing pooled connections will be stale.
  Upcoming SQLAlchemy 1.2 includes this feature as a simple flag
  but for now, oslo_db implements the event listener as directed
  by SQLA docs
* The errors raised by the DBAPI, and then wrapped by SQLAlchemy,
  are further sub-classified.  In particular, Zaqar seems to use
  a lot of IntegrityError catches to detect duplicate entry and
  foreign key constraint conditions.  oslo_db parses these out on
  a per-database-basis into individual DBDuplicateEntry,
  DBReferenceError, and other error classes, allowing Zaqar to
  respond specifically to the sub-class of IntegrityError or
  allow it to propagate if the condition is unhandled.
* checks for MySQL SQL_MODE and best practice driver (pymysql)
  will emit warnings if these conditions are not met.
* Gets Zaqar ready for further oslo.db integration and guides
  new features into oslo_db, including a potential "mysql timezone"
  setting

Change-Id: I16c3ed89e006e132bbd0295be1dfd0b561b2037c
Resolves-bug: https://bugs.launchpad.net/tripleo/+bug/1691951
2017-06-12 21:29:11 -04:00
Mike Bayer f0de7b283c Simplify SQL run() method
Currently, Zaqar is using only Core SQL in an autocommit
context, meaning, no ORM, and when a statement is run,
it's on a new pool checkout, autocommit, returned.

In that case there's no reason to deal with the ORM
Session or thread-local scope of scoped_session() since there
is no state being used across requests here, other than the
"engine" itself.

Keeping in mind Zaqar wants to move to a transactionalized
pattern w/ context managers, for now they are doing the equivalent
of connectionless execution.   Just switch to that for now.

Change-Id: I06bfb96381864448a874278364f06489bdc76ddd
2017-06-05 15:07:32 +02:00
Thomas Herve 10b07c9ccf Remove table creation from the SQL driver
Table creation must happen outside of API requests. This changes the
devstack plugin to create the tables properly.

Change-Id: I57c4fba06dc6725ea977477b777e4ffd6856adde
2017-02-22 16:29:58 -05:00
Zhi Yan Liu 47324171d4 Integrate OSprofiler with Zaqar
*) Add osprofiler wsgi middleware
This middleware is used for 2 things:
1) It checks that person who want to trace is trusted and knows
secret HMAC key.
2) It start tracing in case of proper trace headers
and add first wsgi trace point, with info about HTTP request.

*) Add initialization of osprofiler at start of server
Initialize and set an oslo.messaging based notifier instance
to osprofiler which be used to send notifications to Ceilometer.

*) Enable profile on existing useful storage backends
Change controller creation logic of data and control panel for
mongodb, redis and sqlalchemy storage backends, as well as
an aggregative pooling driver.

*) Add options to allow operator control profiles separately

NOTE to test this:
1) You have to enable necessary profiler option(s) base on your needed.
2) You need to enable follow services in localrc for devstack:
  CEILOMETER_NOTIFICATION_TOPICS=notifications,profiler
  ENABLED_SERVICES+=,ceilometer-acompute,ceilometer-acentral
  ENABLED_SERVICES+=,ceilometer-anotification,ceilometer-collector
  ENABLED_SERVICES+=,ceilometer-alarm-evaluator,ceilometer-alarm-notifier
  ENABLED_SERVICES+=,ceilometer-api
3) You should use python-zaqarclient with this change:
  I880c003511e9e4ef99806ba5b19d0ef6996be80b

Run any command with --os-profile <SECRET_KEY>
  $ openstack --os-profile <SECRET_KEY> queue list
  # it will print <Trace ID>
Get pretty HTML with traces:
  $ osprofiler trace show --html <Trace ID>
note that osprofiler should be run from admin user name & tenant.

DocImpact

Partially-implements BP: osprofiler
Change-Id: I32565de6c447cd5e95a0ef54a9fbd4e571c2d820
Co-Authored-By: wangxiyuan <wangxiyuan@huawei.com>
2016-11-18 08:33:31 +00:00
wangxiyuan 8e5be21524 Avoid multi-threading problem with sql backend
Now zaqar's sql backend always use only one connection
to db. It will lead an multi-thread problem:
pymysql.err.InternalError) Packet sequence number wrong

So we should use session in sqlalchemy to avoid this happen.

Change-Id: I84e2f9899e141aed151f7c06fc4b1f603481886e
Closes-bug: #1588117
2016-06-06 09:46:53 +08:00
ChenZheng 666ab97e01 Trival: Remove unused logging import In some files
In some files, oslo_log.log has been imported but not used. Need to remove it.

Change-Id: Ib70dbbb2469067c16cf8422e1af572a914a214ec
2015-12-28 14:22:23 +08:00
Thomas Herve 0dcca4663f Close backend connections in tests
Tests creates connections to backends that we need to explicitly close
so that they don't pile up. This adds new methods to drivers,
implementation on the various backends, and cleanup calls in tests to do
so.

Change-Id: I48fb31f21403d5af56b13979eb8710cbf42948e4
2015-09-19 22:29:21 +02:00
Flavio Percoco b7bb8bca0d Add support for flavors in sqlalchemy
This adds a new FlavorsController for sqlalchemy. It follows closely
what mongodb's controller does and it was forked from sqlalchemy's pool
controller.

Change-Id: I22d01fc93d030fbd8c97c481616f0f76bd620505
Closes-bug: #1489883
2015-09-02 00:02:57 +02:00
Ryan S. Brown 899b5be59b Satisfy abstract base by adding queue_controller
Sqlalchemy management store was missing its queue_controller property,
causing the server to fail on startup.

Change-Id: I590be382cb783918e969b62ae4b177db4eb5afef
2015-06-26 10:28:53 -04:00
Flavio Percoco a3a80c8e5c Remove messages and claims from sql code
Remove data modules from the sqlalchemy package since we don't support
them anymore.

Closes-bug: #1461962
Change-Id: I28abb510ea918ece65e5b28271b4d921221e6877
2015-06-05 11:16:34 +02:00
Jeremy Stanley 11dca03384 Switch from MySQL-python to PyMySQL
As discussed in the Liberty Design Summit "Moving apps to Python 3"
cross-project workshop, the way forward in the near future is to
switch to the pure-python PyMySQL library as a default.

https://etherpad.openstack.org/p/liberty-cross-project-python3

Change-Id: I35ac53ec8a51ef0037c81aa939b871c9d037272d
2015-05-30 14:40:44 +00:00
Flavio Percoco 35f2764204 Remove sqlalchemy from our data plane
This patch removes the sqlalchemy as a valid data driver. In order to
make this work properly, we also need the data plane to be properly
split into 2 completely independent pipelines.

This patch, unfortunately, disables some of the sqlalchemy's tests for
queues and pools. The reason is that, until these planes are correctly
separated and pooling is enabled by default, we won't be able to
properly run those tests. A follow-up patch, expected to land in kilo,
will do this.

DocImpact

Implements blueprint: disable-sqlalchemy-as-pool

Change-Id: I5ca73102241692b0e1b23b3eaaaf1938f0106dfa
2015-03-29 18:26:36 -03:00
Fei Long Wang 1b694eb485 Implement mongodb driver for notifications
This patch adds the base API for notification to the storage layer,
and an init mongodb driver. The API follows pretty much the leads
of other APIs and supports basic operations that allow users to
create, delete, update and retrieve subscriptions for notification.

Partially-Implements blueprint: notifications

Change-Id: Ie065aaec16b9e6dbf9d31d93320bf6e691a4ed37
2015-01-16 00:55:43 +13:00
Jenkins e5ef9c9720 Merge "Split Control and Data planes of Storage layer" 2014-12-12 22:59:47 +00:00
Flavio Percoco 55624816bd Add capabilities property to the DataDriver
This patch adds the capabilities property to DataDrivers as a first step
to support storage capabilities. For now, capabilities are static for
storage drivers, whereas they are calculated dynamically for pooled
drivers.

Follow up patches will make drivers capabilities dynamic.

Change-Id: I29602ab5c8b3857caa3a5a6b1e9e37a5f88b2eef
Partial-blueprint: expose-storage-capabilities
2014-12-12 15:06:20 +01:00
Shaifali Agrawal 44ceb3d392 Split Control and Data planes of Storage layer
To split Data/Control planes first separate groups for options are created.
Accordingly registered data and control plane options in the new group.
Modified drivers modules and many test cases.

Change-Id: I413b30b14ea605a7b3f22d6a51059a601af71e76
2014-12-11 09:06:48 -08:00
Fei Long Wang 166abfd303 Refactor code structure for notification
Given we are going to implement notification, so the 'queues'
package is not suitable for current scope of zaqar. This
patch will remove the 'queues' package.

Partially implements: blueprint notifications

Change-Id: I6984f31f4bd1e646b585c45c088ed239b58587c4
2014-12-09 16:19:42 +13:00