]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: handle infinite values for pools 56006/head
authorAfreen <afreen23.git@gmail.com>
Wed, 6 Mar 2024 20:22:16 +0000 (01:52 +0530)
committerAfreen <afreen23.git@gmail.com>
Fri, 8 Mar 2024 10:22:53 +0000 (15:52 +0530)
Fixes https://tracker.ceph.com/issues/64724

Issue:
======
Json parsing is failing because of Infinity values present in pools
meteadata. "read_balance": {"score_acting": Infinity, "score_stable":
Infinity,}
Due to this entire pool list is not rendered.

Fix:
====
Added a handler for checking "inf" values and replacing them with a
string "Infinity" so that json parsing does not fail on frontend.

Signed-off-by: Afreen <afreen23.git@gmail.com>
src/pybind/mgr/dashboard/controllers/pool.py

index 1e2e04e1b14da5548abe221d7c654a1b470a8b38..9310d2f97aab188914dc147ef7e9cd5d27babff1 100644 (file)
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
 
+import math
 import time
 from typing import Any, Dict, Iterable, List, Optional, Union, cast
 
@@ -101,7 +102,7 @@ class Pool(RESTController):
 
         crush_rules = {r['rule_id']: r["rule_name"] for r in mgr.get('osd_map_crush')['rules']}
 
-        res: Dict[Union[int, str], Union[str, List[Any]]] = {}
+        res: Dict[Union[int, str], Union[str, List[Any], Dict[str, Any]]] = {}
         for attr in attrs:
             if attr not in pool:
                 continue
@@ -111,6 +112,15 @@ class Pool(RESTController):
                 res[attr] = crush_rules[pool[attr]]
             elif attr == 'application_metadata':
                 res[attr] = list(pool[attr].keys())
+            # handle infinity values
+            elif attr == 'read_balance' and isinstance(pool[attr], dict):
+                read_balance: Dict[str, Any] = {}
+                for key, value in pool[attr].items():
+                    if isinstance(value, float) and math.isinf(value):
+                        read_balance[key] = "Infinity"
+                    else:
+                        read_balance[key] = value
+                res[attr] = read_balance
             else:
                 res[attr] = pool[attr]