[2.0] subnet.list: list index out of range error when using a /31 subnet

Bug #1570606 reported by tz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Critical
Mike Pontillo
maas (Ubuntu)
Undecided
Mike Pontillo

Bug Description

xenial 16.04
maas 2.0.0~beta2+bzr4920-0ubuntu1

browsing to Nodes, DNS, Networks, or DHCP Snippets (anything that has IP ranges) returns "index out of range"

initial investigation looks like the same problem as the divide by zero error, MAASIPRange isnt being populated. Hard to see why that is though.

2016-04-14 21:22:43 [-] Error on request (15) subnet.list: list index out of range
Apr 14 21:22:43 hostname sh[46786]: #011--- <exception caught here> ---
Apr 14 21:22:43 hostname sh[46786]: #011 File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 246, in inContext
Apr 14 21:22:43 hostname sh[46786]: #011 result = inContext.theWork()
Apr 14 21:22:43 hostname sh[46786]: #011 File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 262, in <lambda>
Apr 14 21:22:43 hostname sh[46786]: #011 inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
Apr 14 21:22:43 hostname sh[46786]: #011 File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 118, in callWithContext
Apr 14 21:22:43 hostname sh[46786]: #011 return self.currentContext().callWithContext(ctx, func, *args, **kw)
Apr 14 21:22:43 hostname sh[46786]: #011 File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 81, in callWithContext
Apr 14 21:22:43 hostname sh[46786]: #011 return func(*args,**kw)
Apr 14 21:22:43 hostname sh[46786]: #011 File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 874, in callInContext
Apr 14 21:22:43 hostname sh[46786]: #011 return func(*args, **kwargs)
Apr 14 21:22:43 hostname sh[46786]: #011 File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 516, in call_within_transaction
Apr 14 21:22:43 hostname sh[46786]: #011 return func_outside_txn(*args, **kwargs)
Apr 14 21:22:43 hostname sh[46786]: #011 File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 343, in retrier
Apr 14 21:22:43 hostname sh[46786]: #011 return func(*args, **kwargs)
Apr 14 21:22:43 hostname sh[46786]: #011 File "/usr/lib/python3.5/contextlib.py", line 30, in inner
Apr 14 21:22:43 hostname sh[46786]: #011 return func(*args, **kwds)
Apr 14 21:22:43 hostname sh[46786]: #011 File "/usr/lib/python3/dist-packages/maasserver/websockets/base.py", line 343, in list
Apr 14 21:22:43 hostname sh[46786]: #011 for obj in objs
Apr 14 21:22:43 hostname sh[46786]: #011 File "/usr/lib/python3/dist-packages/maasserver/websockets/base.py", line 343, in <listcomp>
Apr 14 21:22:43 hostname sh[46786]: #011 for obj in objs
Apr 14 21:22:43 hostname sh[46786]: #011 File "/usr/lib/python3/dist-packages/maasserver/websockets/base.py", line 195, in full_dehydrate
Apr 14 21:22:43 hostname sh[46786]: #011 return self.dehydrate(obj, data, for_list=for_list)
Apr 14 21:22:43 hostname sh[46786]: #011 File "/usr/lib/python3/dist-packages/maasserver/websockets/handlers/subnet.py", line 41, in dehydrate
Apr 14 21:22:43 hostname sh[46786]: #011 metadata = IPRangeStatistics(full_range)
Apr 14 21:22:43 hostname sh[46786]: #011 File "/usr/lib/python3/dist-packages/provisioningserver/utils/network.py", line 155, in __init__
Apr 14 21:22:43 hostname sh[46786]: #011 self.first_address_value = self.ranges.first
Apr 14 21:22:43 hostname sh[46786]: #011 File "/usr/lib/python3/dist-packages/provisioningserver/utils/network.py", line 335, in first
Apr 14 21:22:43 hostname sh[46786]: #011 return self.ranges[0].first
Apr 14 21:22:43 hostname sh[46786]: #011builtins.IndexError: list index out of range

Related branches

Changed in maas:
milestone: none → 2.0.0
importance: Undecided → Critical
summary: - subnet.list: list index out of range
+ [2.0] subnet.list: list index out of range
Changed in maas:
status: New → Triaged
assignee: nobody → Mike Pontillo (mpontillo)
Revision history for this message
Mike Pontillo (mpontillo) wrote : Re: [2.0] subnet.list: list index out of range

This one is more puzzling than I first thought. It seems you have a subnet that has no IP addresses in it, and I'm not sure how this can happen. (the divide by zero you mentioned was due to a /32 subnet, and we already have unit tests for /32 and /128 subnets.)

Which subnets are defined on your MAAS server? Are you able to log into the MAAS CLI and tell me which is the problematic subnet? To narrow it down, run this command against each subnet:

maas <profile> subnet statistics <cidr> include_suggestions=True include_ranges=True

The one that doesn't work is the one causing the problem.

Changed in maas:
status: Triaged → Incomplete
Revision history for this message
Mike Pontillo (mpontillo) wrote :

OK, I think how this could occur just hit me... don't tell me you have a /31.

Rather, why in the world do you have a /31?!?! ;-)

Changed in maas:
status: Incomplete → In Progress
Changed in maas (Ubuntu):
status: New → Confirmed
assignee: nobody → Mike Pontillo (mpontillo)
Revision history for this message
tz (csherwood-n) wrote :

i pulled the subnet list from maas-proxy.conf, would be interested in a better way to grab the subnets tho!

/var/lib/maas]$ maas maas subnet statistics x.x.x.x/31 include_suggestions=True include_ranges=True
list index out of range

can i manually edit that somewhere (as i dont have GUI access due to the error) or should i just wait for a fix?

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

Well, MAAS will automatically create subnets for you if it sees them attached to a registered rack controller. That is probably how you got the /31. (but you can use "maas maas subnets read" to grab of all of them from the API.)

If you want to test the proposed fix, take a look at the linked merge proposal here:

https://code.launchpad.net/~mpontillo/maas/fix-1570606/+merge/291957

Then make the same change I made to this file on your MAAS server:

/usr/lib/python3/dist-packages/provisioningserver/utils/network.py

summary: - [2.0] subnet.list: list index out of range
+ [2.0] subnet.list: list index out of range error when using a /31 subnet
Revision history for this message
Mike Pontillo (mpontillo) wrote :

By the way, you will most likely only need the changes in that file related to the prefixlen; I added an assert just in case this happens again, since it's difficult to troubleshoot the problem without knowing what the problematic CIDR was.

Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers