[PATCHv3 1/2] Tear down all devices after finding existing installations

Vratislav Podzimek vpodzime at redhat.com
Thu Jul 2 16:26:00 UTC 2015


On Thu, 2015-07-02 at 11:19 -0500, David Lehman wrote:
> On 07/01/2015 03:27 AM, Vratislav Podzimek wrote:
> > When trying to find existing installations we setup and mount devices (to check
> > if they have /etc/fstab). Setting a device up results in its parents being setup
> > too (recursively) so when done we need to tear all/rest of the devices down so
> > that they are not left activated as that could cause problems later (as for
> > example in the bug where a thin pool was activated/setup on setup of a thin LV
> > and never deactivated/torn down).
> >
> > Resolves: rhbz#1182229
> > Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> > ---
> >   blivet/__init__.py | 12 +++++++++++-
> >   1 file changed, 11 insertions(+), 1 deletion(-)
> >
> > diff --git a/blivet/__init__.py b/blivet/__init__.py
> > index 47cb1dd..7cb1228 100644
> > --- a/blivet/__init__.py
> > +++ b/blivet/__init__.py
> > @@ -2979,7 +2979,14 @@ def getReleaseString():
> >
> >       return (relArch, relName, relVer)
> >
> > -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
> > +
> > +    """
> >       if not os.path.exists(getTargetPhysicalRoot()):
> >           util.makedirs(getTargetPhysicalRoot())
> >
> > @@ -3027,6 +3034,9 @@ def findExistingInstallations(devicetree):
> >               continue
> >           roots.append(Root(mounts=mounts, swaps=swaps, name=name))
> >
> > +    if teardown_all:
> > +        devicetree.teardownAll()
> > +
> >       return roots
> >
> >   class Root(object):
> >
> 
> This function can raise exceptions pretty easily if people have screwy
> stuff in their existing fstabs. We catch those and proceed in
> Blivet.reset, but the devices won't be torn down with this patch.
> 
> As much as I hate it, maybe you should rename findExistingInstallations
> _findExistingInstallations and add a findExistingInstallations that just
> wraps a call to _findExistingInstallations like
> 
> try:
>    _findExistingInstallations()
> except Exception:
>    log()
> finally:
>    teardownAll()
Works for me. Fixing locally.

-- 
Vratislav Podzimek

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



More information about the anaconda-patches mailing list