[PATCH 6/6][anaconda] Add handling for preexisting unusable storage configurations.

Vratislav Podzimek vpodzime at redhat.com
Thu Nov 6 07:40:39 UTC 2014


On Wed, 2014-11-05 at 09:49 -0600, David Lehman wrote:
> In the event that blivet finds a setup it cannot handle with any
> reasonable expectation of success it will raise ConfigurationError.
> The user then has the option to resolve the issue and retry the
> storage scan or exit the installer.
> ---
>  pyanaconda/errors.py        | 15 +++++++++++++++
>  pyanaconda/storage_utils.py | 14 ++++++++++++--
>  2 files changed, 27 insertions(+), 2 deletions(-)
> 
> diff --git a/pyanaconda/errors.py b/pyanaconda/errors.py
> index 29c15a9..124db04 100644
> --- a/pyanaconda/errors.py
> +++ b/pyanaconda/errors.py
> @@ -118,6 +118,20 @@ class ErrorHandler(object):
>          self.ui.showError(message)
>          return ERROR_RAISE
>  
> +    def _storageResetHandler(self, exn):
> +        message = (_("An error has occurred while scanning your existing "
> +                     "storage configuration:\n\n%(errortxt)s\n\nYou must "
> +                     "resolve this matter before the installation can proceed. "
> +                     "There is a shell available for use which you can access "
> +                     "by pressing ctrl-alt-f1 and then ctrl-b 2. Once you have "
> +                     "resolved the issue you can either retry the storage scan "
> +                     "or you can exit the installer. Would you like to retry?")
> +                   % {"errortxt": exn})
> +        if self.ui.showYesNoQuestion(message):
> +            return ERROR_RETRY
> +        else:
> +            return ERROR_RAISE
> +
>      def _noDisksHandler(self, exn):
>          message = _("An error has occurred - no valid devices were found on "
>                      "which to create new file systems.  Please check your "
> @@ -285,6 +299,7 @@ class ErrorHandler(object):
>  
>          _map = {"PartitioningError": self._partitionErrorHandler,
>                  "FSResizeError": self._fsResizeHandler,
> +                "ConfigurationError": self._storageResetHandler,
>                  "NoDisksError": self._noDisksHandler,
>                  "DirtyFSError": self._dirtyFSHandler,
>                  "FSTabTypeMismatchError": self._fstabTypeMismatchHandler,
> diff --git a/pyanaconda/storage_utils.py b/pyanaconda/storage_utils.py
> index bb3a5ee..bf59954 100644
> --- a/pyanaconda/storage_utils.py
> +++ b/pyanaconda/storage_utils.py
> @@ -35,11 +35,12 @@ from blivet.devicefactory import DEVICE_TYPE_BTRFS
>  from blivet.devicefactory import DEVICE_TYPE_MD
>  from blivet.devicefactory import DEVICE_TYPE_PARTITION
>  from blivet.devicefactory import DEVICE_TYPE_DISK
> +from blivet.errors import StorageError
>  
>  from pyanaconda.i18n import _, N_
>  from pyanaconda import isys
>  from pyanaconda.constants import productName
> -from pyanaconda.errors import UnknownSourceDeviceError
> +from pyanaconda.errors import errorHandler, UnknownSourceDeviceError, ERROR_RETRY
>  from pyanaconda.flags import flags
>  
>  from pykickstart.constants import AUTOPART_TYPE_PLAIN, AUTOPART_TYPE_BTRFS
> @@ -110,7 +111,16 @@ def storageInitialize(storage, ksdata, protected):
>      if protected:
>          storage.config.protectedDevSpecs.extend(protected)
>  
> -    storage.reset()
> +    while True:
> +        try:
> +            storage.reset()
> +        except StorageError as e:
> +            if errorHandler.cb(e) == ERROR_RETRY:
> +                continue
> +            else:
> +                raise
> +        else:
> +            break
Is this valid for all StorageError subclasses or should we work here
explicitly with the ConfigurationError?

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list