summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-08-18 17:28:54 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-19 18:04:00 +0100
commite0911e408db4fa07086738fe11121b173b4d1cf5 (patch)
tree13dcf3b52f566cc2523b697515e4daa07487c59b
parent5fe0c42ca9d34fa34b65b9fe0ff474200b78efe6 (diff)
toaster: do not stop data import on bad data
The layer data update in Layer source needlessly stops processing by throwing an Exception when bad layer data cannot be inserted in the database (e.g. invalid dependencies). This patch changes the behaviour to ignore bad data, and continue with data import after detailed logging through the logging system. [YOCTO #7955] Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/toaster/orm/models.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/toaster/orm/models.py b/lib/toaster/orm/models.py
index c3fb766c..de007027 100644
--- a/lib/toaster/orm/models.py
+++ b/lib/toaster/orm/models.py
@@ -19,7 +19,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-from django.db import models
+from django.db import models, IntegrityError
from django.db.models import F, Q, Avg, Max
from django.utils import timezone
@@ -938,7 +938,7 @@ class LayerIndexLayerSource(LayerSource):
try:
dependlist[lv].append(Layer_Version.objects.get(layer_source = self, layer__up_id = ldi['dependency'], up_branch = lv.up_branch))
except Layer_Version.DoesNotExist:
- logger.warning("Cannot find layer version %s dep:%s up_brach:%s" % (self, ldi['dependency'], lv.up_branch))
+ logger.warning("Cannot find layer version (ls:%s), up_id:%s lv:%s" % (self, ldi['dependency'], lv))
for lv in dependlist:
LayerVersionDependency.objects.filter(layer_version = lv).delete()
@@ -989,8 +989,8 @@ class LayerIndexLayerSource(LayerSource):
if 'inherits' in ri:
ro.is_image = 'image' in ri['inherits'].split()
ro.save()
- except Exception:
- logger.warning("Duplicate Recipe, ignoring: %s " % vars(ro))
+ except IntegrityError as e:
+ logger.debug("Failed saving recipe, ignoring: %s (%s:%s)" % (e, ro.layer_version, ri['filepath']+"/"+ri['filename']))
if not connection.features.autocommits_when_autocommit_is_off:
transaction.set_autocommit(True)