[blivet][master] Make sure devices are always torn down in findExistingInstallations if requested
Vratislav Podzimek
vpodzime at redhat.com
Fri Sep 11 06:46:18 UTC 2015
On Wed, 2015-09-09 at 11:19 -0700, Brian C. Lane wrote:
> On Wed, Sep 09, 2015 at 12:44:19PM +0200, Vratislav Podzimek wrote:
> > It's not that uncommon that findExistingInstallations() raises an
> > exception. Even in such case we need to tear all devices down if requested. Also
> > such exceptions should be just logged and not propagated as this function is a
> > "best-effort" one.
> >
> > (port of commits bbe124c94772cb3313a05e9a00a663f75084be55 and
> > 71f77ec0e7f657a3e9bffd03b859e845b2598eb7 from rhel7-branch merged together)
> >
> > Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> > ---
> > blivet/blivet.py | 6 +-----
> > blivet/osinstall.py | 19 ++++++++++++++++++-
> > 2 files changed, 19 insertions(+), 6 deletions(-)
> >
> > diff --git a/blivet/blivet.py b/blivet/blivet.py
> > index f555ec2..f232f71 100644
> > --- a/blivet/blivet.py
> > +++ b/blivet/blivet.py
> > @@ -286,11 +286,7 @@ class Blivet(object):
> >
> > self.roots = []
> > if flags.installer_mode:
> > - try:
> > - self.roots = findExistingInstallations(self.devicetree)
> > - except Exception: # pylint: disable=broad-except
> > - log_exception_info(log.info, "failure detecting existing installations")
> > -
> > + self.roots = findExistingInstallations(self.devicetree)
> > self.dumpState("initial")
> >
> > if not flags.installer_mode:
> > diff --git a/blivet/osinstall.py b/blivet/osinstall.py
> > index bb7c204..fb4e6f6 100644
> > --- a/blivet/osinstall.py
> > +++ b/blivet/osinstall.py
> > @@ -196,7 +196,24 @@ def parseFSTab(devicetree, chroot=None):
> >
> > return (mounts, swaps)
> >
> > -def findExistingInstallations(devicetree):
> > +def findExistingInstallations(devicetree, teardown_all=True):
> > + """Find existing GNU/Linux installations on devices from the devicetree.
> > + :param devicetree: devicetree to find existing installations in
> > + :type devicetree: :class:`~.devicetree.DeviceTree`
> > + :param bool teardown_all: whether to tear down all devices in the
> > + devicetree in the end
> > +
>
> Return needs to be documented.
Good point.
>
> > + """
> > + try:
> > + roots = _findExistingInstallations(devicetree)
> > + return roots
> > + except Exception: # pylint: disable=broad-except
> > + log_exception_info(log.info, "failure detecting existing installations")
> > + finally:
> > + if teardown_all:
> > + devicetree.teardownAll()
>
> Needs to return [] maybe?
And another one. Fixing locally and pushing, thanks!
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list