Skip to content

Commit cb82f62

Browse files
author
Matthew Fisher
committed
fix(controller): destroy app containers in parallel
When we call app.destroy(), each container is destroyed in series. Since we now rely on Fleet's state to respond, we are getting a more accurate idea of what state the container is actually in. Because of this, c.destroy() was taking a very long time waiting for a response from fleet. iThis wasn't a problem before because we were waiting for django-fsm, which basically said "yup, I told fleet to destroy the container. It's dead now", which wasn't entirely true. Switching to destroying containers in parallel makes this operation much faster.
1 parent a6515c8 commit cb82f62

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

controller/api/models.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,11 @@ def create(self, *args, **kwargs):
181181

182182
def delete(self, *args, **kwargs):
183183
"""Delete this application including all containers"""
184-
for c in self.container_set.exclude(type='run'):
185-
c.destroy()
184+
try:
185+
# attempt to remove containers from the scheduler
186+
self._destroy_containers([c for c in self.container_set.exclude(type='run')])
187+
except RuntimeError:
188+
pass
186189
self._clean_app_logs()
187190
return super(App, self).delete(*args, **kwargs)
188191

0 commit comments

Comments
 (0)