Use ContextFormatter for imparting context info

Currently, we are using a logger instance adapter - ContextAdapter -
for imparting contextual information into log records (e.g. API
request ids). Unfortunately, the way ContextAdapter is applied to
logger instances makes them unusable for 3rd party libraries: there
is a helper factory function in openstack.common.log - getLogger() -
which obtains a logger instance via standard Python interface and
wraps it in a ContextAdapter instance. 3rd party libraries (e.g.
SQLAlchemy) know nothing about oslo-incubator code, so their log
records in log files of OpenStack services won't have request_id
value set.

In order to fix this issue we can rely on the fact that all log
entries are propagated up to the root logger. Moving imparting of
contextual information into a handler/formatter bound to the root
logger, would allow us to modify log records of 3rd party libraries
too.

DocImpact

If logging is configured using a separate configuration file rather
than via project.conf, deployers can use ContextFormatter formatter
provided by openstack.common.log module in order to impart contextual
information into log messages (e.g. request_id), so that it would be
possible to correlate log messages of third-party libraries like e.g.
SQLAlchemy with requests to API services.

Closes-Bug: #1263714

Change-Id: Ibe6edf1fcf111481abfd750fcbef89209ee9d615
Only enable MySQL TRADITIONAL mode if we're running against MySQL

Change I2960435c81d21f5a65ea7fa4dc5c100880cf6aef, which enabled
MySQL TRADITIONAL mode, erroneously would attempt to enable that
MySQL-specific mode on both MySQL and DB2 connections. Only enable
TRADITIONAL mode when actually running against MySQL.

Change-Id: I28c40c47e2515112555f2abdd2ecc4dc5c3399f6
Clean up docstring in db.sqlalchemy.session

When generating the docs, a couple of warnings were generated for
invalid RST in the module-level docstring for
db.sqlalchemy.session. This change cleans up the docstring.

Change-Id: Id08c876c6698b4ef329247c1d034033f0bfa86cb
Correct docstring in load_plugin_from_args

apiclient/auth.py load_plugin_from_args docstring :raises: line does not
match the method's actual behavior. The method appears correct, so this
patch corrects the docstring.

Change-Id: I0acefd91682bab778800b92d72bc062806773355
Closes-bug: #1274660
Revert "service: replace eventlet event by threading"

This reverts commit f08f6ba7e80729fb6028b24568da0f651a75fcd6.

This was a terrible idea: as soon as you don't monkey patch threading,
this does not work as expected in the end.

So it's better to say that it's explicitly eventlet mechanisms that are
required, at least for now.

Conflicts:
	tests/unit/test_service.py

Partial-Bug: #1274044

Change-Id: I4d4f112d4550d912c4f81e62bc9a4714cf117384
Fix policy tests for parallel testing

After enabling parallel testing for most of oslo-incubator, I
found that a number of the policy tests were failing consistently
due to order-dependent behavior in them.  This change fixes all
of the issues that I saw in local testing.

Change-Id: I670415d616db433d17186f496f43c961aaeb2e9b
Closes-Bug: #1275150
Related-Bug: #1272035
Move the released file lock to the successful path

Instead of logging that the lock was released even
if there was an error that caused it not to be
unreleased we should only log that it was released
after it really was.

Change-Id: Id3f37b801a1d5efd2dcb4a9803989df50a36e7de
Use Context Manager for reading JSON configs

Avoids leaking a fd when there's an exception.

Change-Id: Iacd10edc58037192a2e710c47a6caf0da40c6d71
Merge "Use ContextFormatter for imparting context info"
Drop dependency on log from oslo db code

Openstack common log module registers a few oslo.config options,
which can possibly lead to unpleasant issues (DuplicateOptError)
when we split oslo.db from oslo-incubator into a separate library
and reuse both log and oslo.db in target projects.

We don't use for example, any of the special formatting supported by
ContextAdaptor so we can use logging module from python standart library
instead of common log module.

Related to blueprint oslo-db-lib

Change-Id: I6ec426274eb3b603dbbc894762edb97515a618b2
Merge "Only enable MySQL TRADITIONAL mode if we're running against MySQL"
Handle exception messages with six.text_type

Handle exception messages with six.text_type tools instead of using
string. This is necessary becase a message can contain
non-ascii characters and it can cause the unicode error:
"UnicodeError: Message objects do not support str() because they may
contain non-ascii characters. Please use unicode() or translate()
instead."

Change-Id: I3312b75731c1ce49e2f1069c83e1a868805409d3
Closes-Bug: #1273301
Merge "Revert "service: replace eventlet event by threading""
Merge "Move the released file lock to the successful path"
Merge "Fix policy tests for parallel testing"
Merge "Correct docstring in load_plugin_from_args"
Merge "Clean up docstring in db.sqlalchemy.session"
Don't raise MySQL 2013 'Lost connection' errors

Closes-bug: #1276510

Although this code error is part of the `ping_listener` tests, it was
missing from the list of known - and ignored - connection errors.

The code error 2013 refers to a connection lost during a query, see:
https://dev.mysql.com/doc/refman/5.0/en/error-messages-client.html#error_cr_server_lost

Without this error code, the session won't try to reconnect to mysql,
which makes `max_retries` useless.

Change-Id: If2667cf83ac656666ffe00aa90e3454516b080db
Merge "Handle exception messages with six.text_type"
Merge "Use Context Manager for reading JSON configs"