Filtering with multiple variables returns an empty list

Bug #1669493 reported by git-harry
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
craton
Fix Released
Critical
Thomas Maddox

Bug Description

Filtering with vars=='tempest_public_subnet_cidr:192.168.4.0/22' returns two regions as expected.

# http GET :8080/v1/regions 'X-Auth-Token:demo' 'X-Auth-User:demo' 'X-Auth-Project:b9f10eca66ac4c279c139d01e65f96b4' details==true vars=='tempest_public_subnet_cidr:192.168.4.0/22'
HTTP/1.0 200 OK
Content-Length: 1469
Content-Type: application/json
Date: Thu, 02 Mar 2017 15:54:24 GMT
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-7176ec6b-9902-4c82-ba1e-13ffd42d7ca9

{
    "links": [
        {
            "href": "http://localhost:8080/v1/regions?sort_keys=created_at%2Cid&resolved-values=True&sort_dir=asc&limit=30&vars=tempest_public_subnet_cidr%3A192.168.4.0%2F22&details=True",
            "rel": "first"
        },
        {
            "href": "http://localhost:8080/v1/regions?sort_keys=created_at%2Cid&resolved-values=True&sort_dir=asc&limit=30&vars=tempest_public_subnet_cidr%3A192.168.4.0%2F22&details=True",
            "rel": "prev"
        },
        {
            "href": "http://localhost:8080/v1/regions?sort_keys=created_at%2Cid&resolved-values=True&sort_dir=asc&limit=30&vars=tempest_public_subnet_cidr%3A192.168.4.0%2F22&details=True",
            "rel": "self"
        },
        {
            "href": "http://localhost:8080/v1/regions?sort_keys=created_at%2Cid&resolved-values=True&marker=4&sort_dir=asc&limit=30&vars=tempest_public_subnet_cidr%3A192.168.4.0%2F22&details=True",
            "rel": "next"
        }
    ],
    "regions": [
        {
            "cloud_id": 1,
            "created_at": "2017-03-02T15:37:40.000000",
            "id": 2,
            "name": "DFW",
            "note": null,
            "project_id": "b9f10eca-66ac-4c27-9c13-9d01e65f96b4",
            "updated_at": null,
            "variables": {
                "glance_default_store": "swift",
                "neutron_l2_population": true,
                "nova_console_type": "novnc",
                "tempest_public_subnet_cidr": "192.168.4.0/22"
            }
        },
        {
            "cloud_id": 2,
            "created_at": "2017-03-02T15:37:42.000000",
            "id": 4,
            "name": "DFW",
            "note": null,
            "project_id": "b9f10eca-66ac-4c27-9c13-9d01e65f96b4",
            "updated_at": null,
            "variables": {
                "glance_default_store": "swift",
                "neutron_l2_population": true,
                "nova_console_type": "foo",
                "tempest_public_subnet_cidr": "192.168.4.0/22"
            }
        }
    ]
}

Filtering with vars=='nova_console_type:foo' returns one region as expected.

# http GET :8080/v1/regions 'X-Auth-Token:demo' 'X-Auth-User:demo' 'X-Auth-Project:b9f10eca66ac4c279c139d01e65f96b4' details==true vars=='nova_console_type:foo'
HTTP/1.0 200 OK
Content-Length: 1051
Content-Type: application/json
Date: Thu, 02 Mar 2017 15:56:16 GMT
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-0e5c46c0-2542-4f91-920e-c84d1ddf560c

{
    "links": [
        {
            "href": "http://localhost:8080/v1/regions?sort_keys=created_at%2Cid&resolved-values=True&sort_dir=asc&limit=30&vars=nova_console_type%3Afoo&details=True",
            "rel": "first"
        },
        {
            "href": "http://localhost:8080/v1/regions?sort_keys=created_at%2Cid&resolved-values=True&sort_dir=asc&limit=30&vars=nova_console_type%3Afoo&details=True",
            "rel": "prev"
        },
        {
            "href": "http://localhost:8080/v1/regions?sort_keys=created_at%2Cid&resolved-values=True&sort_dir=asc&limit=30&vars=nova_console_type%3Afoo&details=True",
            "rel": "self"
        },
        {
            "href": "http://localhost:8080/v1/regions?sort_keys=created_at%2Cid&resolved-values=True&marker=4&sort_dir=asc&limit=30&vars=nova_console_type%3Afoo&details=True",
            "rel": "next"
        }
    ],
    "regions": [
        {
            "cloud_id": 2,
            "created_at": "2017-03-02T15:37:42.000000",
            "id": 4,
            "name": "DFW",
            "note": null,
            "project_id": "b9f10eca-66ac-4c27-9c13-9d01e65f96b4",
            "updated_at": null,
            "variables": {
                "glance_default_store": "swift",
                "neutron_l2_population": true,
                "nova_console_type": "foo",
                "tempest_public_subnet_cidr": "192.168.4.0/22"
            }
        }
    ]
}

Filtering with vars=='tempest_public_subnet_cidr:192.168.4.0/22,nova_console_type:foo' returns no regions when one is expected.

# http GET :8080/v1/regions 'X-Auth-Token:demo' 'X-Auth-User:demo' 'X-Auth-Project:b9f10eca66ac4c279c139d01e65f96b4' details==true vars=='tempest_public_subnet_cidr:192.168.4.0/22,nova_console_type:foo'
HTTP/1.0 200 OK
Content-Length: 688
Content-Type: application/json
Date: Thu, 02 Mar 2017 15:56:45 GMT
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-af490d0e-6a17-4eab-b2dc-81ab18f4898d

{
    "links": [
        {
            "href": "http://localhost:8080/v1/regions?sort_keys=created_at%2Cid&resolved-values=True&sort_dir=asc&limit=30&vars=tempest_public_subnet_cidr%3A192.168.4.0%2F22%2Cnova_console_type%3Afoo&details=True",
            "rel": "first"
        },
        {
            "href": "http://localhost:8080/v1/regions?sort_keys=created_at%2Cid&resolved-values=True&sort_dir=asc&limit=30&vars=tempest_public_subnet_cidr%3A192.168.4.0%2F22%2Cnova_console_type%3Afoo&details=True",
            "rel": "prev"
        },
        {
            "href": "http://localhost:8080/v1/regions?sort_keys=created_at%2Cid&resolved-values=True&sort_dir=asc&limit=30&vars=tempest_public_subnet_cidr%3A192.168.4.0%2F22%2Cnova_console_type%3Afoo&details=True",
            "rel": "self"
        }
    ],
    "regions": []
}

Revision history for this message
Jim Baker (jimbaker) wrote :
Changed in craton:
status: New → Confirmed
assignee: nobody → Jim Baker (jimbaker)
milestone: none → v0.1.0
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to craton (master)

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

Changed in craton:
importance: Undecided → Critical
Changed in craton:
assignee: Jim Baker (jimbaker) → Thomas Maddox (thomas-maddox)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to craton (master)

Reviewed: https://review.openstack.org/440929
Committed: https://git.openstack.org/cgit/openstack/craton/commit/?id=3d0506b69c255571ee6b580f85a0bf6646d7ed21
Submitter: Jenkins
Branch: master

commit 3d0506b69c255571ee6b580f85a0bf6646d7ed21
Author: Jim Baker <email address hidden>
Date: Thu Mar 2 21:56:28 2017 -0700

    Variable search for resources now uses resolved variables.

    Implements a filter addition for vars such that each key-value pair in
    the vars is searched for a possible match, regardless of associated
    resource; then chases the associated resources for the specific
    resource being searched for, thereby implementing the resolution
    algorithm (but in reverse). Finally all such resources are checked to
    see if they intersect with respect to their rooting key-value pairs in
    the original search.

    Examples:

    $ GET v1/hosts?vars=openstack_release:juno

    $ GET v1/hosts?vars=foo:abc,bar:xyz

    To disable this feature in your request, you can supply
    'resolved-values=false', for example:

    $ GET /v1/hosts?vars=foo:bar,baz:zoo&resolved-value=false

    Filter values are not currently encoded for JSON; but this will fixed
    in a subsequent patch that is addressing generalized JSON matching via
    JSON path.

    Change-Id: I1d40d734e60b5563dfb01da05ffb6494ed9a919c
    Closes-bug: 1661226
    Closes-bug: 1669493

Changed in craton:
status: In Progress → Fix Released
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.