summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Server/bkr/server/labcontroller.py9
-rw-r--r--Server/bkr/server/model.py14
-rw-r--r--beaker.spec6
-rw-r--r--rel-eng/packages/beaker2
4 files changed, 16 insertions, 15 deletions
diff --git a/Server/bkr/server/labcontroller.py b/Server/bkr/server/labcontroller.py
index 47e4df9..028a3b1 100644
--- a/Server/bkr/server/labcontroller.py
+++ b/Server/bkr/server/labcontroller.py
@@ -144,9 +144,12 @@ class LabControllers(RPCRoot):
def _addDistro(self, lab_controller, new_distro):
arches = []
- # Look up the distro by the install name
- distro = Distro.lazy_create(install_name=new_distro['name'])
- distro.name = new_distro['treename']
+ # Try and look up the distro by the install name
+ try:
+ distro = Distro.by_install_name(new_distro['name'])
+ except InvalidRequestError:
+ distro = Distro(new_distro['name'])
+ distro.name = new_distro['treename']
# All the arches this distro's osmajor applies to
if 'arches' in new_distro:
diff --git a/Server/bkr/server/model.py b/Server/bkr/server/model.py
index ad7b5e3..3c9d0a8 100644
--- a/Server/bkr/server/model.py
+++ b/Server/bkr/server/model.py
@@ -15,7 +15,7 @@ from sqlalchemy.orm import relation, backref, synonym, dynamic_loader, \
from sqlalchemy.orm.interfaces import AttributeExtension
from sqlalchemy.sql import exists
from sqlalchemy.sql.expression import join
-from sqlalchemy.exceptions import InvalidRequestError, IntegrityError
+from sqlalchemy.exceptions import InvalidRequestError
from sqlalchemy.orm.exc import NoResultFound
from identity import LdapSqlAlchemyIdentityProvider
from cobbler_utils import consolidate, string_to_hash
@@ -1133,15 +1133,9 @@ class MappedObject(object):
try:
item = cls.query.filter_by(**kwargs).one()
except NoResultFound:
- try:
- item = cls(**kwargs)
- session.add(item)
- session.flush([item])
- # small race condition where its been created in between
- # us querying it.
- except IntegrityError:
- # if we fail again then let the traceback propagate
- item = cls.query.filter_by(**kwargs).one()
+ item = cls(**kwargs)
+ session.add(item)
+ session.flush([item])
return item
def __init__(self, **kwargs):
diff --git a/beaker.spec b/beaker.spec
index 373a5ca..5f45c66 100644
--- a/beaker.spec
+++ b/beaker.spec
@@ -16,7 +16,7 @@
Name: beaker
Version: 0.8.0
-Release: 10%{?dist}
+Release: 11%{?dist}
Summary: Filesystem layout for Beaker
Group: Applications/Internet
License: GPLv2+
@@ -341,6 +341,10 @@ fi
%endif
%changelog
+* Tue Nov 15 2011 Dan Callaghan <dcallagh@redhat.com> 0.8.0-11
+- Revert fix for bug 752869: "race condition when adding distros"
+ (dcallagh@redhat.com)
+
* Fri Nov 11 2011 Dan Callaghan <dcallagh@redhat.com> 0.8.0-10
- 752869 race condition when adding distros (bpeck@redhat.com)
- clean up lab controller logging (dcallagh@redhat.com)
diff --git a/rel-eng/packages/beaker b/rel-eng/packages/beaker
index 78a521f..cde5886 100644
--- a/rel-eng/packages/beaker
+++ b/rel-eng/packages/beaker
@@ -1 +1 @@
-0.8.0-10 /
+0.8.0-11 /