Non admin user can't search shared networks when db don't support BOOLEAN.

Bug #1161195 reported by Guang Chun Wu
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
High
Hua Zhang
Grizzly
Fix Released
High
Gary Kotton

Bug Description

Below quantum command cannot return shared networks correctly when the backend database doesn't support BOOLEAN type.
quantum --os-username user1 --os-password pass --os-tenant user1-tenant net-list

It will fail with a SQL statement token error at runtime.

Take IBM DB2 for example, SQLAlchemy maps the column 'shared' in quantum.networks as SMALLINT.
Generated SQL error:
[CLI Driver][DB2/LINUXX8664] SQL0104N An unexpected token "END-OF-STATEMENT" was found following "? OR networks.shared". Expected tokens may include: "<interval_qualifier>". SQLSTATE=42601 SQLCODE=-104 'SELECT networks.tenant_id AS networks_tenant_id, networks.id AS networks_id, networks.name AS networks_name, networks.status AS networks_status, networks.admin_state_up AS networks_admin_state_up, networks.shared AS networks_shared \nFROM networks LEFT OUTER JOIN externalnetworks ON networks.id = externalnetworks.network_id \nWHERE externalnetworks.network_id IS NOT NULL OR networks.tenant_id = ? OR networks.shared'

"OR networks.shared" is not supported by databases which don't support BOOLEAN type.
It can be made more compatible by changing to "OR networks.shared = ?" .

Feilong Wang (flwang)
Changed in quantum:
assignee: nobody → Fei Long Wang (flwang)
Changed in quantum:
status: New → Confirmed
importance: Undecided → High
milestone: none → 2012.2.4
Changed in quantum:
milestone: 2012.2.4 → havana-1
tags: added: db folsom-backport-potential grizzly-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to quantum (master)

Fix proposed to branch: master
Review: https://review.openstack.org/25808

Changed in quantum:
assignee: Fei Long Wang (flwang) → Hua Zhang (zhhuabj)
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to quantum (master)

Reviewed: https://review.openstack.org/25808
Committed: http://github.com/openstack/quantum/commit/de5c1e4f281f59d550b476919b27ac4e2aae14ac
Submitter: Jenkins
Branch: master

commit de5c1e4f281f59d550b476919b27ac4e2aae14ac
Author: zhhuabj <email address hidden>
Date: Mon Apr 1 13:30:00 2013 +0800

    Make "shared" filter more compatible with diff DBs

    For the type BOOLEAN, in sqlalchemy,
    it's mapped to BOOLEAN type if the backend database supports it,
    otherwise, it's mapped to one of the Integer types, like SMALLINT,
    and restrict the values to 1(True) and 0(False).

    query_filter = (... | model.shared))
    The above filter will generate a SQL where clause like:
    where ... OR xxx.shared

    This is not supported in databases which don't support BOOLEAN type.
    Change it as below to make it more compatible:
    query_filter = (... | model.shared == True))

    It will generate a SQL where clause as below:
    where ... OR xxx.shared = ?

    In Python, True == 1, so this change is compatible
    with both databases supporting BOOLEAN and those not supporting it.

    Fix bug 1161195

    Change-Id: Ic0ce0816d63b576a3469de0ed92cae4b19a3690e

Changed in quantum:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to quantum (stable/grizzly)

Fix proposed to branch: stable/grizzly
Review: https://review.openstack.org/27277

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to quantum (stable/grizzly)

Reviewed: https://review.openstack.org/27277
Committed: http://github.com/openstack/quantum/commit/d1344124ff2cbf71f94cb4ee03cdc8bed8a10b14
Submitter: Jenkins
Branch: stable/grizzly

commit d1344124ff2cbf71f94cb4ee03cdc8bed8a10b14
Author: zhhuabj <email address hidden>
Date: Mon Apr 1 13:30:00 2013 +0800

    Make "shared" filter more compatible with diff DBs

    For the type BOOLEAN, in sqlalchemy,
    it's mapped to BOOLEAN type if the backend database supports it,
    otherwise, it's mapped to one of the Integer types, like SMALLINT,
    and restrict the values to 1(True) and 0(False).

    query_filter = (... | model.shared))
    The above filter will generate a SQL where clause like:
    where ... OR xxx.shared

    This is not supported in databases which don't support BOOLEAN type.
    Change it as below to make it more compatible:
    query_filter = (... | model.shared == True))

    It will generate a SQL where clause as below:
    where ... OR xxx.shared = ?

    In Python, True == 1, so this change is compatible
    with both databases supporting BOOLEAN and those not supporting it.

    Fix bug 1161195

    Change-Id: Ic0ce0816d63b576a3469de0ed92cae4b19a3690e

tags: added: in-stable-grizzly
Gary Kotton (garyk)
tags: removed: grizzly-backport-potential
Thierry Carrez (ttx)
Changed in quantum:
status: Fix Committed → Fix Released
Alan Pevec (apevec)
tags: removed: in-stable-grizzly
Thierry Carrez (ttx)
Changed in neutron:
milestone: havana-1 → 2013.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.