[PATCH 1/2] Don't traceback when no size is given in kickstart (#1067707).

Chris Lumens clumens at redhat.com
Fri Feb 21 15:50:09 UTC 2014


There are various circumstances where a size may not be given - recommended swap
size, grow, and the like.  We need to ignore these situations and let the
methods we call deal with the default value.  This bug was caused by
ea61ee97601b3aa3f49c2163d0b86c48ef6a3e31.  I've added a test case for it.
---
 pyanaconda/kickstart.py            |  8 ++++++
 tests/storage/cases/__init__.py    |  2 +-
 tests/storage/cases/bz1067707.py   | 51 ++++++++++++++++++++++++++++++++++++++
 tests/storage/run_storage_tests.py |  7 ++++--
 4 files changed, 65 insertions(+), 3 deletions(-)
 create mode 100644 tests/storage/cases/bz1067707.py

diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
index 1c5a64a..7ab7151 100644
--- a/pyanaconda/kickstart.py
+++ b/pyanaconda/kickstart.py
@@ -710,6 +710,8 @@ class LogVolData(commands.logvol.F20_LogVolData):
             size = Size(spec="%d MiB" % self.size)
         except (ValueError, SizeParamsError):
             raise KickstartValueError(formatErrorMsg(self.lineno, msg="The size %s is not valid." % self.size))
+        except TypeError:
+            pass
 
         if self.mountpoint == "swap":
             ty = "swap"
@@ -852,6 +854,8 @@ class LogVolData(commands.logvol.F20_LogVolData):
                     maxsize = Size(spec="%d MiB" % self.maxSizeMB)
                 except (ValueError, SizeParamsError):
                     raise KickstartValueError(formatErrorMsg(self.lineno, msg="The maximum size %s is not valid." % self.maxSizeMB))
+                except TypeError:
+                    pass
             else:
                 maxsize = None
 
@@ -942,6 +946,8 @@ class PartitionData(commands.partition.F18_PartData):
             size = Size(spec="%d MiB" % self.size)
         except (ValueError, SizeParamsError):
             raise KickstartValueError(formatErrorMsg(self.lineno, msg="The size %s is not valid." % self.size))
+        except TypeError:
+            pass
 
         if self.onbiosdisk != "":
             for (disk, biosdisk) in storage.eddDict.iteritems():
@@ -1096,6 +1102,8 @@ class PartitionData(commands.partition.F18_PartData):
                 maxsize = Size(spec="%d MiB" % self.maxSizeMB)
             except (ValueError, SizeParamsError):
                 raise KickstartValueError(formatErrorMsg(self.lineno, msg="The maximum size %s is not valid." % self.maxSizeMB))
+            except TypeError:
+                pass
         else:
             maxsize = None
 
diff --git a/tests/storage/cases/__init__.py b/tests/storage/cases/__init__.py
index 1e2fd5f..fae1f9e 100644
--- a/tests/storage/cases/__init__.py
+++ b/tests/storage/cases/__init__.py
@@ -119,7 +119,7 @@ class TestCaseComponent(object):
     def __init__(self):
         """Create a new TestCaseComponent instance.  This __init__ method should
            typically do very little.  However, subclasses must be sure to set
-           self.disksToCreate.  This attribute is a list of (disk name, size in MB)
+           self.disksToCreate.  This attribute is a list of (disk name, blivet.Size)
            tuples that will be used in this test.  Disks given in this list will
            be automatically created by setupDisks and destroyed by tearDownDisks.
         """
diff --git a/tests/storage/cases/bz1067707.py b/tests/storage/cases/bz1067707.py
new file mode 100644
index 0000000..b67c15d
--- /dev/null
+++ b/tests/storage/cases/bz1067707.py
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2014  Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Chris Lumens <clumens at redhat.com>
+
+from . import TestCase, TestCaseComponent
+from blivet.size import Size
+
+class SwapWithRecommendedSizeComponent(TestCaseComponent):
+    name = "SwapWithRecommendedSize"
+
+    def __init__(self, *args, **kwargs):
+        TestCaseComponent.__init__(self, *args, **kwargs)
+        self.disksToCreate = [("anatest-disk1", Size(spec="1GiB"))]
+
+    @property
+    def ks(self):
+        return """
+zerombr
+clearpart --all --initlabel
+part swap --recommended
+"""
+
+class BZ1067707_TestCase(TestCase):
+    components = [SwapWithRecommendedSizeComponent]
+    name = "1067707"
+    desc = """The members of various commands must have the correct format.
+For instance, raid members must have mdmember, and volgroup members must have
+lvmpv.  If they do not have this format, a KickstartValueError should be raised
+during storage execution time.
+
+Note that this is different from the error condition described in the bug.
+There, anaconda was letting the invalid format go and then hitting errors
+much further in installation - during bootloader installation.  The real
+bug is that this condition should be detected when the kickstart storage
+commands are being converted to actions.
+"""
diff --git a/tests/storage/run_storage_tests.py b/tests/storage/run_storage_tests.py
index 4af47df..ef155e0 100755
--- a/tests/storage/run_storage_tests.py
+++ b/tests/storage/run_storage_tests.py
@@ -8,7 +8,10 @@ if os.geteuid() != 0:
     os._exit(77)
 
 from cases.bz1014545 import BZ1014545_TestCase
-tc = BZ1014545_TestCase()
-failures = tc.run()
+from cases.bz1067707 import BZ1067707_TestCase
+
+for tc in [BZ1014545_TestCase(),
+           BZ1067707_TestCase()]:
+    failures = tc.run()
 
 os._exit(failures)
-- 
1.8.3.1



More information about the anaconda-patches mailing list