Fix snapshot delete in convergence

The patch at I1cb321a3878a0abce9b41832f76bf77c25bf7cb4 properly deleted
the snapshots from the database, but as delete in convergence sets the
template to an empty template, stack.resources is empty. This works
around the problem by deleting the snapshots beforehand.

Related-Bug: #1508299
Change-Id: Id1c2c1a293fdcda07c527f29fedc00b716b303bc
This commit is contained in:
Thomas Herve
2017-05-03 16:40:28 +02:00
parent aa10e29975
commit df1708b1a8
3 changed files with 9 additions and 45 deletions

View File

@@ -1304,14 +1304,6 @@ class Stack(collections.Mapping):
LOG.info('convergence_dependencies: %s',
self.convergence_dependencies)
# Delete all the snapshots before starting delete operation
if self.action == self.DELETE:
snapshots = snapshot_object.Snapshot.get_all(self.context,
self.id)
for snapshot in snapshots:
self.delete_snapshot(snapshot)
snapshot_object.Snapshot.delete(self.context, snapshot.id)
# create sync_points for resources in DB
for rsrc_id, is_update in self.convergence_dependencies:
sync_point.create(self.context, rsrc_id,
@@ -1788,11 +1780,7 @@ class Stack(collections.Mapping):
'Failed to %s : %s' % (action, failure))
return
snapshots = snapshot_object.Snapshot.get_all(self.context,
self.id)
for snapshot in snapshots:
self.delete_snapshot(snapshot)
snapshot_object.Snapshot.delete(self.context, snapshot.id)
self.delete_all_snapshots()
if not backup:
try:
@@ -1904,6 +1892,13 @@ class Stack(collections.Mapping):
pre_completion_func=save_snapshot_func)
sus_task(timeout=self.timeout_secs())
def delete_all_snapshots(self):
"""Remove all snapshots for this stack."""
snapshots = snapshot_object.Snapshot.get_all(self.context, self.id)
for snapshot in snapshots:
self.delete_snapshot(snapshot)
snapshot_object.Snapshot.delete(self.context, snapshot.id)
@profiler.trace('Stack.delete_snapshot', hide_args=False)
def delete_snapshot(self, snapshot):
"""Remove a snapshot from the backends."""