[blivet:master 10/11] Fall back to accepting defaults if btrfs creation fails (#1109195)

Martin Kolman mkolman at redhat.com
Tue Jun 17 16:58:22 UTC 2014


On Tue, 2014-06-17 at 11:08 -0400, mulhern wrote:
> Resolves: fed#1109195
> 
> At the point where the filesystem is being created failure because btrfs
> is not comfortable with the options specified is worse than success
> w/out those particular options.
> 
> Signed-off-by: mulhern <amulhern at redhat.com>
> ---
>  blivet/devices.py | 23 +++++++++++++++++++----
>  1 file changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/blivet/devices.py b/blivet/devices.py
> index d488422..097eab3 100644
> --- a/blivet/devices.py
> +++ b/blivet/devices.py
> @@ -5220,10 +5220,25 @@ class BTRFSVolumeDevice(BTRFSDevice, ContainerDevice):
>  
>      def _create(self):
>          log_method_call(self, self.name, status=self.status)
> -        btrfs.create_volume(devices=[d.path for d in self.parents],
> -                            label=self.format.label,
> -                            data=self.dataLevel,
> -                            metadata=self.metaDataLevel)
> +        try:
> +            btrfs.create_volume(devices=[d.path for d in self.parents],
> +               label=self.format.label,
> +               data=self.dataLevel,
> +               metadata=self.metaDataLevel)
> +            return
> +        except errors.BTRFSError:
> +            pass
> +
> +        log.warning("failed to create device %s with specified options %s, omitting options for second attempt", self, {'label' : self.format.label, 'data' : self.dataLevel, 'metadata' : self.metaDataLevel})
I think it would be good to split this to multiple lines, it does not
fit on my 23" monitor. :)

Also any reason not to log the warnings/raise the error directly from
the exception handler ? It should work the same and you could get rid
off the pass there.

> +
> +        try:
> +            btrfs.create_volume(devices=[d.path for d in self.parents])
> +            return
> +        except errors.BTRFSError:
> +            pass
> +
> +        raise errors.DeviceCreateError("failed to create device %s on %s" % (self, [d.path for d in self.parents]))
> +
>  
>      def _postCreate(self):
>          super(BTRFSVolumeDevice, self)._postCreate()




More information about the anaconda-patches mailing list