Validate Grafana is present for dashboarder service 58/8358/3 v7.0.0rc1
authorlavado <glavado@whitestack.com>
Mon, 9 Dec 2019 21:02:18 +0000 (16:02 -0500)
committerlavado <glavado@whitestack.com>
Tue, 10 Dec 2019 00:57:08 +0000 (19:57 -0500)
Check if MON can resolve a grafana service.
This is currently useful in the transition to K8s,
or in OSM distros with absent Grafana.

Fixes Bug 932

Change-Id: I3b5ebf3d8ee3397f16793cd730e7e1fa5f6676d4
Signed-off-by: lavado <glavado@whitestack.com>
osm_mon/dashboarder/dashboarder.py

index dc21e33..bb2935a 100644 (file)
@@ -22,7 +22,7 @@
 ##
 import logging
 import time
-
+import socket
 import peewee
 
 from osm_mon.dashboarder.service import DashboarderService
@@ -39,6 +39,13 @@ class Dashboarder:
     def dashboard_forever(self):
         log.debug('dashboard_forever')
         while True:
+            try:
+                socket.gethostbyname("grafana")
+                log.debug("Dashboard backend is running")
+            except socket.error:
+                log.debug("Dashboard backend is not available")
+                time.sleep(int(self.conf.get('dashboarder', 'interval')))
+                continue
             try:
                 self.create_dashboards()
                 time.sleep(int(self.conf.get('dashboarder', 'interval')))