[blivet:master 10/11] Fall back to accepting defaults if btrfs creation fails (#1109195)
Brian C. Lane
bcl at redhat.com
Wed Jun 18 00:46:40 UTC 2014
On Tue, Jun 17, 2014 at 11:08:01AM -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)
Please indent this one as well.
> + 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})
> +
> + 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]))
> +
I agree with mkolman that moving the log.warning and raise inside the
except: blocks is cleaner. Still feels kinda weird returning from inside
the try but the only other option is a try/else which doesn't seem like
an improvement.
--
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
More information about the anaconda-patches
mailing list