Alignak-monitoring-contrib / alignak-module-backend

Alignak modules (arbiter, broker, scheduler) for the backend
GNU Affero General Public License v3.0
0 stars 2 forks source link

Broker module exception #60

Closed mohierf closed 7 years ago

mohierf commented 7 years ago

Using try...except is a must-have for the backend modules!

[2017-02-14 04:41:07 CET] ERROR: [alignak.basemodule] [backend_broker] main function exception: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/root/git/alignak/alignak/basemodule.py", line 412, in _main
    self.main()
  File "/usr/local/lib/python2.7/site-packages/alignak_module_backend/broker/module.py", line 573, in main
    self.manage_brok(b)
  File "/usr/local/lib/python2.7/site-packages/alignak_module_backend/broker/module.py", line 461, in manage_brok
    self.update(brok.data, 'service')
  File "/usr/local/lib/python2.7/site-packages/alignak_module_backend/broker/module.py", line 336, in update
    ret = self.send_to_backend('livestate_service', service_name, data_to_update)
  File "/usr/local/lib/python2.7/site-packages/alignak_module_backend/broker/module.py", line 408, in send_to_backend
    data, headers, True)
  File "/usr/local/lib/python2.7/site-packages/alignak_backend_client/client.py", line 644, in patch
    resp = response.json()
  File "/usr/local/lib/python2.7/site-packages/requests/models.py", line 866, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/simplejson/__init__.py", line 516, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python2.7/site-packages/simplejson/decoder.py", line 374, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python2.7/site-packages/simplejson/decoder.py", line 404, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[2017-02-14 04:41:07 CET] INFO: [alignak.basemodule] Process for module backend_broker is now exiting (pid=68433)
mohierf commented 7 years ago

In the backend log:

[2017-02-14 04:41:07,622] - eve - ERROR - Exception on /service/589c88356376e9e74f2e6e2b [PATCH]
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python2.7/site-packages/eve/endpoints.py", line 94, in item_endpoint
    response = patch(resource, **lookup)
  File "/usr/local/lib/python2.7/site-packages/eve/methods/common.py", line 242, in rate_limited
    return f(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/eve/auth.py", line 77, in decorated
    if not auth.authorized(roles, resource_name, request.method):
  File "/usr/local/lib/python2.7/site-packages/eve/auth.py", line 259, in authorized
    method)
  File "/usr/local/lib/python2.7/site-packages/alignak_backend/app.py", line 83, in check_auth
    user = current_app.data.driver.db['user'].find_one({'token': token})
  File "/usr/local/lib/python2.7/site-packages/pymongo/collection.py", line 1102, in find_one
    for result in cursor.limit(-1):
  File "/usr/local/lib/python2.7/site-packages/pymongo/cursor.py", line 1114, in next
    if len(self.__data) or self._refresh():
  File "/usr/local/lib/python2.7/site-packages/pymongo/cursor.py", line 1036, in _refresh
    self.__collation))
  File "/usr/local/lib/python2.7/site-packages/pymongo/cursor.py", line 873, in __send_message
    **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 905, in _send_message_with_response
    exhaust)
  File "/usr/local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 916, in _reset_on_error
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pymongo/server.py", line 99, in send_message_with_response
    with self.get_socket(all_credentials, exhaust) as sock_info:
  File "/usr/local/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/local/lib/python2.7/site-packages/pymongo/server.py", line 168, in get_socket
    with self.pool.get_socket(all_credentials, checkout) as sock_info:
  File "/usr/local/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/local/lib/python2.7/site-packages/pymongo/pool.py", line 790, in get_socket
    sock_info = self._get_socket_no_auth()
  File "/usr/local/lib/python2.7/site-packages/pymongo/pool.py", line 836, in _get_socket_no_auth
    sock_info = self._check(sock_info)
  File "/usr/local/lib/python2.7/site-packages/pymongo/pool.py", line 890, in _check
    return self.connect()
  File "/usr/local/lib/python2.7/site-packages/pymongo/pool.py", line 763, in connect
    _raise_connection_failure(self.address, error)
  File "/usr/local/lib/python2.7/site-packages/pymongo/pool.py", line 211, in _raise_connection_failure
    raise AutoReconnect(msg)
AutoReconnect: 93.93.47.82:27017: [Errno 61] Connection refused

And then the backend was restarted at 05:03 ! You did restarted @ddurieux ?

ddurieux commented 7 years ago

yes

mohierf commented 7 years ago

Then you should have checked that Alignak modules were not broken 😞