Skip to content

Commit

Permalink
Merge pull request #4881 from KKoukiou/webui-disk-selection-changed-p…
Browse files Browse the repository at this point in the history
…artitioning

webui: if device selection changed since last partitioning request redo the partitioning
  • Loading branch information
KKoukiou authored Jul 6, 2023
2 parents 84638c2 + d6d3677 commit 3e2c1a9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ui/webui/src/components/AnacondaWizard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const AnacondaWizard = ({ dispatch, storageData, localizationData, onAddE
label: _("Storage configuration")
}, {
component: CustomMountPoint,
data: { deviceData: storageData.devices, partitioningData: lastPartitioning, dispatch },
data: { deviceData: storageData.devices, diskSelection: storageData.diskSelection, partitioningData: lastPartitioning, dispatch },
id: "custom-mountpoint",
label: _("Custom mount point"),
isHidden: storageScenarioId !== "custom-mount-point"
Expand Down
11 changes: 8 additions & 3 deletions ui/webui/src/components/storage/CustomMountPoint.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const MountpointCheckbox = ({ reformat, isRootMountPoint, handleCheckReFormat, p
);
};

export const CustomMountPoint = ({ deviceData, partitioningData, dispatch, idPrefix, setIsFormValid, onAddErrorNotification, toggleContextHelp, stepNotification }) => {
export const CustomMountPoint = ({ deviceData, diskSelection, partitioningData, dispatch, idPrefix, setIsFormValid, onAddErrorNotification, toggleContextHelp, stepNotification }) => {
const [creatingPartitioning, setCreatingPartitioning] = useState(true);
useEffect(() => {
const validateMountPoints = requests => {
Expand All @@ -131,8 +131,13 @@ export const CustomMountPoint = ({ deviceData, partitioningData, dispatch, idPre
validateMountPoints(partitioningData?.requests);
}, [partitioningData?.requests, setIsFormValid]);

// If device selection changed since the last partitioning request redo the partitioning
const selectedDevicesPaths = diskSelection.selectedDisks.map(d => deviceData[d].path.v) || [];
const partitioningDevicesPaths = partitioningData?.requests.map(r => r["device-spec"]) || [];
const canReusePartitioning = selectedDevicesPaths.length === partitioningDevicesPaths.length && selectedDevicesPaths.every(d => partitioningDevicesPaths.includes(d));

useEffect(() => {
if (partitioningData?.method === "MANUAL") {
if (canReusePartitioning) {
setCreatingPartitioning(false);
} else {
/* Reset the bootloader drive before we schedule partitions
Expand All @@ -145,7 +150,7 @@ export const CustomMountPoint = ({ deviceData, partitioningData, dispatch, idPre
.then(() => createPartitioning({ method: "MANUAL" }))
.then(() => setCreatingPartitioning(false));
}
}, [partitioningData?.method]);
}, [canReusePartitioning]);

if (creatingPartitioning) {
return <EmptyStatePanel loading />;
Expand Down
21 changes: 20 additions & 1 deletion ui/webui/test/check-storage
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@ class TestStorageMountPoints(anacondalib.VirtInstallMachineCase):
def check_format_type(self, row, format_type):
self.browser.wait_in_text(f"#custom-mountpoint-table tbody tr:nth-child({row}) td[data-label='Format type']", format_type)

def check_partition(self, row, partition):
self.browser.wait_in_text(f"#custom-mountpoint-table tbody tr:nth-child({row}) td[data-label='Partition']", partition)

def select_reformat(self, row):
self.browser.set_checked(f"#custom-mountpoint-table tbody tr:nth-child({row}) td[data-label='Reformat'] input", True)

Expand Down Expand Up @@ -536,18 +539,34 @@ class TestStorageMountPoints(anacondalib.VirtInstallMachineCase):
self.udevadm_settle()

partitions = {}
partitions[disk1] = [f"{disk1}2", f"{disk1}3"]

# Select first only vdb disk and verify that the partitioning request is correct
partitions[disk2] = [f"{disk2}1"]
self.select_mountpoint(i, s, [disk2], partitions)

self.check_partition(1, "/dev/vdb1")

# Go back and change the disk selection. The partitioning should be re-created
b.click("button:contains(Back)")
b.click("button:contains(Back)")
b.click("button:contains(Back)")

partitions[disk1] = [f"{disk1}2", f"{disk1}3"]
self.select_mountpoint(i, s, [disk1, disk2], partitions)

self.check_partition(1, "/dev/vda1")

self.check_partition(2, "/dev/vda2")
self.check_format_type(2, "xfs")
self.select_from_dropdown(2, "boot", "/boot")
self.check_reformat(2, False)

self.check_partition(3, "/dev/vda3")
self.check_format_type(3, "xfs")
self.select_from_dropdown(3, "root", "/")
self.check_reformat(3, True)

self.check_partition(4, "/dev/vdb1")
self.check_format_type(4, "xfs")
self.select_from_dropdown(4, "home", "/home")
self.check_reformat(4, False)
Expand Down

0 comments on commit 3e2c1a9

Please sign in to comment.