Browse Source

Fix divide zero error when no object storage cost

Change-Id: I6018678aac7367c5fbe4d169509feff1f262d05d
Feilong Wang 1 year ago
parent
commit
aa78a20f66
1 changed files with 3 additions and 1 deletions
  1. 3
    1
      distil_ui/api/distil_v2.py

+ 3
- 1
distil_ui/api/distil_v2.py View File

@@ -155,7 +155,9 @@ def _wash_details(current_details):
155 155
     # NOTE(flwang): Currently, the breakdown will accumulate all the object
156 156
     # storage cost, so we need to deduce the duplicated part.
157 157
     object_cost = current_details["breakdown"].get(OBJECTSTORAGE_CATEGORY, 0)
158
-    dup_object_cost = (region_count - 1) * (object_cost / region_count)
158
+
159
+    dup_object_cost = (0 if region_count == 0 else
160
+                       (region_count - 1) * (object_cost / region_count))
159 161
     current_details["total_cost"] = (current_details["total_cost"] -
160 162
                                      dup_object_cost)
161 163
     return current_details

Loading…
Cancel
Save