The previous commit [1] introduced a decorator to cleanup db sessions
at the end of the call. If an exception happen before calling the
db_api, sys.exc_info() will still carry the exception information,
which can lead to problems depending on the use case. This commit
makes sure that we only use the exception value of the db function
execution.
Test plan:
- PASS: Build a custom ISO with the changes and deploy a DX system
controller and a SX subcloud. Verify the system works as
expected.
- PASS: Manage a subcloud and verify the sync_status is "in-sync".
- PASS: Soak the system and verify there was no connection leak and
no sessions stuck in "idle in transaction" state.
[1]: https://review.opendev.org/c/starlingx/fault/+/943387
Story: 2011311
Task: 51790
Change-Id: Ib5c5f052aadebc19e671564739d3d2d74a1de5fb
Signed-off-by: Victor Romano <victor.gluzromano@windriver.com>