From 8e6989b43f781eecfa556ff5903e28f870ae7c8d Mon Sep 17 00:00:00 2001 From: lavado Date: Mon, 9 Dec 2019 16:02:18 -0500 Subject: [PATCH] Validate Grafana is present for dashboarder service 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 --- osm_mon/dashboarder/dashboarder.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/osm_mon/dashboarder/dashboarder.py b/osm_mon/dashboarder/dashboarder.py index dc21e33..bb2935a 100644 --- a/osm_mon/dashboarder/dashboarder.py +++ b/osm_mon/dashboarder/dashboarder.py @@ -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'))) -- 2.25.1