We are using retrying for database connection, but that decorator
can only have default value of max_retries and retry_interval because
it happens at import time. We should use configured values instead,
so this patch moves those code into inner function, which makes
retrying get parameters at running time.
We override max_retries for some rare case when using oslo.db, but
that is not the right behavior. For example, collector will connect
to metering and event databases, if one is sqlalchemy and the other
one is MongoDB then when MongoDB lost connection in serving time,
then the max_retries will be zero which will cause safe_mongo_call not
work as expected. The right behavior for that sqlalchemy problem
is enforcing max_retries when we pass it to connection __init__ method.
Note: This patch also applies the enforcement to alarm and event
sqlalchemy implementations.
ref: https://review.openstack.org/#/c/127128/9
Change-Id: Ia8bec410c1cabe850c8d033daef5a5a0ddae8954
Closes-Bug: #1421485