When importing a distro, if the distro row already exists but refers to a different osversion than the one being sent in the import data, then the import will fail: 2012-05-29 14:11:13,684 bkr.server.xmlrpccontroller DEBUG Time: 0:00:00.037483 labcontrollers.add_distro_tree ({'osma jor': 'RedHatEnterpriseLinux3', 'name': 'RH 2012-05-29 14:11:14,041 bkr.server.xmlrpccontroller ERROR Error handling XML-RPC method Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/bkr/server/xmlrpccontroller.py", line 54, in RPC2 response = self.process_rpc(method,params) File "/usr/lib/python2.6/site-packages/bkr/server/xmlrpccontroller.py", line 43, in process_rpc response = obj(*params) File "<string>", line 3, in add_distro_tree File "/usr/lib/python2.6/site-packages/turbogears/identity/conditions.py", line 249, in require return fn(self, *args, **kwargs) File "/usr/lib/python2.6/site-packages/bkr/server/labcontroller.py", line 128, in add_distro_tree distro = Distro.lazy_create(name=new_distro['name'], osversion=osversion) File "/usr/lib/python2.6/site-packages/bkr/server/model.py", line 1259, in lazy_create item = cls.query.filter_by(**kwargs).one() File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/query.py", line 1684, in one raise orm_exc.NoResultFound("No row was found for one()") NoResultFound: No row was found for one() Ideally this should never happen, but it might if the distro was previously imported with wrong .treeinfo or using an old import script that got things wrong.
The problem stems from this line: distro = Distro.lazy_create(name=new_distro['name'], osversion=osversion) Distro is unique only on name, but osversion_id is not NULLable so we have to pass that in here as well in case the row is created. This bug happens if the osversion we are passing in is not the same as the osversion on the existing row, so when lazy_create tries to query it back, nothing matches. The lazy_create method needs some way to distinguish unique columns from creation columns. That might be difficult to do in the general case, but I think distro is the only table in this boat so maybe we can just override Distro.lazy_create to handle it. Or we could make distro.osversion_id NULLable and update it after calling lazy_create. But that seems a bit dodgy.
On Gerrit: http://gerrit.beaker-project.org/1090
Beaker 0.9.0 has been released.