Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
fix(api/models/app): Catch unhandled error (#1317)
Browse files Browse the repository at this point in the history
Fix for #1313

An unhandled exception in ns.create due to "Conflict
namespaces" will
wipe out an entire namespace. I've added a catch here to
protect against
that occurring.
  • Loading branch information
lshemesh authored and Matthew Fisher committed Aug 8, 2017
1 parent ccd4387 commit c02eb51
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rootfs/api/models/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ def create(self, *args, **kwargs): # noqa
try:
self._scheduler.ns.get(namespace)
except KubeException:
self._scheduler.ns.create(namespace)
try:
self._scheduler.ns.create(namespace)
except KubeException as e:
raise ServiceUnavailable('Could not create the Namespace in Kubernetes') from e

if settings.KUBERNETES_NAMESPACE_DEFAULT_QUOTA_SPEC != '':
quota_spec = json.loads(settings.KUBERNETES_NAMESPACE_DEFAULT_QUOTA_SPEC)
self.log('creating Quota {} for namespace {}'.format(quota_name, namespace),
Expand Down

0 comments on commit c02eb51

Please sign in to comment.