]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commit
Don't create cgsnapshot if cg is empty
authorAccela Zhao <accelazh@gmail.com>
Wed, 3 Feb 2016 07:19:45 +0000 (23:19 -0800)
committerAccela Zhao <accelazh@gmail.com>
Wed, 3 Feb 2016 22:16:30 +0000 (14:16 -0800)
commit8260169fa72655705d4c86640c08e4262538bb09
tree1da6dd54432d94c8abbbc8da6fcb10147df51a5e
parent7a6f1d8a445fe0820d584222401114ff6a1f8244
Don't create cgsnapshot if cg is empty

If we create cgsnapshot from an empty consistencygroup, it fails
with "Consistency group is empty. No cgsnapshot will be created".
However, a cgsnapshot object is still created in DB.

This is because in cinder/consistencygroup/api.py::_create_cgsnapshot,
we create cgsnapshot object before we test whether the corresponding
consistencygroup is empy.

This patch fixes this problem by moving the creation of cgsnapshot
object to after the test of whether consistencygroup is empty.

Change-Id: I09500ab1cf19b28591668a3fed6834d1a73ad176
Closes-Bug: #1535979
cinder/consistencygroup/api.py
cinder/tests/unit/api/contrib/test_cgsnapshots.py