shinken-monitoring / mod-webui

Shinken Web User Interface
GNU Affero General Public License v3.0
79 stars 71 forks source link

Exception (sometimes) on host display #651

Closed mohierf closed 5 years ago

mohierf commented 5 years ago

I noticed an exception like

Error: 500 Internal Server Error
Sorry, the requested URL 'http://127.0.0.1:7767/host/localhost2' caused an error:

Internal Server Error
Exception:
AttributeError("'unicode' object has no attribute 'hostgroup_name'",)
Traceback:
Traceback (most recent call last):
  File "/usr/local/bin/bottle.py", line 862, in _handle
    return route.call(**args)
  File "/usr/local/bin/bottle.py", line 1740, in wrapper
    rv = callback(*a, **ka)
  File "/usr/local/lib/python2.7/dist-packages/alignak_webui/module.py", line 642, in lock_version
    return f(**args)
  File "/usr/local/bin/bottle.py", line 3639, in wrapper
    result = func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/alignak_webui/plugins/eltdetail/eltdetail.py", line 39, in show_host
    app.datamgr.set_hostgroups_level(user)
  File "/usr/local/lib/python2.7/dist-packages/alignak_webui/datamanager.py", line 766, in set_hostgroups_level
    self.set_hostgroup_level(group, 0, user)
  File "/usr/local/lib/python2.7/dist-packages/alignak_webui/datamanager.py", line 772, in set_hostgroup_level
    for g in sorted(group.hostgroup_members, key=lambda g: g.hostgroup_name):
  File "/usr/local/lib/python2.7/dist-packages/alignak_webui/datamanager.py", line 772, in <lambda>
    for g in sorted(group.hostgroup_members, key=lambda g: g.hostgroup_name):
AttributeError: 'unicode' object has no attribute 'hostgroup_name'` 

when displying an host page. This looks like if the hosts groups were not build correclty by the regenerator ... when refreshing the same page, the error is no more present. this looks strange !

mohierf commented 5 years ago

When this exception happens, attributes of the group are:

{'configuration_errors': [], 'notes_url': u'', 'realm': u'48a49493-2070-4baa-ad08-93957229df90', 'uuid': u'f9fb0360-9b9d-408c-93b1-fd1ce787082e', 'tags': [], 'notes': u'', 'downtimes': {}, 'instance_id': u'SchedulerLink_2', 'hostgroup_name': u'routers', 'action_url': u'', 'alias': u'All the routers', 'configuration_warnings': [], 'members': [], 'hash': '', 'hostgroup_members': [u'north-routers', u'south-routers'], 'level': 0, 'id': u'f9fb0360-9b9d-408c-93b1-fd1ce787082e'} 

The hosts groups members are string values and not objects!

Fixing this problem is possible in the regenerator or in the datamanager. The best solution would be to unify the groups management done in the regenerator (link groups and hosts) and in the datamanager (set groups level information)