summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Callaghan <dcallagh@redhat.com>2017-10-11 08:58:05 +1000
committerDan Callaghan <dcallagh@redhat.com>2017-10-11 08:58:05 +1000
commit0d72f8c9158682f902c922e5b931c9efcbb2c02c (patch)
treed2e7dbb1d3a6b7d68fd437596877b56275e1a74c
parenta7d5921d31453c394a31062a8b0039bb047ee11a (diff)
sqlalchemy 1.0 compatibility: cannot delete from join
With sqlalchemy 1.0, deleting from a query containing a join is now an error. This fixes a failure in the tests for removing lab controllers: bkr.server ERROR Exception on /labcontrollers/lab249.testdata.invalid [PATCH] Traceback (most recent call last): [...] File "Server/bkr/server/labcontroller.py", line 151, in update_labcontroller remove_labcontroller(labcontroller) File "Server/bkr/server/labcontroller.py", line 92, in remove_labcontroller distro_tree_assocs.delete(synchronize_session=False) File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/query.py", line 3047, in delete self, synchronize_session) File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 1302, in factory }, synchronize_session, query) File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 1122, in _factory return klass(*arg) File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 1294, in __init__ super(BulkDelete, self).__init__(query) File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 1087, in __init__ self._validate_query_state() File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 1105, in _validate_query_state (methname, ) InvalidRequestError: Can't call Query.update() or Query.delete() when join(), outerjoin(), select_from(), or from_self() has been called OpenStack 11 provides sqlalchemy 1.0. Change-Id: Ib09439d121fe41d2ad49103c7f11b816567c0afa
-rw-r--r--Server/bkr/server/labcontroller.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Server/bkr/server/labcontroller.py b/Server/bkr/server/labcontroller.py
index e4b06f9..fc33f58 100644
--- a/Server/bkr/server/labcontroller.py
+++ b/Server/bkr/server/labcontroller.py
@@ -83,11 +83,11 @@ def remove_labcontroller(labcontroller):
# remove distro trees
distro_tree_assocs = LabControllerDistroTree.query\
- .filter(LabControllerDistroTree.lab_controller == labcontroller)\
- .join(LabControllerDistroTree.distro_tree)
+ .filter(LabControllerDistroTree.lab_controller == labcontroller)
DistroTree.record_bulk_activity(
- distro_tree_assocs, user=identity.current.user,
- service=u'HTTP', action=u'Removed', field=u'lab_controller_assocs',
+ distro_tree_assocs.join(LabControllerDistroTree.distro_tree),
+ user=identity.current.user, service=u'HTTP',
+ action=u'Removed', field=u'lab_controller_assocs',
old=labcontroller.fqdn, new=None)
distro_tree_assocs.delete(synchronize_session=False)
labcontroller.disabled = True