deb-murano/meta/io.murano/Classes/Environment.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

144 lines
3.8 KiB
YAML

# 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.
Namespaces:
=: io.murano
res: io.murano.resources
sys: io.murano.system
Name: Environment
Properties:
name:
Contract: $.string().notNull()
applications:
Contract: [$.class(Application).owned().notNull()]
agentListener:
Contract: $.class(sys:AgentListener)
Usage: Runtime
stack:
Contract: $.class(sys:HeatStack)
Usage: Runtime
instanceNotifier:
Contract: $.class(sys:InstanceNotifier)
Usage: Runtime
defaultNetworks:
Contract:
environment: $.template(res:Network)
flat: $.template(res:Network)
securityGroupManager:
Contract: $.class(sys:SecurityGroupManager)
Usage: Runtime
reporter:
Contract: $.class(sys:StatusReporter)
Usage: Runtime
regionConfigs:
Contract:
$.string():
agentRabbitMq:
host: $.string().notNull()
port: $.int() or 5672
login: $.string().notNull()
password: $.string().notNull()
virtual_host: $.string() or '/'
ssl: $.bool() or false
insecure: $.bool() or false
Usage: Config
region:
Contract: $.string()
Usage: InOut
homeRegionName:
Contract: $.string()
Usage: Runtime
regions:
Contract:
$.string(): $.class(CloudRegion)
Usage: InOut
Methods:
.init:
Body:
- $.homeRegionName: config(home_region) or ''
- $._assignRegions()
- $.instanceNotifier: new(sys:InstanceNotifier, environment => $this)
- $.reporter: new(sys:StatusReporter, environment => $this)
- $.regions: $.regions + $.regionConfigs.keys().
where($ and not $this.regions.containsKey($)).
select($this._createRegion($)).
toDict($.name)
- If: not $.regions.containsKey('')
Then:
- If: $.homeRegionName
Then:
$.regions['']: $.regions[$.homeRegionName]
Else:
$.regions['']: $._createRegion('')
- $defaultRegion: $.regions['']
- $.stack: $defaultRegion.stack
- $.securityGroupManager: $defaultRegion.securityGroupManager
_createRegion:
Arguments:
regionName:
Contract: $.string()
Body:
- $envNet: $.defaultNetworks.environment?.set(regionName => $regionName)
- $flatNet: $.defaultNetworks.flat?.set(regionName => $regionName)
- Return: new(CloudRegion, $this,
name => $regionName,
defaultNetworks => {
environment => $envNet,
flat => $flatNet
}
)
deploy:
Usage: Action
Body:
- $.applications.pselect($.deploy())
_assignRegions:
Body:
- If: $.region = null
Then:
$.region: $.homeRegionName
- $defaultRegionConfig:
agentRabbitMq:
host: config(rabbitmq, host)
port: config(rabbitmq, port)
login: config(rabbitmq, login)
password: config(rabbitmq, password)
virtual_host: config(rabbitmq, virtual_host)
ssl: config(rabbitmq, ssl)
- If: not $.regionConfigs.containsKey('')
Then:
- $.regionConfigs: $.regionConfigs.set('' => $defaultRegionConfig)
- If: $.homeRegionName and not $.regionConfigs.containsKey($.homeRegionName)
Then:
- $.regionConfigs: $.regionConfigs.set($.homeRegionName => $defaultRegionConfig)