]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: remove non-null id in Grafana dashb
authorErnesto Puerta <epuertat@redhat.com>
Fri, 21 May 2021 08:57:23 +0000 (10:57 +0200)
committerErnesto Puerta <epuertat@redhat.com>
Fri, 21 May 2021 11:54:48 +0000 (13:54 +0200)
Testing added to prevent this situation.

Fixes: https://tracker.ceph.com/issues/50918
Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
monitoring/grafana/dashboards/pool-overview.json
src/pybind/mgr/dashboard/ci/check_grafana_uids.py

index 1815236ecd551489b9c4b5cee226be5570a11d49..cd699348b07fed820b7a326c08a1f2b466aa9206 100644 (file)
@@ -15,7 +15,7 @@
   "editable": false,
   "gnetId": null,
   "graphTooltip": 0,
-  "id": 15,
+  "id": null,
   "iteration": 1617656284287,
   "links": [],
   "panels": [
index f82ddbbc8bab7355bce536bc02713969645066a8..250fb8bad480e621ab479a6c79f74a4b970f6bf5 100644 (file)
@@ -72,28 +72,34 @@ def get_grafana_dashboards(base_dir):
     json_files = get_files(base_dir, 'json')
     dashboards = {}
     for json_file in json_files:
-        with open(json_file) as f:
-            dashboard_config = json.load(f)
-            uid = dashboard_config.get('uid')
-
-            # Grafana dashboard checks
-            title = dashboard_config['title']
-            assert len(title) > 0, \
-                "Title not found in '{}'".format(json_file)
-            assert len(dashboard_config.get('links', [])) == 0, \
-                "Links found in '{}'".format(json_file)
-            if not uid:
-                continue
-            if uid in dashboards:
-                # duplicated uids
-                error_msg = 'Duplicated UID {} found, already defined in {}'.\
-                    format(uid, dashboards[uid]['file'])
-                exit(error_msg)
-
-            dashboards[uid] = {
-                'file': json_file,
-                'title': title
-            }
+        try:
+            with open(json_file) as f:
+                dashboard_config = json.load(f)
+                uid = dashboard_config.get('uid')
+                assert dashboard_config['id'] is None, \
+                    "'id' not null: '{}'".format(dashboard_config['id'])
+
+                # Grafana dashboard checks
+                title = dashboard_config['title']
+                assert len(title) > 0, \
+                    "Title not found in '{}'".format(json_file)
+                assert len(dashboard_config.get('links', [])) == 0, \
+                    "Links found in '{}'".format(json_file)
+                if not uid:
+                    continue
+                if uid in dashboards:
+                    # duplicated uids
+                    error_msg = 'Duplicated UID {} found, already defined in {}'.\
+                        format(uid, dashboards[uid]['file'])
+                    exit(error_msg)
+
+                dashboards[uid] = {
+                    'file': json_file,
+                    'title': title
+                }
+        except Exception as e:
+            print(f"Error in file {json_file}")
+            raise e
     return dashboards