From 22bffbd25f5f9c31988245dbfe0b57b91f49fa47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9D=93=9C=F0=9D=93=AA=F0=9D=93=AC=F0=9D=93=AE=E2=84=A2?= <71522630+0815Cracky@users.noreply.github.com> Date: Wed, 11 Jun 2025 10:37:21 +0200 Subject: [PATCH] Fix OSD utilization calculation --- app/utils/ceph_calculator.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/utils/ceph_calculator.py b/app/utils/ceph_calculator.py index 7e117fc..78a8352 100644 --- a/app/utils/ceph_calculator.py +++ b/app/utils/ceph_calculator.py @@ -60,7 +60,11 @@ def calculate_ceph_capacity(replication_type, replicas=3, k=0, m=0, nodes=None, # Calculate OSD utilization using the formula x = (s × p) / (s + 1) # where s = number of OSDs per server and p = percentage of total utilization - osds_per_server = int(nodes[0].get('osd_count', 0)) if nodes else 0 + # Use the node with the most OSDs for the utilization calculation to avoid + # underestimating the usage when nodes differ in size + osds_per_server = max( + (int(node.get('osd_count', 0)) for node in nodes), default=0 + ) if nodes else 0 osd_usage_percent = (osds_per_server * max_recommended_usage_percent) / (osds_per_server + 1) # Find largest OSD size for calculating capacity after OSD failure