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

fix(Storage): fix disks view for degraded group #1930

Merged
merged 2 commits into from
Feb 17, 2025

Conversation

artemmufazalov
Copy link
Member

@artemmufazalov artemmufazalov commented Feb 11, 2025

Closes #1929

Stand with the example of degraded group: https://nda.ya.ru/t/H7kJOQl57BtQVV

CI Results

Test Status: ⚠️ FLAKY

📊 Full Report

Total Passed Failed Flaky Skipped
262 259 0 3 0

😟 No changes in tests. 😕

Bundle Size: ✅

Current: 80.33 MB | Main: 80.32 MB
Diff: +1.20 KB (0.00%)

✅ Bundle size unchanged.

ℹ️ CI Information
  • Test recordings for failed tests are available in the full report.
  • Bundle size is measured for the entire 'dist' directory.
  • 📊 indicates links to detailed reports.
  • 🔺 indicates increase, 🔽 decrease, and ✅ no change in bundle size.

const preparedPDisk = PDisk
? prepareGroupsPDisk({...PDisk, NodeId: mergedVDiskData.NodeId})
: undefined;
const preparedPDisk = prepareGroupsPDisk({...PDisk, NodeId: mergedVDiskData.NodeId});
Copy link
Member Author

Choose a reason for hiding this comment

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

Add empty PDisk object even if there is no PDisk field

@@ -89,7 +91,7 @@ function VDiskItem({
const vDiskId = vDisk.StringifiedId;

// show vdisks without AllocatedSize as having average width (#1433)
const minWidth = valueIsDefined(vDiskToShow.AllocatedSize) ? undefined : unavailableVDiskWidth;
const minWidth = isNumeric(vDiskToShow.AllocatedSize) ? undefined : unavailableVDiskWidth;
Copy link
Member Author

Choose a reason for hiding this comment

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

AllocatedSize could be numeric or NaN, but not undefined

@@ -55,7 +57,7 @@ export function Disks({vDisks = [], viewContext}: DisksProps) {
<div className={b('pdisks-wrapper')}>
{vDisks?.map((vDisk, index) => (
<PDiskItem
key={vDisk?.PDisk?.StringifiedId}
key={vDisk?.PDisk?.StringifiedId || index}
Copy link
Member Author

@artemmufazalov artemmufazalov Feb 11, 2025

Choose a reason for hiding this comment

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

There could be no proper id, use index in such case. Array index will be always different from pdisk and vdisk ids, since ids include several numbers joined by dash (e.g. "1-1001")

Copy link
Collaborator

Choose a reason for hiding this comment

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

in which cases there may be no StringifiedId and why cant we always use index

I dont mean to rework anything - I just dont understand (:

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. If there is no data about PDisk, then there would be no id, so we use index to prevent undefined ids - with undefined ids there is a bug where new disks added on every rerender
  2. Generally it's not a good practice to use indexes as keys, since they could cause some unexpected behaviour if array is reordered or some elements added or deleted (and it's not recommended in react docs). So we use unique ids everywhere where it's possible. For the case of missing vdisks' pdisks there is no much difference, since they have no data and displayed the same way

@artemmufazalov artemmufazalov marked this pull request as ready for review February 11, 2025 11:46
@@ -84,12 +85,21 @@ export function getStorageGroupsInitialEntitiesCount(
return DEFAULT_ENTITIES_COUNT;
}

export function useVDisksWithDCMargins(vDisks: PreparedVDisk[] = []) {
function isErasureWithDifferentDC(erasure?: Erasure) {
return erasure === 'mirror-3-dc' || erasure === 'mirror-3of4';
Copy link
Collaborator

@astandrik astandrik Feb 11, 2025

Choose a reason for hiding this comment

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

what do these magic constant strings mean?

comment would be nice (and may be move to actual constants)

@@ -228,6 +228,8 @@ export interface TStoragePDisk {
Whiteboard?: TPDiskStateInfo;
}

export type Erasure = 'none' | 'block-4-2' | 'mirror-3-dc' | 'mirror-3of4';
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe enum and use it in isErasureWithDifferentDC ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't like enums, you have to import them everywhere to satisfy TS, while for union string types every option will be suggested by autocomplete

@artemmufazalov artemmufazalov added this pull request to the merge queue Feb 17, 2025
Merged via the queue into main with commit a2b7d1c Feb 17, 2025
7 checks passed
@artemmufazalov artemmufazalov deleted the 1929-fix-broken-group branch February 17, 2025 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix degraded group Disks display
2 participants