db: Resolve SAWarning warnings
Resolve the following SAWarning warning: SELECT statement has a cartesian product between FROM element(s) "foo" and FROM element "bar". Apply join condition(s) between each element to resolve. This was happening because we were filtering instances of ConductorHardwareInterfaces by the state of the Conductor referenced by the 'conductor_id' field *without* joining the Conductor table. By adding the join, we can avoid this cartesian product. Change-Id: I2c20d7a7c1de41d4d0057fabc1d953b5bfb5b216 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
8ef9db1570
commit
00aadf570b
@ -1379,12 +1379,14 @@ class Connection(api.Connection):
|
||||
|
||||
def list_hardware_type_interfaces(self, hardware_types):
|
||||
with _session_for_read() as session:
|
||||
query = (session.query(models.ConductorHardwareInterfaces)
|
||||
query = (session.query(models.ConductorHardwareInterfaces,
|
||||
models.Conductor)
|
||||
.join(models.Conductor)
|
||||
.filter(models.ConductorHardwareInterfaces.hardware_type
|
||||
.in_(hardware_types)))
|
||||
|
||||
query = _filter_active_conductors(query)
|
||||
return query.all()
|
||||
return [row[0] for row in query]
|
||||
|
||||
@oslo_db_api.retry_on_deadlock
|
||||
def register_conductor_hardware_interfaces(self, conductor_id, interfaces):
|
||||
|
@ -125,16 +125,6 @@ class WarningsFixture(fixtures.Fixture):
|
||||
category=sqla_exc.SAWarning,
|
||||
)
|
||||
|
||||
# ...but filter everything out until we get around to fixing them
|
||||
# TODO(stephenfin): Fix all of these
|
||||
|
||||
warnings.filterwarnings(
|
||||
'ignore',
|
||||
module='ironic',
|
||||
message='SELECT statement has a cartesian product ',
|
||||
category=sqla_exc.SAWarning,
|
||||
)
|
||||
|
||||
# FIXME(stephenfin): We can remove this once oslo.db is fixed
|
||||
# https://review.opendev.org/c/openstack/oslo.db/+/856453
|
||||
warnings.filterwarnings(
|
||||
|
Loading…
x
Reference in New Issue
Block a user