Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-117805 / 22.12 / Adding warnings for unused disks with exported pools #7078

Merged
merged 43 commits into from
Sep 23, 2022

Conversation

RehanY147
Copy link
Contributor

@RehanY147 RehanY147 commented Sep 13, 2022

This PR aims to add warnings for wherever UI is dealing with unused disks that are currently also part of exported pools. Test the following places in the UI.

  • When creating a new pool or adding a disk to an existing pool, the ManagerComponent should show the following warnings for such disks
    Name of the exported pool that's attached to the disk mentioned in the table like so
    image
    Also, when you click the checkbox to select this disk, you should see the warning like this
    image
    Select/unselect a bunch of disks to check that the warning is only shown for the correct disks
  • On the new Storage Dashboard, when you click Add to Pool button on the unused disks card, the model opens up. On the model, disks that are attached to exported pools should be separate from other disks of similar size and properties with a warning underneath as in the screenshot.
    image
  • On the Extend and Replace buttons for ZFS Info cards on the new Devices page and Replace and Attach operations on the Boot Pool Status page, you see a modal where you can select a disk from a drop down. Disks with exported pools should have the exported pools name mentioned in the select.
    image
    Also, if you select such a disk/vdev from the drop down, you should see a warning.
    image
  • On the Disks page, you should see the name of the exported pool in the Pool column of such disks with the text '(Exported)' appended.
    image
    if you select to Wipe such a disk, you should see a confirmation dialog.
    image

@RehanY147 RehanY147 requested a review from a team as a code owner September 13, 2022 14:21
@RehanY147 RehanY147 requested review from bvasilenko and removed request for a team September 13, 2022 14:21
@bugclerk bugclerk changed the title Adding warnings for unused disks with exported pools NAS-117805 / 22.12 / Adding warnings for unused disks with exported pools Sep 13, 2022
@bugclerk
Copy link
Contributor

@codecov
Copy link

codecov bot commented Sep 13, 2022

Codecov Report

Merging #7078 (24cf47c) into master (c02594c) will increase coverage by 0.06%.
The diff coverage is 86.81%.

@@            Coverage Diff             @@
##           master    #7078      +/-   ##
==========================================
+ Coverage   41.24%   41.30%   +0.06%     
==========================================
  Files        1049     1051       +2     
  Lines       46107    46183      +76     
  Branches     6406     6415       +9     
==========================================
+ Hits        19017    19078      +61     
- Misses      27090    27105      +15     
Impacted Files Coverage Δ
...rc/app/helptext/storage/volumes/manager/manager.ts 100.00% <ø> (+100.00%) ⬆️
src/app/interfaces/storage.interface.ts 100.00% <ø> (ø)
...ed-pools-dialog/exported-pools-dialog.component.ts 0.00% <0.00%> (ø)
src/app/pages/storage/storage.module.ts 0.00% <0.00%> (ø)
src/app/views/sessions/signin/signin.component.ts 0.00% <0.00%> (ø)
...disk-dialog/manage-unused-disk-dialog.component.ts 92.15% <80.00%> (-3.40%) ⬇️
...info-card/extend-dialog/extend-dialog.component.ts 88.52% <92.30%> (+0.76%) ⬆️
...t-pool-replace/boot-pool-replace-form.component.ts 87.03% <93.33%> (+1.32%) ⬆️
...oot-pool-attach/boot-pool-attach-form.component.ts 79.66% <95.00%> (+5.24%) ⬆️
...place-disk-dialog/replace-disk-dialog.component.ts 97.95% <95.83%> (-2.05%) ⬇️
... and 5 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@undsoft undsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In manager selecting disk always shows warning despite the code that should prevent it. On the other hand selecting multiple disks via select all checkbox doesn't show a warning.

@@ -72,4 +72,6 @@ export default {
err_title: T('Error Extending Vdev'),
err_msg: T('Could not extend Vdev.'),
},
exported_pool_warning: T('This disk is part of the exported pool {pool}. Adding this disk to a new or existing pool will make {pool} unable to import. You will lose any and all data in {pool}. Please make sure you have backed up any sensitive data in {pool} before reusing/repurposing this disk.'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we have it in one file only? If you really have to use separate files, you can make one file reference another.

@@ -136,6 +136,7 @@ export interface UnusedDisk extends Disk {
partitions: {
path: string;
}[];
exported_zpool?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is field really optional?

this.selected.splice(0, this.selected.length);
this.selected.push(...selected);
}

handleWarningAboutExportedPoolDisks(selectedDisks: ManagerDisk[]): void {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just because it's okay to write longer names, doesn't mean that we should write them longer on purpose :)

handleWarningAboutExportedPoolDisks => warnAboutExportedPool

showWarningAboutExportedPoolForDisk => can be inlined and handleWarningAboutExportedPoolDisks can be changed early to return if no warning is necessary.

shouldWarnAboutExportedPoolForLastSelectedDisk => shouldWarnAboutExportedPool or hasExportedPoolWarning

}

updateDisksWithExportedPoolWarningFlags(selectedDisks: ManagerDisk[]): void {
const selectedDisksWithExportedPoolsAttached = selectedDisks.filter((selectedDisk) => selectedDisk.exported_zpool);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updateDisksWithExportedPoolWarningFlags => updateExportedWarningFlags or rememberExportedWarnings or markExportedWarning.

selectedDisksWithExportedPoolsAttached => disksWithPools there is enough context.

disksNamesWithExportedPoolsAlreadyWarnedFor => exportedPoolWarningsShown or even exportedWarningsShown

@@ -27,7 +27,7 @@
<ng-template #poolContainer>
<div fxFlex="100%" fxLayout="column">
<!-- TODO: https://ixsystems.atlassian.net/browse/NAS-117820 -->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment can be removed.

this.matDialog.open(DiskWipeDialogComponent, {
data: disk.name,
});
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it may be better to put this login into DiskWipeDialog and show a line somewhere there to avoid adding too many responsibilities to this component.

}));
}

getExportedPoolNameForDiskIfApplicable(disk: Disk): string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getPoolColumn with disk.pool being used here as well

unusedDisks$ = this.ws.call('disk.get_unused').pipe(
tap((unusedDisks) => {
this.unusedDisks = unusedDisks;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unexpected side-effect - unusedDisks$ now has two responsibilities.
You should remove both of these and a new loadUnusedDisks method in ngOnInit.

);
}

warnAboutExportedPoolForUnusedDiskIfNeeded = (diskIdentifier: string): void => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same notes about extra functions, long names and template strings.

isFormLoading = false;

form = this.fb.group({
dev: ['', Validators.required],
expand: [false],
});

unusedDisks: UnusedDisk[] = [];

dev = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

@RehanY147
Copy link
Contributor Author

The check to not show warning is there to avoid showing warning for a disk that was already selected. If the disk is unchecked and then checked again, showing the warning again.

Copy link
Collaborator

@undsoft undsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace disk dialog seems to be broken.

Copy link
Contributor

@bvasilenko bvasilenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works good for me!

Just one minor observation: it's still possible to bypass the warning if user clicks Suggest Layout button:

Sep-18-2022.14-16-14.mp4

Copy link
Collaborator

@undsoft undsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

@RehanY147 RehanY147 merged commit 8abcf73 into master Sep 23, 2022
@RehanY147 RehanY147 deleted the NAS-117805 branch September 23, 2022 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants