Internal Server Error when trying to determine MAAS version from apt-cache

Bug #1489529 reported by Andres Rodriguez on 2015-08-27
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ricardo Bánffy

Bug Description

apt cache was borked, and it couldn't extract the maas version for the webpage, causing an internal server error.

Related branches

Changed in maas:
milestone: none → 1.9.0
Changed in maas:
status: New → Confirmed
Changed in maas:
importance: Undecided → High
Gavin Panella (allenap) on 2015-09-02
Changed in maas:
status: Confirmed → Triaged
no longer affects: maas/1.8
Ricardo Bánffy (rbanffy) wrote :

In order to reproduce the problem, run `sudo rm -rf /var/lib/dpkg/` on your machine. It's not easy to recover from it, so, do it only if you need to see the problem happening.

Ricardo Bánffy (rbanffy) wrote :

Alternatively, you can just move the /var/lib/dpkg directory someplace dpkg will not find it. It's much easier to recover that way. What you'll get in the logs is a traceback like this:

==> /var/log/maas/regiond.log <==
2015-10-14 06:27:24 [HTTPChannel,2,] 500 Error - /MAAS/
 Traceback (most recent call last):
   File "/usr/lib/python2.7/dist-packages/django/core/handlers/", line 206, in __call__
     response = self.get_response(request)
   File "/usr/lib/python2.7/dist-packages/maasserver/utils/", line 236, in get_response
     response = get_response(request)
   File "/usr/lib/python2.7/dist-packages/maasserver/utils/", line 210, in get_response
     return django_get_response(request)
   File "/usr/lib/python2.7/dist-packages/django/core/handlers/", line 194, in get_response
     response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
 --- <exception caught here> ---
   File "/usr/lib/python2.7/dist-packages/django/core/handlers/", line 137, in get_response
     response = response.render()
   File "/usr/lib/python2.7/dist-packages/django/template/", line 105, in render
     self.content = self.rendered_content
   File "/usr/lib/python2.7/dist-packages/django/template/", line 81, in rendered_content
     context = self.resolve_context(self.context_data)
   File "/usr/lib/python2.7/dist-packages/django/template/", line 159, in resolve_context
     return RequestContext(self._request, context, current_app=self._current_app)
   File "/usr/lib/python2.7/dist-packages/django/template/", line 169, in __init__
   File "/usr/lib/python2.7/dist-packages/maasserver/", line 111, in global_options
     'version': get_maas_version_ui(),
   File "/usr/lib/python2.7/dist-packages/maasserver/utils/", line 82, in wrapped
     _cache[key] = fun(*args, **kwargs)
   File "/usr/lib/python2.7/dist-packages/maasserver/utils/", line 118, in get_maas_version_ui
     version, subversion = get_maas_version_subversion()
   File "/usr/lib/python2.7/dist-packages/maasserver/utils/", line 82, in wrapped
     _cache[key] = fun(*args, **kwargs)
   File "/usr/lib/python2.7/dist-packages/maasserver/utils/", line 98, in get_maas_version_subversion
     apt_version = get_maas_package_version()
   File "/usr/lib/python2.7/dist-packages/maasserver/utils/", line 82, in wrapped
     _cache[key] = fun(*args, **kwargs)
   File "/usr/lib/python2.7/dist-packages/maasserver/utils/", line 92, in get_maas_package_version
     return get_version_from_apt(REGION_PACKAGE_NAME)
   File "/usr/lib/python2.7/dist-packages/maasserver/utils/", line 39, in get_version_from_apt
     cache = apt_pkg.Cache(None)
 exceptions.SystemError: E:Could not open file /var/lib/dpkg/status - open (2: No such file or directory), E:The package lists or status file could not be parsed or opened.

Changed in maas:
assignee: nobody → Ricardo Bánffy (rbanffy)
Blake Rouse (blake-rouse) wrote :

To resolve this bug we should be using dpkg instead of apt to get the MAAS version. Because if there is an issue with APT then this will occur. What you did probably just destroyed all your packaging information on your machine. The easier way of reproducing this would be to add a source to sources.list that is invalid and then doing "apt-get update". Now see if it falls over, which it should. In that case dpkg will return the correct result.

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  Edit
Everyone can see this information.

Other bug subscribers