Merge "zun: check delete complete for Zun container"

This commit is contained in:
Zuul 2018-02-07 04:01:54 +00:00 committed by Gerrit Code Review
commit 4289cbaa59
2 changed files with 14 additions and 0 deletions

View File

@ -203,9 +203,20 @@ class Container(resource.Resource):
return
try:
self.client().containers.delete(self.resource_id, stop=True)
return self.resource_id
except Exception as exc:
self.client_plugin().ignore_not_found(exc)
def check_delete_complete(self, id):
if not id:
return True
try:
self.client().containers.get(id)
except Exception as exc:
self.client_plugin().ignore_not_found(exc)
return True
return False
def _resolve_attribute(self, name):
if self.resource_id is None:
return

View File

@ -16,6 +16,7 @@ import mock
import six
from oslo_config import cfg
from zunclient import exceptions as zc_exc
from heat.common import exception
from heat.common import template_format
@ -229,6 +230,8 @@ class ZunContainerTest(common.HeatTestCase):
def test_container_delete(self):
c = self._create_resource('container', self.rsrc_defn, self.stack)
scheduler.TaskRunner(c.create)()
self.patchobject(self.client.containers, 'get',
side_effect=[c, zc_exc.NotFound('Not Found')])
scheduler.TaskRunner(c.delete)()
self.assertEqual((c.DELETE, c.COMPLETE), c.state)
self.client.containers.delete.assert_called_once_with(