[master 1/1] Fix bad space needed messages

jkonecny12 installerbot-noreply at redhat.com
Fri Oct 23 14:13:49 UTC 2015


From: Jiri Konecny <jkonecny at redhat.com>

When we reduce metadata from device size in space check we also
need to tell user how much space he needs on root to get installation
done. That means we need to add metadata in count when calculating this
space deficit.
---
 pyanaconda/ui/gui/spokes/lib/resize.py | 13 +++++++++++--
 pyanaconda/ui/lib/space.py             | 10 ++++++++--
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/lib/resize.py b/pyanaconda/ui/gui/spokes/lib/resize.py
index cc086f9..be6e0a2 100644
--- a/pyanaconda/ui/gui/spokes/lib/resize.py
+++ b/pyanaconda/ui/gui/spokes/lib/resize.py
@@ -21,6 +21,7 @@
 
 
 from collections import namedtuple
+from decimal import Decimal, ROUND_UP
 
 import gi
 gi.require_version("Gdk", "3.0")
@@ -32,6 +33,7 @@
 from pyanaconda.ui.gui import GUIObject
 from pyanaconda.ui.gui.utils import blockedHandler, escape_markup, timed_action
 from blivet.size import Size
+from blivet.formats.fs import BTRFS
 
 __all__ = ["ResizeDialog"]
 
@@ -84,7 +86,7 @@ def __init__(self, data, storage, payload):
 
         self._required_label = self.builder.get_object("requiredSpaceLabel")
         markup = self._required_label.get_label()
-        self._required_label.set_markup(markup % escape_markup(str(self.payload.spaceRequired)))
+        self._required_label.set_markup(markup % escape_markup(str(self._updateRequiredSpace())))
 
         self._reclaimDescLabel = self.builder.get_object("reclaimDescLabel")
 
@@ -95,6 +97,13 @@ def __init__(self, data, storage, payload):
         self._deleteButton = self.builder.get_object("deleteButton")
         self._resizeSlider = self.builder.get_object("resizeSlider")
 
+    def _updateRequiredSpace(self):
+        space_required = self.payload.spaceRequired
+        # get real required space
+        # BTRFS is used here because it's FS with biggest space taken by metadata
+        space_required = Size(Decimal(space_required) / Decimal(BTRFS.MetadataSizeFactor))
+        return space_required.roundToNearest(Size("1 MiB"), rounding=ROUND_UP)
+
     def _description(self, part):
         # First, try to find the partition in some known Root.  If we find
         # it, return the mountpoint as the description.
@@ -314,7 +323,7 @@ def _update_action_buttons(self, row):
             self._deleteButton.set_sensitive(False)
 
     def _update_reclaim_button(self, got):
-        self._resizeButton.set_sensitive(got+self._initialFreeSpace >= self.payload.spaceRequired)
+        self._resizeButton.set_sensitive(got+self._initialFreeSpace >= self._updateRequiredSpace())
 
     # pylint: disable=arguments-differ
     def refresh(self, disks):
diff --git a/pyanaconda/ui/lib/space.py b/pyanaconda/ui/lib/space.py
index 067e4d8..47b695a 100644
--- a/pyanaconda/ui/lib/space.py
+++ b/pyanaconda/ui/lib/space.py
@@ -19,6 +19,8 @@
 # Red Hat Author(s): David Lehman <dlehman at redhat.com>
 #
 import os
+from decimal import Decimal, ROUND_UP
+
 from blivet.size import Size
 from pyanaconda import iutil
 
@@ -77,7 +79,9 @@ def check(self):
         log.info("fs space: %s  needed: %s", free, needed)
         self.success = (free > needed)
         if not self.success:
-            self.deficit = needed - free
+            required_space = Size(Decimal(needed) / Decimal(self.storage.rootDevice.format.MetadataSizeFactor))
+            self.deficit = required_space - self.storage.rootDevice.size
+            self.deficit = self.deficit.roundToNearest(Size("1 MiB"), rounding=ROUND_UP)
             self.error_message = _(self.error_template) % self.deficit
 
         return self.success
@@ -108,7 +112,9 @@ def check(self):
         log.info("fs space: %s  needed: %s", free, needed)
         self.success = (free > needed)
         if not self.success:
-            self.deficit = needed - free
+            required_space = Size(Decimal(needed) / Decimal(self.storage.rootDevice.format.MetadataSizeFactor))
+            self.deficit = required_space - self.storage.rootDevice.size
+            self.deficit = self.deficit.roundToNearest(Size("1 MiB"), rounding=ROUND_UP)
             self.error_message = _(self.error_template) % self.deficit
 
         return self.success


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/f7582ee3262c910d529165891f067537e52de781


More information about the anaconda-patches mailing list