Only delete and re-create managed Mistral workflows
In Pike Mistral workflows in tripleo-common were tagged with `tripleo-common-managed`. During the transition we needed to conder installs with no tagged workflows. However, users of Queens and above will already have this handled, so the extra code and the test case can be removed. Change-Id: I06b3bccf03c1e2851c0bc3b291cefbf24ff7dbff
This commit is contained in:
parent
ee94c3a259
commit
e3c3e89b50
@ -1354,54 +1354,8 @@ class TestPostConfig(BaseTestCase):
|
||||
@mock.patch('instack_undercloud.undercloud._create_mistral_config_'
|
||||
'environment')
|
||||
@mock.patch('instack_undercloud.undercloud._create_default_plan')
|
||||
def test_post_config_mistral(self, mock_create, mock_cmce, mock_listdir,
|
||||
mock_isfile):
|
||||
instack_env = {}
|
||||
mock_mistral = mock.Mock()
|
||||
mock_swift = mock.Mock()
|
||||
mock_swift.get_account.return_value = [None, [{'name': 'hut8'}]]
|
||||
|
||||
mock_workbooks = [mock.Mock() for m in range(2)]
|
||||
mock_workbooks[0].name = 'foo'
|
||||
mock_workbooks[1].name = 'tripleo.bar'
|
||||
mock_mistral.workbooks.list.return_value = mock_workbooks
|
||||
|
||||
mock_triggers = [mock.Mock() for m in range(2)]
|
||||
mock_triggers[0].name = 'foobar'
|
||||
mock_triggers[0].workflow_name = 'foo'
|
||||
mock_triggers[1].name = 'delete_me'
|
||||
mock_triggers[1].workflow_name = 'tripleo.bar'
|
||||
mock_mistral.cron_triggers.list.return_value = mock_triggers
|
||||
|
||||
mock_workflows = [mock.Mock() for m in range(2)]
|
||||
mock_workflows[0].name = 'foo'
|
||||
mock_workflows[1].name = 'tripleo.bar'
|
||||
mock_workflows[0].tags = []
|
||||
mock_workflows[1].tags = []
|
||||
mock_mistral.workflows.list.return_value = mock_workflows
|
||||
mock_listdir.return_value = ['foo.yaml', 'bar.yaml']
|
||||
undercloud._post_config_mistral(instack_env, mock_mistral, mock_swift)
|
||||
self.assertEqual([mock.call('tripleo.bar')],
|
||||
mock_mistral.workbooks.delete.mock_calls)
|
||||
self.assertEqual([mock.call('tripleo.bar')],
|
||||
mock_mistral.workflows.delete.mock_calls)
|
||||
self.assertEqual([mock.call('delete_me')],
|
||||
mock_mistral.cron_triggers.delete.mock_calls)
|
||||
self.assertEqual([mock.call(undercloud.PATHS.WORKBOOK_PATH +
|
||||
'/foo.yaml'),
|
||||
mock.call(undercloud.PATHS.WORKBOOK_PATH +
|
||||
'/bar.yaml')],
|
||||
mock_mistral.workbooks.create.mock_calls)
|
||||
mock_cmce.assert_called_once_with(instack_env, mock_mistral)
|
||||
mock_create.assert_called_once_with(mock_mistral, ['hut8'])
|
||||
|
||||
@mock.patch('os.path.isfile', return_value=True)
|
||||
@mock.patch('os.listdir')
|
||||
@mock.patch('instack_undercloud.undercloud._create_mistral_config_'
|
||||
'environment')
|
||||
@mock.patch('instack_undercloud.undercloud._create_default_plan')
|
||||
def test_post_config_mistral_with_tags(self, mock_create, mock_cmce,
|
||||
mock_listdir, mock_isfile):
|
||||
def test_post_config_mistral(self, mock_create, mock_cmce,
|
||||
mock_listdir, mock_isfile):
|
||||
instack_env = {}
|
||||
mock_mistral = mock.Mock()
|
||||
mock_swift = mock.Mock()
|
||||
|
@ -1916,21 +1916,8 @@ def _post_config_mistral(instack_env, mistral, swift):
|
||||
managed_tag = 'tripleo-common-managed'
|
||||
|
||||
all_workflows = mistral.workflows.list()
|
||||
workflow_tags = set()
|
||||
for workflow in all_workflows:
|
||||
workflow_tags.update(workflow.tags)
|
||||
|
||||
# If at least one workflow is tagged, then we should only delete those.
|
||||
# Otherwise we should revert to the previous behaviour - this is required
|
||||
# for the initial upgrade.
|
||||
# TODO(d0ugal): From Q onwards we should only ever delete workflows with
|
||||
# the tripleo-common tag.
|
||||
if 'tripleo-common-managed' in workflow_tags:
|
||||
workflows_delete = [w.name for w in all_workflows
|
||||
if managed_tag in w.tags]
|
||||
else:
|
||||
workflows_delete = [w.name for w in all_workflows
|
||||
if w.name.startswith('tripleo')]
|
||||
workflows_delete = [w.name for w in all_workflows
|
||||
if managed_tag in w.tags]
|
||||
|
||||
# in order to delete workflows they should have no triggers associated
|
||||
for trigger in [t for t in mistral.cron_triggers.list()
|
||||
|
Loading…
Reference in New Issue
Block a user