Skip to content

Commit 68266b9

Browse files
author
smothiki
committed
fix(controller): add scheduler logs to app logs
fix(controller): roll back if scale fails
1 parent 68415ae commit 68266b9

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

controller/api/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ def _start_containers(self, to_add):
292292
if any(c.state != 'created' for c in to_add):
293293
err = 'aborting, failed to create some containers'
294294
log_event(self, err, logging.ERROR)
295+
self._destroy_containers(to_add)
295296
raise RuntimeError(err)
296297
[t.start() for t in start_threads]
297298
[t.join() for t in start_threads]

controller/api/tests/test_scheduler.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ def test_create_chaos(self):
7575
url = "/v1/apps/{app_id}/containers".format(**locals())
7676
response = self.client.get(url, HTTP_AUTHORIZATION='token {}'.format(self.token))
7777
self.assertEqual(response.status_code, 200)
78-
self.assertEqual(len(response.data['results']), 20)
79-
# make sure some failed
80-
states = set([c['state'] for c in response.data['results']])
81-
self.assertEqual(states, set(['error', 'created']))
78+
self.assertEqual(len(response.data['results']), 0)
8279

8380
def test_start_chaos(self):
8481
url = '/v1/apps'
@@ -304,7 +301,6 @@ def test_build_chaos(self):
304301
response = self.client.get(url, HTTP_AUTHORIZATION='token {}'.format(self.token))
305302
self.assertEqual(response.status_code, 200)
306303
self.assertEqual(len(response.data['results']), 20)
307-
308304
# make sure all old containers are still up
309305
states = set([c['state'] for c in response.data['results']])
310306
self.assertEqual(states, set(['up']))

controller/scheduler/swarm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def create(self, name, image, command='', template=None, **kwargs):
3333
mem = mem[:-1]
3434
cpu = kwargs.get('cpu', {}).get(l['c_type'])
3535
self.docker_cli.create_container(image=cimage, name=name,
36-
command=command.encode('utf-8'), mem_limit=mem,
36+
command=command.encode('utf-8'),
37+
mem_limit=mem,
3738
cpu_shares=cpu,
3839
environment=[affinity],
3940
host_config={'PublishAllPorts': True})

0 commit comments

Comments
 (0)