Merge "Release resources allocated to the Instance when it gets deleted"
This commit is contained in:
@@ -103,6 +103,8 @@ Methods:
|
||||
value: {get_attr: [$deployment_name, deploy_stderr]}
|
||||
|
||||
- $.softwareConfigs: $.softwareConfigs + list($fragment)
|
||||
- $.setAttr(scResources, $.getAttr(scResources, []).concat([$full_config_name, $deployment_name]))
|
||||
- $.setAttr(scOutputs, $.getAttr(scOutputs, []).concat([$deployment_stdout, $deployment_stderr]))
|
||||
|
||||
# Adds to the stack any heat SW config elements
|
||||
prepareStackTemplate:
|
||||
@@ -122,3 +124,14 @@ Methods:
|
||||
- Return:
|
||||
data:
|
||||
format: SOFTWARE_CONFIG
|
||||
|
||||
releaseResources:
|
||||
Body:
|
||||
- $environment: $.find(std:Environment)
|
||||
- $template: $environment.stack.current()
|
||||
- $template.resources: $template.resources.deleteAll($.getAttr(scResources, []))
|
||||
- $template.outputs: $template.outputs.deleteAll($.getAttr(scOutputs, []))
|
||||
- $environment.stack.setTemplate($template)
|
||||
- $.super($.releaseResources())
|
||||
- $.setAttr(scResources, [])
|
||||
- $.setAttr(scOutputs, [])
|
||||
|
@@ -192,6 +192,9 @@ Methods:
|
||||
assignFloatingIp => $assignFip,
|
||||
sharedIps => $sharedIps
|
||||
)
|
||||
- $.setAttr(instanceResources, $.getAttr(instanceResources, []).concat($joinResult.get(instanceResources, [])))
|
||||
- $.setAttr(instanceOutputs, $.getAttr(instanceOutputs, []).concat($joinResult.get(instanceOutputs, [])))
|
||||
|
||||
- If: $joinResult.template != null
|
||||
Then:
|
||||
- $.instanceTemplate: $.instanceTemplate.mergeWith($joinResult.template)
|
||||
@@ -218,17 +221,27 @@ Methods:
|
||||
|
||||
- $._floatingIpOutputName: coalesce($._floatingIpOutputName, $joinResult.instanceFipOutput)
|
||||
|
||||
destroy:
|
||||
# FIXME(smelikyan): All allocated resources should be cleaned-up on destroy
|
||||
# Now no clean-up happens here cause we don't track all native resources
|
||||
# that are allocated at the moment in descendants of Instance or other
|
||||
# classes that may allocate resource dependent on OS::Nova:Server used
|
||||
# as underlying implementation for Instance. This can cause
|
||||
# resource leak when environment is updated. Resources are cleaned-up only
|
||||
# when whole Environment is deleted (alongside with Heat stack deletion).
|
||||
# https://bugs.launchpad.net/murano/+bug/1359998
|
||||
releaseResources:
|
||||
Body:
|
||||
- $.environment.instanceNotifier.untrackCloudInstance($this)
|
||||
- $template: $.environment.stack.current()
|
||||
- $resourcesToDelete: list($.name).concat($.getAttr(instanceResources, []))
|
||||
- $template.resources: $template.resources.deleteAll($resourcesToDelete)
|
||||
|
||||
- $outputsToDelete: list(
|
||||
'{0}-assigned-ips'.format($.name),
|
||||
'{0}-id'.format($.name)).concat($.getAttr(instanceOutputs, []))
|
||||
- $template.outputs: $template.outputs.deleteAll($outputsToDelete)
|
||||
|
||||
- $.environment.stack.setTemplate($template)
|
||||
- $.environment.stack.push()
|
||||
- $.setAttr(instanceResources, [])
|
||||
- $.setAttr(instanceOutputs, [])
|
||||
|
||||
destroy:
|
||||
Body:
|
||||
- $.releaseResources()
|
||||
|
||||
|
||||
createDefaultInstanceSecurityGroupRules:
|
||||
Arguments:
|
||||
|
@@ -47,6 +47,9 @@ Methods:
|
||||
- get_resource: $securityGroupName
|
||||
- $patchTemplate: $patchTemplate.mergeWith($template)
|
||||
|
||||
- $instanceResources: [$portName]
|
||||
- $instanceOutputs: []
|
||||
|
||||
- For: sip
|
||||
In: $sharedIps
|
||||
Do:
|
||||
@@ -75,12 +78,16 @@ Methods:
|
||||
value:
|
||||
get_attr: [$floatingIpResourceName, floating_ip_address]
|
||||
description: format('Floating IP of {0}', $instance.name)
|
||||
- $instanceResources: $instanceResources.append($floatingIpResourceName)
|
||||
- $instanceOutputs: $instanceOutputs.append($instanceFipOutput)
|
||||
- $patchTemplate: $patchTemplate.mergeWith($template)
|
||||
- Return:
|
||||
template: $patchTemplate
|
||||
portRef:
|
||||
get_resource: $portName
|
||||
instanceFipOutput: $instanceFipOutput
|
||||
instanceResources: $instanceResources
|
||||
instanceOutputs: $instanceOutputs
|
||||
|
||||
|
||||
generateSecurityGroupManager:
|
||||
|
@@ -23,6 +23,8 @@ Methods:
|
||||
- $fipName: null
|
||||
- $template: null
|
||||
- $instanceFipOutput: null
|
||||
- $instanceResources: []
|
||||
- $instanceOutputs: []
|
||||
- If: $assignFloatingIp
|
||||
Then:
|
||||
- $instanceFipOutput: $instance.name + '-floatingIPaddress'
|
||||
@@ -43,11 +45,15 @@ Methods:
|
||||
value:
|
||||
get_attr: [$fipName, ip]
|
||||
description: format('Floating IP of {0}', $instance.name)
|
||||
- $instanceResources: [$fipName, $fipName + 'Assignment']
|
||||
- $instanceOutputs: [$instanceFipOutput]
|
||||
- Return:
|
||||
template: $template
|
||||
secGroupName:
|
||||
get_resource: $securityGroupName
|
||||
instanceFipOutput: $instanceFipOutput
|
||||
instanceResources: $instanceResources
|
||||
instanceOutputs: $instanceOutputs
|
||||
|
||||
|
||||
generateSecurityGroupManager:
|
||||
|
@@ -200,8 +200,8 @@ class MuranoDslExecutor(object):
|
||||
gc_object_store.load(objects_copy, None)
|
||||
objects_to_clean = []
|
||||
for object_id in self._list_potential_object_ids(objects_copy):
|
||||
if (gc_object_store.has(object_id)
|
||||
and not self._object_store.has(object_id)):
|
||||
if (gc_object_store.has(object_id) and
|
||||
not self._object_store.has(object_id)):
|
||||
obj = gc_object_store.get(object_id)
|
||||
objects_to_clean.append(obj)
|
||||
if objects_to_clean:
|
||||
@@ -217,14 +217,13 @@ class MuranoDslExecutor(object):
|
||||
|
||||
def _list_potential_object_ids(self, data):
|
||||
if isinstance(data, types.DictionaryType):
|
||||
for val in data.values():
|
||||
sys_dict = data.get('?')
|
||||
if (isinstance(sys_dict, types.DictionaryType) and
|
||||
sys_dict.get('id') and sys_dict.get('type')):
|
||||
yield sys_dict['id']
|
||||
for val in data.itervalues():
|
||||
for res in self._list_potential_object_ids(val):
|
||||
yield res
|
||||
sys_dict = data.get('?')
|
||||
if (isinstance(sys_dict, types.DictionaryType)
|
||||
and sys_dict.get('id')
|
||||
and sys_dict.get('type')):
|
||||
yield sys_dict['id']
|
||||
elif isinstance(data, collections.Iterable) and not isinstance(
|
||||
data, types.StringTypes):
|
||||
for val in data:
|
||||
|
Reference in New Issue
Block a user