[2.2, trunk] Spaces API has broken backwards compatability

Bug #1656208 reported by Blake Rouse
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
High
Unassigned

Bug Description

The spaces API has broken backwards compatability preventing Juju from being able to bootstrap. Our CI and also our unit tests should have caught this issue.

Previous API result:

http://paste.ubuntu.com/23791040/

Trunk API result:

http://paste.ubuntu.com/23791044/

The difference is with:

Subnets -> vlan -> should be object trunk is now an integer

Related branches

Revision history for this message
Blake Rouse (blake-rouse) wrote :

This is the fix:

=== modified file 'src/maasserver/api/spaces.py'
--- src/maasserver/api/spaces.py 2017-01-04 19:37:16 +0000
+++ src/maasserver/api/spaces.py 2017-01-13 07:45:52 +0000
@@ -79,16 +79,7 @@
     @classmethod
     def subnets(cls, space):
         """Return an abbreviated view of each subnet in the space."""
- subnets = Subnet.objects.filter(vlan__space=space)
- return [
- {
- "id": subnet.id,
- "name": subnet.name,
- "cidr": str(subnet.cidr),
- "vlan": subnet.vlan_id
- }
- for subnet in subnets
- ]
+ return Subnet.objects.filter(vlan__space=space)

     @classmethod
     def vlans(cls, space):

Revision history for this message
Mike Pontillo (mpontillo) wrote :

Thanks for the patch. I spent some time testing a fix for this today to make sure it worked as expected.

I remembered that I had to render abbreviated objects at one point during development, because the VLAN or subnet would render the space, and then an infinite loop would occur. But before the branch landed, I made the VLAN endpoint consistent with the Subnet endpoint, and now the API simply returns the space name, not the entire object. So that removed the recursion I was worried about.

During testing, I also noticed that the resource_uri was missing for spaces, so I went ahead and added that as well.

Changed in maas:
status: Triaged → Fix Committed
Changed in maas:
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.