[yocto] [layerindex-web][PATCH 1/6] update_layer: fix handling of database errors

Paul Eggleton paul.eggleton at linux.intel.com
Mon Jan 8 20:20:24 PST 2018


If a database error occurs when we save a recipe (e.g. because a
database-level constraint is voilated) it will mess up the transaction.
Unfortunately that means we need to break out of updating the entire
layer rather than catching the error, because if we do catch it we just
get errors on every update after the initial error; failing early and
giving up on the transaction is a little better in terms of not filling
up the update logs with further useless errors.

Signed-off-by: Paul Eggleton <paul.eggleton at linux.intel.com>
---
 layerindex/update_layer.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/layerindex/update_layer.py b/layerindex/update_layer.py
index 307c43a..42e4da9 100644
--- a/layerindex/update_layer.py
+++ b/layerindex/update_layer.py
@@ -56,6 +56,8 @@ def split_recipe_fn(path):
     return (pn, pv)
 
 def update_recipe_file(tinfoil, data, path, recipe, layerdir_start, repodir):
+    from django.db import DatabaseError
+
     fn = str(os.path.join(path, recipe.filename))
     from layerindex.models import PackageConfig, StaticBuildDep, DynamicBuildDep
     try:
@@ -156,6 +158,8 @@ def update_recipe_file(tinfoil, data, path, recipe, layerdir_start, repodir):
 
     except KeyboardInterrupt:
         raise
+    except DatabaseError:
+        raise
     except BaseException as e:
         if not recipe.pn:
             recipe.pn = recipe.filename[:-3].split('_')[0]
-- 
2.9.5




More information about the yocto mailing list