Merge "Keep existing stack tags for patch update"
This commit is contained in:
commit
0518e906ed
@ -940,6 +940,9 @@ class EngineService(service.ServiceBase):
|
||||
common_params.setdefault(rpc_api.PARAM_DISABLE_ROLLBACK,
|
||||
current_stack.disable_rollback)
|
||||
|
||||
if args.get(rpc_api.PARAM_EXISTING):
|
||||
common_params.setdefault(rpc_api.STACK_TAGS,
|
||||
current_stack.tags)
|
||||
current_kwargs.update(common_params)
|
||||
updated_stack = parser.Stack(cnxt, stack_name, tmpl,
|
||||
**current_kwargs)
|
||||
|
@ -321,6 +321,41 @@ resources:
|
||||
tmpl.env.params)
|
||||
self.assertEqual(stk.identifier(), result)
|
||||
|
||||
def test_stack_update_with_tags(self):
|
||||
"""Test case for updating stack with tags.
|
||||
|
||||
Create a stack with tags, then update with/without
|
||||
rpc_api.PARAM_EXISTING.
|
||||
"""
|
||||
stack_name = 'service_update_test_stack_existing_tags'
|
||||
api_args = {rpc_api.PARAM_TIMEOUT: 60,
|
||||
rpc_api.PARAM_EXISTING: True}
|
||||
t = template_format.parse(tools.wp_template)
|
||||
|
||||
stk = utils.parse_stack(t, stack_name=stack_name, tags=['tag1'])
|
||||
stk.set_stack_user_project_id('1234')
|
||||
self.assertEqual(['tag1'], stk.tags)
|
||||
|
||||
self.patchobject(stack.Stack, 'validate')
|
||||
|
||||
# update keep old tags
|
||||
_, _, updated_stack = self.man._prepare_stack_updates(
|
||||
self.ctx, stk, t, {}, None, None, api_args, None)
|
||||
self.assertEqual(['tag1'], updated_stack.tags)
|
||||
|
||||
# with new tags
|
||||
api_args[rpc_api.STACK_TAGS] = ['tag2']
|
||||
_, _, updated_stack = self.man._prepare_stack_updates(
|
||||
self.ctx, stk, t, {}, None, None, api_args, None)
|
||||
self.assertEqual(['tag2'], updated_stack.tags)
|
||||
|
||||
# with no PARAM_EXISTING flag and no tags
|
||||
del api_args[rpc_api.PARAM_EXISTING]
|
||||
del api_args[rpc_api.STACK_TAGS]
|
||||
_, _, updated_stack = self.man._prepare_stack_updates(
|
||||
self.ctx, stk, t, {}, None, None, api_args, None)
|
||||
self.assertIsNone(updated_stack.tags)
|
||||
|
||||
def test_stack_update_existing_registry(self):
|
||||
# Use a template with existing flag and ensure the
|
||||
# environment registry is preserved.
|
||||
|
@ -91,7 +91,8 @@ def dummy_context(user='test_username', tenant_id='test_tenant_id',
|
||||
|
||||
|
||||
def parse_stack(t, params=None, files=None, stack_name=None,
|
||||
stack_id=None, timeout_mins=None, cache_data=None):
|
||||
stack_id=None, timeout_mins=None,
|
||||
cache_data=None, tags=None):
|
||||
params = params or {}
|
||||
files = files or {}
|
||||
ctx = dummy_context()
|
||||
@ -104,7 +105,8 @@ def parse_stack(t, params=None, files=None, stack_name=None,
|
||||
cache_data = {n: node_data.NodeData.from_dict(d)
|
||||
for n, d in cache_data.items()}
|
||||
stk = stack.Stack(ctx, stack_name, templ, stack_id=stack_id,
|
||||
timeout_mins=timeout_mins, cache_data=cache_data)
|
||||
timeout_mins=timeout_mins,
|
||||
cache_data=cache_data, tags=tags)
|
||||
stk.store()
|
||||
return stk
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user