Skip to content

Commit 82d100a

Browse files
committed
mgr/dashboard: handle infinite values for pools
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 <[email protected]>
1 parent 55ac8d6 commit 82d100a

File tree

1 file changed

+11
-1
lines changed
  • src/pybind/mgr/dashboard/controllers

1 file changed

+11
-1
lines changed

src/pybind/mgr/dashboard/controllers/pool.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3+
import math
34
import time
45
from typing import Any, Dict, Iterable, List, Optional, Union, cast
56

@@ -101,7 +102,7 @@ def _serialize_pool(pool, attrs):
101102

102103
crush_rules = {r['rule_id']: r["rule_name"] for r in mgr.get('osd_map_crush')['rules']}
103104

104-
res: Dict[Union[int, str], Union[str, List[Any]]] = {}
105+
res: Dict[Union[int, str], Union[str, List[Any], Dict[str, Any]]] = {}
105106
for attr in attrs:
106107
if attr not in pool:
107108
continue
@@ -111,6 +112,15 @@ def _serialize_pool(pool, attrs):
111112
res[attr] = crush_rules[pool[attr]]
112113
elif attr == 'application_metadata':
113114
res[attr] = list(pool[attr].keys())
115+
# handle infinity values
116+
elif attr == 'read_balance' and isinstance(pool[attr], dict):
117+
read_balance: Dict[str, Any] = {}
118+
for key, value in pool[attr].items():
119+
if isinstance(value, float) and math.isinf(value):
120+
read_balance[key] = "Infinity"
121+
else:
122+
read_balance[key] = value
123+
res[attr] = read_balance
114124
else:
115125
res[attr] = pool[attr]
116126

0 commit comments

Comments
 (0)