Removes replace-on-update for SwiftSignalHandle resource

Rebuilding the resource on every stack update results in a new
url being generated. This causes any depending resources to
be rebuilt, even when there are no changes in the template.

Change-Id: Id385e0e8f9f68900b76a596a05ac99baceb831cc
Closes-Bug: #1473692
This commit is contained in:
Pratik Mallya 2015-07-15 10:53:48 -05:00
parent 5f5ae02a3c
commit 399040ece2
3 changed files with 57 additions and 15 deletions

View File

@ -98,9 +98,6 @@ class SwiftSignalHandle(resource.Resource):
self.data_set(self.ENDPOINT, url)
self.resource_id_set(self.physical_resource_name())
def update(self, after, before=None, prev_resource=None):
raise resource.UpdateReplace(self.name)
def _resolve_attribute(self, key):
if self.resource_id:
if key == self.TOKEN:

View File

@ -11,7 +11,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
import datetime
import json
import uuid
@ -267,23 +266,21 @@ class SwiftSignalHandleTest(common.HeatTestCase):
@mock.patch.object(swift.SwiftClientPlugin, '_create')
def test_handle_update(self, mock_swift):
st = create_stack(swiftsignalhandle_template)
handle = st['test_wait_condition_handle']
mock_swift_object = mock.Mock()
mock_swift.return_value = mock_swift_object
mock_swift_object.head_account.return_value = {}
mock_swift_object.head_account.return_value = {
'x-account-meta-temp-url-key': "1234"
}
mock_swift_object.url = "http://fake-host.com:8080/v1/AUTH_1234"
st.create()
handle = st['test_wait_condition_handle']
uprops = copy.copy(handle.properties.data)
uprops['count'] = '5'
rsrc = st.resources['test_wait_condition_handle']
old_url = rsrc.FnGetRefId()
update_snippet = rsrc_defn.ResourceDefinition(handle.name,
handle.type(),
uprops)
updater = scheduler.TaskRunner(handle.update, update_snippet)
self.assertRaises(resource.UpdateReplace, updater)
handle.properties.data)
scheduler.TaskRunner(handle.update, update_snippet)()
self.assertEqual(old_url, rsrc.FnGetRefId())
class SwiftSignalTest(common.HeatTestCase):

View File

@ -0,0 +1,48 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from heat_integrationtests.common import test
test_template = '''
heat_template_version: 2014-10-16
resources:
signal_handle:
type: "OS::Heat::SwiftSignalHandle"
outputs:
signal_curl:
value: { get_attr: ['signal_handle', 'curl_cli'] }
description: Swift signal cURL
signal_url:
value: { get_attr: ['signal_handle', 'endpoint'] }
description: Swift signal URL
'''
class SwiftSignalHandleUpdateTest(test.HeatIntegrationTest):
def setUp(self):
super(SwiftSignalHandleUpdateTest, self).setUp()
self.client = self.orchestration_client
def test_stack_update_same_template_replace_no_url(self):
stack_identifier = self.stack_create(template=test_template)
stack = self.client.stacks.get(stack_identifier)
orig_url = self._stack_output(stack, 'signal_url')
orig_curl = self._stack_output(stack, 'signal_curl')
self.update_stack(stack_identifier, test_template)
stack = self.client.stacks.get(stack_identifier)
self.assertEqual(orig_url, self._stack_output(stack, 'signal_url'))
self.assertEqual(orig_curl, self._stack_output(stack, 'signal_curl'))