When an entry is made into the database when a resource is created, SQLalchemy performs a set of constraint checks to verify that the entry will be valid. In Barbican, a resource includes secrets, containers, consumers, transport-keys, etc. Constraints that can be checked include uniqueness (no duplicates), not null, matches an entry in another table (Foreign Key), etc.
When a constraint check fails, SQLalchemy raises the exception exc.IntegrityError.
BaseRepo():create_from() catches that and then raises the exception exc.Duplicate.
This can be misleading when debugging a problem, since the message now indicates that a duplicate entry exists, when in reality any number of constraints could have failed instead.
This code should raise a new exception that preserves more information about the failure, and does not provide incorrect information.
From barbican/model/repositories.py
try:
LOG.debug("Saving entity...")
entity.save(session=session)
except sqlalchemy.exc.IntegrityError:
LOG.exception(u._LE('Problem saving entity for create'))
_raise_entity_already_exists(self._do_entity_name())
Change abandoned by Kaitlin Farr (<email address hidden>) on branch: master /review. openstack. org/267826
Review: https:/
Reason: To clean up the Barbican review queue, I am abandoning this patch because it has negative reviews and has not been updated since the start of the current development cycle (Newton). Please feel free to restore the patch and address any comments or issues if you'd still like to contribute this patch.