Skip to content

Commit b1f8911

Browse files
author
Gabriel Monroy
committed
create one initial web container on Build.push, only if there exists a runtime layer and web containers are < 1 fixes #42
1 parent 02f6fad commit b1f8911

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

api/models.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def import_tasks(provider_type):
3939
"""
4040
try:
4141
tasks = importlib.import_module('celerytasks.' + provider_type)
42-
except ImportError:
43-
raise
42+
except ImportError as e:
43+
raise e
4444
return tasks
4545

4646

@@ -348,7 +348,7 @@ def _balance_containers(self, **kwargs):
348348
changed = False
349349
# iterate by unique container type
350350
for container_type in set([c.type for c in all_containers]):
351-
# map node container counts => {2: [b3, b4], 3: [ b1, b2 ]}
351+
# map node container counts => { 2: [b3, b4], 3: [ b1, b2 ] }
352352
n_map = {}
353353
for node in runtime_nodes:
354354
ct = len(node.container_set.filter(type=container_type))
@@ -708,6 +708,12 @@ def push(cls, push):
708708
release_signal.send(sender=push, build=new_build,
709709
formation=formation,
710710
user=user)
711+
# see if we need to scale an initial web container
712+
if len(formation.layer_set.filter(id='runtime')) > 0 and \
713+
len(formation.container_set.filter(type='web')) < 1:
714+
# scale an initial web containers
715+
formation.containers['web'] = 1
716+
formation.scale_containers()
711717
# recalculate the formation databag including the new
712718
# build and release
713719
databag = formation.calculate()

0 commit comments

Comments
 (0)