Parsing of service catalog should be less error prone

Bug #1424825 reported by Lin Hua Cheng
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
High
Lin Hua Cheng
django-openstack-auth
Fix Released
High
Lin Hua Cheng

Bug Description

Currently, parsing of the service catalog is hard-coded and dependent on the data structure of the service catalog.

For example:

in user.py

    @property
    def available_services_regions(self):
        """Returns list of unique region name values in service catalog."""
        regions = []
        if self.service_catalog:
            for service in self.service_catalog:
                if service['type'] == 'identity':
                    continue
                for endpoint in service['endpoints']:
                    if endpoint['region'] not in regions:
                        regions.append(endpoint['region'])
        return regions

This code is prone to issue if the structure of the service catalog changes, it should be using the public interfaces of Service Catalog object from KSC when parsing rather than directly accessing the service_catalog dictionary.

Revision history for this message
Jamie Lennox (jamielennox) wrote :

Even better would be to use the auth plugins and let them handle the service catalog for you.

Revision history for this message
Lin Hua Cheng (lin-hua-cheng) wrote :

jamielennox: good call, didn't noticed that auth plugins also exposed the get_endpoint() method too. We should move to that instead.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to django_openstack_auth (master)

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

Changed in django-openstack-auth:
assignee: nobody → Lin Hua Cheng (lin-hua-cheng)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

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

Changed in horizon:
assignee: nobody → Lin Hua Cheng (lin-hua-cheng)
status: New → In Progress
Revision history for this message
Lin Hua Cheng (lin-hua-cheng) wrote :

Marking importance as High, Keystone is going to include additional data in the service catalog that is different from endpoint data format. Horizon assumes that the data is always well formatted, any unexpected data added will break Horizon.

Changed in django-openstack-auth:
milestone: none → 1.1.10
Changed in horizon:
milestone: none → kilo-3
importance: Undecided → High
Changed in django-openstack-auth:
importance: Undecided → High
Thierry Carrez (ttx)
Changed in horizon:
milestone: kilo-3 → kilo-rc1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/159308
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=8d3c2baa5b6f9ad22a398430c68ecfe54d6f4edc
Submitter: Jenkins
Branch: master

commit 8d3c2baa5b6f9ad22a398430c68ecfe54d6f4edc
Author: lin-hua-cheng <email address hidden>
Date: Wed Feb 25 16:51:28 2015 -0800

    Updated parsing of catalog to handle bad format

    Don't assume that the service catalog is well-formed, added code
    to safely parsing the catalog.

    Parsing of region from service catalog has been fixed as well.
    'region' has been deprecated in the Keystone V3 catalog in favor of
    'region_id'. Fix how region is extracted by checking 'region_id' then
    fallback to 'region'.

    Change-Id: I9e027586847b7b7c0276e8c3ff6b73f06a32e2a5
    Closes-Bug: #1424825

Changed in horizon:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to django_openstack_auth (master)

Reviewed: https://review.openstack.org/159303
Committed: https://git.openstack.org/cgit/openstack/django_openstack_auth/commit/?id=7ec44e898b08dc57e231d78465d9d242f2058d77
Submitter: Jenkins
Branch: master

commit 7ec44e898b08dc57e231d78465d9d242f2058d77
Author: lin-hua-cheng <email address hidden>
Date: Wed Feb 25 16:33:22 2015 -0800

    Updated parsing of catalog to handle bad format

    Don't assume that the service catalog is well-formed, added code
    to safely parsing the catalog.

    Parsing of region from service catalog has been fixed as well.
    'region' has been deprecated in the Keystone V3 catalog in favor of
    'region_id'. Fix how region is extracted by checking 'region_id' then
    fallback to 'region'.

    Change-Id: I7b649a8b90e20caa2d04fdd3f79b5b1ac775237c
    Closes-Bug: #1424825

Changed in django-openstack-auth:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in horizon:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: kilo-rc1 → 2015.1.0
David Lyle (david-lyle)
Changed in django-openstack-auth:
status: Fix Committed → 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.