deb-murano/meta/io.murano/Classes/CloudResource.yaml
Stan Lagun 0e55368e2a Forces applications to be deleted before Heat stack
After multi-region support was merged there are CloudRegion
objects that hold Heat stacks and applications that are not
owned by the regions. When Environment get deleted there is
no guarantee that applications will be deleted before regions.
If regions were deleted first Heat stacks will be deleted and
any attempt for an application to send any script to its
instance will cause it to hang waiting for the terminated
instance to answer

This commit adds destruction dependency between
application and region first time application
accesses it. Thus region is going to be deleted
after application if both are deleted at the same time
(e.g. upon Environment delete).

Also prevent default region re-creation and loosing
its destruction dependencies. In earlier versions
default region had a null name rather than an empty
string. Then it was changed everywhere except for
this one place.

Change-Id: I88b37345b3a77146241cebe1b9e0a32b44e4be11
Closes-Bug: #1623612
2016-09-14 11:26:32 -07:00

34 lines
818 B
YAML

Namespaces:
=: io.murano
sys: io.murano.system
Name: CloudResource
Properties:
regionName:
Contract: $.string()
Methods:
.init:
Body:
$._region: null
getRegion:
Meta:
'io.murano.metadata.engine.Synchronize':
onThis: false
Body:
- If: $._region = null
Then:
- $env: $.find(Environment).require()
- $regionName: generate($this, $ != null, $.find(CloudResource)).
select($.regionName).where($ != null).first($env.region)
- $._region: $.find(CloudRegion)
- If: $._region = null or $._region.name != $regionName
Then:
$._region: $env.regions[$regionName]
- If: $._region != null
Then:
- sys:GC.subscribeDestruction($this, $._region)
- Return: $._region