diff --git a/heat/engine/worker.py b/heat/engine/worker.py index 0a5408495b..f9853b86c2 100644 --- a/heat/engine/worker.py +++ b/heat/engine/worker.py @@ -353,12 +353,7 @@ def check_resource_update(rsrc, template_id, resource_data, engine_id): ''' Create or update the Resource if appropriate. ''' - if (rsrc.resource_id is None - and not (rsrc.action == resource.Resource.CREATE and - rsrc.status in [ - resource.Resource.COMPLETE, - resource.Resource.FAILED - ])): + if rsrc.action == resource.Resource.INIT: rsrc.create_convergence(template_id, resource_data, engine_id) else: rsrc.update_convergence(template_id, resource_data, engine_id) diff --git a/heat/tests/engine/test_engine_worker.py b/heat/tests/engine/test_engine_worker.py index ccd9efd07d..05b50f45e5 100644 --- a/heat/tests/engine/test_engine_worker.py +++ b/heat/tests/engine/test_engine_worker.py @@ -508,32 +508,32 @@ class MiscMethodsTest(common.HeatTestCase): self.assertTrue(mock_sync.called) @mock.patch.object(resource.Resource, 'create_convergence') - def test_check_resource_update_create(self, mock_create): + @mock.patch.object(resource.Resource, 'update_convergence') + def test_check_resource_update_init_action(self, mock_update, mock_create): + self.resource.action = 'INIT' worker.check_resource_update(self.resource, self.resource.stack.t.id, {}, 'engine-id') self.assertTrue(mock_create.called) + self.assertFalse(mock_update.called) + @mock.patch.object(resource.Resource, 'create_convergence') @mock.patch.object(resource.Resource, 'update_convergence') - def test_check_resource_update_update(self, mock_update): - self.resource.resource_id = 'physical-res-id' + def test_check_resource_update_create_action( + self, mock_update, mock_create): + self.resource.action = 'CREATE' worker.check_resource_update(self.resource, self.resource.stack.t.id, {}, 'engine-id') + self.assertFalse(mock_create.called) self.assertTrue(mock_update.called) + @mock.patch.object(resource.Resource, 'create_convergence') @mock.patch.object(resource.Resource, 'update_convergence') - def test_check_resource_update_complete(self, mock_update): - self.resource.action = 'CREATE' - self.resource.status = 'COMPLETE' - worker.check_resource_update(self.resource, self.resource.stack.t.id, - {}, 'engine-id') - self.assertTrue(mock_update.called) - - @mock.patch.object(resource.Resource, 'update_convergence') - def test_check_resource_update_failed(self, mock_update): - self.resource.action = 'CREATE' - self.resource.status = 'FAILED' + def test_check_resource_update_update_action( + self, mock_update, mock_create): + self.resource.action = 'UPDATE' worker.check_resource_update(self.resource, self.resource.stack.t.id, {}, 'engine-id') + self.assertFalse(mock_create.called) self.assertTrue(mock_update.called) @mock.patch.object(resource.Resource, 'delete_convergence')