From a85e4c51525df4a7f986b4fe9028fa32750ef77f Mon Sep 17 00:00:00 2001 From: David Ripton Date: Tue, 2 Apr 2013 12:19:17 -0400 Subject: [PATCH] Raise rather than generating millions of IPs. Fixes bug #1163394 Formerly if we tried to create many millions of floating IPs with a range like "192.168.2.224/2", address_to_hosts would happily iterate over all of them (which would take a long time) and then nova-manage would eventually crash with an OutOfMemoryError when we tried putting all of them in a list. Or, if the initial list wasn't quite big enough to use all memory, it would blow up later (even more slowly) when we tried to put them in the database via SQLAlchemy. Now, raise exception.InvalidInput if the number of IPs is a million or more. (A million is erring on the side of caution.) Change-Id: Ifc6b6a8faadc2e97e09f9f6c975e52229f705789 --- bin/nova-manage | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/nova-manage b/bin/nova-manage index 3bcccfcce..50a192361 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -390,6 +390,14 @@ class FloatingIpCommands(object): reason = _("/%s should be specified as single address(es) " "not in cidr format") % net.prefixlen raise exception.InvalidInput(reason=reason) + elif net.size >= 1000000: + # NOTE(dripton): If we generate a million IPs and put them in + # the database, the system will slow to a crawl and/or run + # out of memory and crash. This is clearly a misconfiguration. + reason = _("Too many IP addresses will be generated. Please " + "increase /%s to reduce the number generated." + ) % net.prefixlen + raise exception.InvalidInput(reason=reason) else: return net.iter_hosts()