Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Business Unit Dashboard fails to load plugins #83

Closed
sheagcraig opened this issue Dec 14, 2016 · 0 comments
Closed

Business Unit Dashboard fails to load plugins #83

sheagcraig opened this issue Dec 14, 2016 · 0 comments

Comments

@sheagcraig
Copy link
Contributor

When a Business Unit has more than one machine group, and plugins that use the machines query, it fails to load, throwing an exception:

[14/Dec/2016 10:45:58] ERROR [django.request:124] Internal Server Error: /id_pluginload/Status/bu_dashboard/1/
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 39, in inner
    response = get_response(request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/home/docker/sal/server/views.py", line 574, in plugin_load
    html = plugin.plugin_object.widget_content(page, machines, theID)
  File "/home/docker/sal/server/plugins/status/status.py", line 40, in widget_content
    errors = machines.filter(errors__gt=0).count()
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 369, in count
    return self.query.get_count(using=self.db)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 476, in get_count
    number = obj.get_aggregation(using, ['__count'])['__count']
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 457, in get_aggregation
    result = compiler.execute_sql(SINGLE)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 835, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
ProgrammingError: more than one row returned by a subquery used as an expression

The root of this problem is actually in the /server/views.py machines query for BusinessUnit filtered machines.

9687da3 rewrote the querying, and mistakenly tries to do a "exact" query on machine groups (which is why we see the "more than one row" error in the logs, and the problem disappears for Business Units with only one Machine Group.

PR incoming.

grahamgilbert added a commit that referenced this issue Dec 14, 2016
Fix single MG issue for BU machines query (fixes #83)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant