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

Catch login exception when backend is not available #85

Closed mohierf closed 7 years ago

mohierf commented 7 years ago

Have some cleaner log when the alignak backend is not available. Currently:

ERROR:alignak_backend_client.client:Backend connection error, error: HTTPConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url: /login (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7fb90d260a90>: Failed to establish a new connection: [Errno 111] Connection refused',))
WARNING:alignak.module.backend_scheduler:Alignak backend is not available for login. No backend connection.
ERROR:alignak.module.backend_scheduler:Exception: Backend error code 1000: Backend connection error
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/alignak_module_backend-0.6.0-py2.7.egg/alignak_module_backend/scheduler/module.py", line 115, in getToken
    self.backend_connected = self.backend.login(username, password, generate)
  File "/usr/local/lib/python2.7/dist-packages/alignak_backend_client-0.9.0-py2.7.egg/alignak_backend_client/client.py", line 176, in login
    raise BackendException(1000, "Backend connection error")
BackendException: Backend error code 1000: Backend connection error

Avoiding the exception backtrace would be cleaner 😉

mohierf commented 7 years ago

The exception log should be set at DEBUG level