Add skip_deploy_identifier
Add a new action argument, skip_deploy_identifier to DeployStackAction. The argument will disable setting a unique value for the DeployIdentifier parameter, which means the SoftwareDeployment resources in the templates will only be triggered if there is an actual change to their configuration. This argument can be used to avoid always applying configuration, such as during node scale out. Change-Id: Idb901a841846fec33d189b3c95f669b0380498ce Closes-Bug: #1688387 (cherry picked from commit9d15887430
) (cherry picked from commit320960c804
)
This commit is contained in:
parent
2958adb64f
commit
de872dd3de
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
features:
|
||||
- Add a new action argument, skip_deploy_identifier to DeployStackAction. The
|
||||
argument will disable setting a unique value for the DeployIdentifier
|
||||
parameter, which means the SoftwareDeployment resources in the templates
|
||||
will only be triggered if there is an actual change to their configuration.
|
||||
This argument can be used to avoid always applying configuration, such as
|
||||
during node scale out. This option should be used with Caution, and only if
|
||||
there is confidence that the software configuration does not need to be
|
||||
run, such as when scaling out certain roles.
|
|
@ -130,9 +130,11 @@ class OrchestrationDeployAction(base.TripleOAction):
|
|||
class DeployStackAction(templates.ProcessTemplatesAction):
|
||||
"""Deploys a heat stack."""
|
||||
|
||||
def __init__(self, timeout, container=constants.DEFAULT_CONTAINER_NAME):
|
||||
def __init__(self, timeout, container=constants.DEFAULT_CONTAINER_NAME,
|
||||
skip_deploy_identifier=False):
|
||||
super(DeployStackAction, self).__init__(container)
|
||||
self.timeout_mins = timeout
|
||||
self.skip_deploy_identifier = skip_deploy_identifier
|
||||
|
||||
def run(self):
|
||||
# check to see if the stack exists
|
||||
|
@ -149,7 +151,8 @@ class DeployStackAction(templates.ProcessTemplatesAction):
|
|||
wf_env = wc.environments.get(self.container)
|
||||
|
||||
parameters = dict()
|
||||
parameters['DeployIdentifier'] = int(time.time())
|
||||
if not self.skip_deploy_identifier:
|
||||
parameters['DeployIdentifier'] = int(time.time())
|
||||
parameters['UpdateIdentifier'] = ''
|
||||
parameters['StackAction'] = 'CREATE' if stack_is_new else 'UPDATE'
|
||||
|
||||
|
|
|
@ -261,6 +261,72 @@ class DeployStackActionTest(base.TestCase):
|
|||
timeout_mins=1,
|
||||
)
|
||||
|
||||
@mock.patch('tripleo_common.actions.deployment.time')
|
||||
@mock.patch('heatclient.common.template_utils.'
|
||||
'process_multiple_environments_and_files')
|
||||
@mock.patch('heatclient.common.template_utils.get_template_contents')
|
||||
@mock.patch('tripleo_common.actions.base.TripleOAction.'
|
||||
'_get_workflow_client')
|
||||
@mock.patch('tripleo_common.actions.base.TripleOAction._get_object_client')
|
||||
@mock.patch(
|
||||
'tripleo_common.actions.base.TripleOAction._get_orchestration_client')
|
||||
@mock.patch('mistral.context.ctx')
|
||||
def test_run_skip_deploy_identifier(
|
||||
self, mock_ctx, get_orchestration_client_mock,
|
||||
mock_get_object_client, mock_get_workflow_client,
|
||||
mock_get_template_contents,
|
||||
mock_process_multiple_environments_and_files,
|
||||
mock_time):
|
||||
|
||||
mock_ctx.return_value = mock.MagicMock()
|
||||
# setup swift
|
||||
swift = mock.MagicMock(url="http://test.com")
|
||||
swift.get_object.side_effect = swiftexceptions.ClientException(
|
||||
'atest2')
|
||||
mock_get_object_client.return_value = swift
|
||||
|
||||
heat = mock.MagicMock()
|
||||
heat.stacks.get.return_value = None
|
||||
get_orchestration_client_mock.return_value = heat
|
||||
|
||||
mock_mistral = mock.MagicMock()
|
||||
mock_env = mock.MagicMock()
|
||||
mock_env.variables = {
|
||||
'temp_environment': 'temp_environment',
|
||||
'template': 'template',
|
||||
'environments': [{u'path': u'environments/test.yaml'}],
|
||||
'parameter_defaults': {'random_existing_data': 'a_value'},
|
||||
}
|
||||
mock_mistral.environments.get.return_value = mock_env
|
||||
mock_get_workflow_client.return_value = mock_mistral
|
||||
|
||||
mock_get_template_contents.return_value = ({}, {
|
||||
'heat_template_version': '2016-04-30'
|
||||
})
|
||||
mock_process_multiple_environments_and_files.return_value = ({}, {})
|
||||
|
||||
# freeze time at datetime.datetime(2016, 9, 8, 16, 24, 24)
|
||||
mock_time.time.return_value = 1473366264
|
||||
|
||||
action = deployment.DeployStackAction(1, 'overcloud',
|
||||
skip_deploy_identifier=True)
|
||||
action.run()
|
||||
|
||||
# verify parameters are as expected
|
||||
expected_defaults = {'StackAction': 'CREATE',
|
||||
'UpdateIdentifier': '',
|
||||
'random_existing_data': 'a_value'}
|
||||
self.assertEqual(expected_defaults,
|
||||
mock_env.variables['parameter_defaults'])
|
||||
|
||||
heat.stacks.create.assert_called_once_with(
|
||||
environment={},
|
||||
files={},
|
||||
stack_name='overcloud',
|
||||
template={'heat_template_version': '2016-04-30'},
|
||||
timeout_mins=1,
|
||||
)
|
||||
|
||||
|
||||
class OvercloudRcActionTestCase(base.TestCase):
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ workflows:
|
|||
input:
|
||||
- container
|
||||
- timeout: 240
|
||||
- skip_deploy_identifier: False
|
||||
- queue_name: tripleo
|
||||
|
||||
tasks:
|
||||
|
@ -123,6 +124,8 @@ workflows:
|
|||
|
||||
deploy:
|
||||
action: tripleo.deployment.deploy timeout=<% $.timeout %> container=<% $.container %>
|
||||
input:
|
||||
skip_deploy_identifier: <% $.skip_deploy_identifier %>
|
||||
on-success: send_message
|
||||
on-error: set_deployment_failed
|
||||
|
||||
|
|
Loading…
Reference in New Issue