Delete package only when the package is updated
Change-Id: I026487258488410d60fd1cba79e694a3c3713979 Story: 2002153 Task: 20000
This commit is contained in:
parent
97481bf291
commit
e5ee23d250
|
@ -391,6 +391,7 @@ class FunctionsController(rest.RestController):
|
|||
|
||||
# Package type function. 'code' and 'entry' make sense only if
|
||||
# 'package' is provided
|
||||
update_package = False
|
||||
if (pre_source == constants.PACKAGE_FUNCTION and
|
||||
values.get('package') is not None):
|
||||
if md5sum and md5sum == pre_md5sum:
|
||||
|
@ -410,6 +411,7 @@ class FunctionsController(rest.RestController):
|
|||
{"md5sum": md5sum, "source": pre_source}
|
||||
)
|
||||
values.pop('package')
|
||||
update_package = True
|
||||
|
||||
# Swift type function
|
||||
if pre_source == constants.SWIFT_FUNCTION:
|
||||
|
@ -423,8 +425,8 @@ class FunctionsController(rest.RestController):
|
|||
|
||||
func_db = db_api.update_function(id, values)
|
||||
|
||||
# Delete function package if needed
|
||||
if pre_md5sum:
|
||||
# Delete the old function package if needed
|
||||
if update_package:
|
||||
self.storage_provider.delete(ctx.projectid, id, pre_md5sum)
|
||||
|
||||
pecan.response.status = 200
|
||||
|
|
|
@ -209,11 +209,11 @@ class TestFunctionController(base.APITest):
|
|||
resp.json['faultstring']
|
||||
)
|
||||
|
||||
@mock.patch('qinling.storage.file_system.FileSystemStorage.delete')
|
||||
@mock.patch('qinling.utils.etcd_util.delete_function')
|
||||
@mock.patch('qinling.rpc.EngineClient.delete_function')
|
||||
def test_put_cpu_and_memorysize(
|
||||
self, mock_delete_func, mock_etcd_del
|
||||
):
|
||||
def test_put_cpu_and_memorysize(self, mock_delete_func, mock_etcd_del,
|
||||
mock_storage_delete):
|
||||
# Test for updating cpu/mem with good input values.
|
||||
db_func = self.create_function(runtime_id=self.runtime_id)
|
||||
|
||||
|
@ -235,6 +235,7 @@ class TestFunctionController(base.APITest):
|
|||
)
|
||||
mock_delete_func.assert_called_once_with(db_func.id)
|
||||
mock_etcd_del.assert_called_once_with(db_func.id)
|
||||
self.assertFalse(mock_storage_delete.called)
|
||||
|
||||
@mock.patch('qinling.utils.etcd_util.delete_function')
|
||||
@mock.patch('qinling.rpc.EngineClient.delete_function')
|
||||
|
|
Loading…
Reference in New Issue