Don't create swift container if plan creation fails
Change-Id: I5e2f16bf4b153fbbd2d75c13dd116bd40a1f11f4 Depends-On: I5ae14eba2cc6707fa8e5273bdd93fcc10ac9d15a Closes-bug: #1648861
This commit is contained in:
parent
b6f42f2a3c
commit
de398c6d18
@ -30,5 +30,8 @@ fixes:
|
||||
- Fixes `bug 1637474
|
||||
<https://bugs.launchpad.net/tripleo/+bug/1637474>`__ so we manage
|
||||
--initial-state flag for register_or_update.
|
||||
- Fixes `bug 1648861
|
||||
<https://bugs.launchpad.net/tripleo/+bug/1648861>`__ so that if the plan
|
||||
creation fails, the Swift container isn't created.
|
||||
other:
|
||||
- Remove the keystone_pki cert generation, which is not needed anymore.
|
||||
|
@ -106,6 +106,7 @@ class TestOvercloudCreatePlan(utils.TestCommand):
|
||||
self.app.client_manager.tripleoclient = self.tripleoclient
|
||||
|
||||
self.workflow = self.app.client_manager.workflow_engine
|
||||
self.swift = self.app.client_manager.tripleoclient.object_store
|
||||
|
||||
# Mock UUID4 generation for every test
|
||||
uuid4_patcher = mock.patch('uuid.uuid4', return_value="UUID4")
|
||||
@ -216,6 +217,28 @@ class TestOvercloudCreatePlan(utils.TestCommand):
|
||||
mock_result = mock.Mock(output='{"result": null}')
|
||||
self.workflow.action_executions.create.return_value = mock_result
|
||||
|
||||
self.swift.get_account.return_value = (
|
||||
{u'accept-ranges': u'bytes'},
|
||||
[{u'bytes': 1719440, u'count': 482, u'name': u'overcast'},
|
||||
{u'bytes': 1719440, u'count': 482, u'name': u'overcloud'}]
|
||||
)
|
||||
|
||||
self.swift.get_container.return_value = (
|
||||
{u'x-container-meta-usage-tripleo': u'plan'},
|
||||
[{u'hash': u'2df2606ed8b866806b162ab3fa9a77ea',
|
||||
u'last_modified': u'2016-12-09T21:18:16.172610', u'bytes': 808,
|
||||
u'name': u'all-nodes-validation.yaml',
|
||||
u'content_type': u'application/octet-stream'},
|
||||
{u'hash': u'0f1043e65e95ec24054a4ea63cdb3984',
|
||||
u'last_modified': u'2016-12-09T21:18:19.612600', u'bytes': 583,
|
||||
u'name': u'bootstrap-config.yaml',
|
||||
u'content_type': u'application/octet-stream'},
|
||||
{u'hash': u'f9415b93617acd6b151582543a77c689',
|
||||
u'last_modified': u'2016-12-09T21:18:16.486870', u'bytes': 20903,
|
||||
u'name': u'capabilities-map.yaml',
|
||||
u'content_type': u'application/octet-stream'}]
|
||||
)
|
||||
|
||||
# Run
|
||||
self.assertRaises(exceptions.WorkflowServiceError,
|
||||
self.cmd.take_action, parsed_args)
|
||||
@ -234,6 +257,14 @@ class TestOvercloudCreatePlan(utils.TestCommand):
|
||||
'generate_passwords': True
|
||||
})
|
||||
|
||||
self.swift.get_account.assert_called_once()
|
||||
self.swift.get_container.assert_called_once_with('overcast')
|
||||
self.swift.delete_object.assert_has_calls([
|
||||
mock.call('overcast', u'capabilities-map.yaml'),
|
||||
mock.call('overcast', u'bootstrap-config.yaml'),
|
||||
mock.call('overcast', u'all-nodes-validation.yaml'),
|
||||
], any_order=True)
|
||||
|
||||
def test_create_default_plan_with_password_gen_disabled(self):
|
||||
|
||||
# Setup
|
||||
|
@ -12,6 +12,7 @@
|
||||
import tempfile
|
||||
import uuid
|
||||
|
||||
from tripleo_common.utils import swift as swiftutils
|
||||
from tripleo_common.utils import tarball
|
||||
|
||||
from tripleoclient import constants
|
||||
@ -139,9 +140,14 @@ def create_plan_from_templates(clients, name, tht_root, roles_file=None,
|
||||
|
||||
print("Creating plan from template files in: {}".format(tht_root))
|
||||
_upload_templates(swift_client, name, tht_root, roles_file)
|
||||
|
||||
try:
|
||||
create_deployment_plan(clients, container=name,
|
||||
queue_name=str(uuid.uuid4()),
|
||||
generate_passwords=generate_passwords)
|
||||
except exceptions.WorkflowServiceError:
|
||||
swiftutils.delete_container(swift_client, name)
|
||||
raise
|
||||
|
||||
|
||||
def update_plan_from_templates(clients, name, tht_root, roles_file=None,
|
||||
@ -151,9 +157,7 @@ def update_plan_from_templates(clients, name, tht_root, roles_file=None,
|
||||
# TODO(dmatthews): Removing the existing plan files should probably be
|
||||
# a Mistral action.
|
||||
print("Removing the current plan files")
|
||||
headers, objects = swift_client.get_container(name)
|
||||
for object_ in objects:
|
||||
swift_client.delete_object(name, object_['name'])
|
||||
swiftutils.empty_container(swift_client, name)
|
||||
|
||||
# Until we have a well defined plan update workflow in tripleo-common we
|
||||
# need to manually reset the environments here. This is to ensure that
|
||||
|
Loading…
Reference in New Issue
Block a user