Skip to content

Commit

Permalink
Guard better against RaidChooser's selected_level being None
Browse files Browse the repository at this point in the history
This happens more often since blivet dropped linear from mdraid
in storaged-project/blivet#1236 . It was
the only RAID level supported for mdraid that had min_members of
1. When you add the first member for a new mdraid set, of course,
there is only one member.

RaidChooser's update method checks the `min_members` on each
level and only adds it to the liststore of available levels if we
currently have at least that many members. So, before that blivet
change, when there was only one member, "linear" was the only
level in the liststore, and was necessarily the selected_level.
Now linear is gone, when there is only one member of an mdraid
set, there are *no* levels in the liststore, which means
selected_level winds up being None.

There are three places I can see in add_dialog.py which don't
guard against selected_level being None. This fixes each of them.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
  • Loading branch information
AdamWill committed Jun 5, 2024
1 parent c0ca51f commit 9958f9b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions blivetgui/dialogs/add_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,12 @@ def raid_member_max_size(self):

device_type = self.selected_type
num_parents = self._get_number_selected_parents()
level = self._raid_chooser.selected_level

if device_type not in self.supported_raids.keys() or num_parents == 1:
return (False, None)

elif self._raid_chooser.selected_level.name in ("linear", "single"):
elif level and level.name in ("linear", "single"):
return (False, None)

else:
Expand Down Expand Up @@ -863,7 +864,8 @@ def add_advanced_options(self):
self.advanced.destroy()

if device_type in ("lvm", "lvmvg", "partition", "mdraid"):
if device_type == "mdraid" and self._raid_chooser.selected_level.name == "raid1":
level = self._raid_chooser.selected_level
if device_type == "mdraid" and level and level.name == "raid1":
self.advanced = None
self.widgets_dict["advanced"] = []
else:
Expand Down Expand Up @@ -1068,7 +1070,9 @@ def get_selection(self):
encryption_selection = self._encryption_chooser.get_selection()

if device_type in ("btrfs volume", "mdraid", "lvmlv"):
raid_level = self._raid_chooser.selected_level.name
raid_level = self._raid_chooser.selected_level
if raid_level:
raid_level = raid_level.name
else:
raid_level = None

Expand Down

0 comments on commit 9958f9b

Please sign in to comment.