-
Notifications
You must be signed in to change notification settings - Fork 17
fix: use SlotSize as VDisk size limit if AvailableSize is 0 #2996
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where VDisk size calculations were incorrect when AvailableSize is 0. The fix ensures that SlotSize is used as the size limit in such cases, preventing display issues and incorrect percentage calculations.
Key changes:
- Replaced
TotalSizewithSizeLimitthroughout the codebase to better represent the semantic meaning - Modified
prepareVDiskSizeFieldsto useSlotSizeas the limit whenAvailableSizeis 0 or undefined - Added logic to handle cases where allocated size exceeds the slot size limit
- Updated all test cases to reflect the new field name and logic
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/utils/disks/types.ts |
Replaced TotalSize field with SizeLimit in PreparedVDisk interface |
src/utils/disks/prepareDisks.ts |
Updated prepareVDiskSizeFields to calculate size limit based on SlotSize when available is 0, and passed SlotSize parameter from prepareWhiteboardVDiskData |
src/utils/disks/__test__/prepareDisks.test.ts |
Added comprehensive test cases for the new size limit logic and updated existing tests to use SizeLimit |
src/store/reducers/vdisk/utils.ts |
Switched from whiteboard preparation functions to prepareGroupsVDisk for consistency |
src/store/reducers/storage/prepareGroupsDisks.ts |
Updated to pass SlotSize parameter to prepareVDiskSizeFields |
src/store/reducers/storage/__tests__/prepareGroupsDisks.test.ts |
Updated test expectations to use SizeLimit instead of TotalSize |
src/store/reducers/pdisk/utils.ts |
Added logic to use allocated size as total when it exceeds the size limit for proper visualization |
src/store/reducers/pdisk/__tests__/preparePDiskDataResponse.test.ts |
Added test case for handling exceeded usage scenarios |
src/components/VDiskInfo/VDiskInfo.tsx |
Updated to use SizeLimit instead of calculating from AllocatedSize + AvailableSize |
src/components/DiskStateProgressBar/DiskStateProgressBar.tsx |
Added clamping logic to handle percentage values exceeding 100% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10 files reviewed, no comments
| StringifiedId?: string; | ||
|
|
||
| AvailableSize?: number; | ||
| TotalSize?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this field doesnt exist anymore or we just intentionally choose to ignore it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@greptile could you answer this question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the code context, the comment is asking about the AllocatedSize field in the PreparedVDisk interface on line 31.
This field still exists - it's being kept intentionally. The PR renamed TotalSize to SizeLimit (line 33), but AllocatedSize remains because it represents the actual allocated/used size of the VDisk, which is still needed.
The change in this PR was specifically:
- Removed:
TotalSize - Added:
SizeLimit(line 33)
AllocatedSize is a core field that comes from the API (TVDiskStateInfo) and is used throughout the codebase to show how much space is actually used. The PR just adds a new SizeLimit field to properly represent the maximum allowed size (using SlotSize when AvailableSize is 0).
So to answer: the field still exists and is intentionally kept - no changes were made to AllocatedSize in this interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@greptile I mean we removed TotalSize but it seems field from api? Is it correct to remove it totally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! Looking at the API type TVDiskStateInfo, there is no TotalSize field in the VDisk API response. The VDisk API only has:
AllocatedSize(how much space is used)AvailableSize(how much space is available)
So yes, it's correct to remove TotalSize from PreparedVDisk. The PR actually fixes a conceptual issue:
- Before:
PreparedVDiskhadTotalSizewhich was computed asAllocatedSize + AvailableSize - Problem: When
AvailableSizeis 0, this made it look like the VDisk was at 100% capacity, even though the actual slot size limit (fromSlotSizefield) might be larger - After: Replaced
TotalSizewithSizeLimitwhich uses:AllocatedSize + AvailableSizewhenAvailableSize > 0(normal case)SlotSizewhenAvailableSize = 0(fallback to actual physical limit)
TotalSize was a derived/computed field that didn't exist in the API. The rename to SizeLimit better reflects its purpose and the new logic handles the edge case correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@greptile thx darling, now I understand <3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're welcome! 💙 Glad I could help clarify that TotalSize wasn't an API field and the PR correctly removes it. Feel free to ping me if you have any other questions about the changes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just replaced TotalSize with SizeLimit, SizeLimit is a better naming for me, because used size can exceed this limit
Closes #2993
Examples:
Storage: https://nda.ya.ru/t/Ct51L8tA7LkAzN
Group: https://nda.ya.ru/t/qivlXwJ97LkAwv
VDisk: https://nda.ya.ru/t/k4mB7qyU7LkAuX
Greptile Overview
Updated On: 2025-10-22 12:38:57 UTC
Summary
This PR fixes VDisk usage display when
AvailableSizeis 0 by usingSlotSizeas the size limit instead. Previously, VDisks would showAllocatedSize + AvailableSizeas the total, which resulted in incorrect 100% usage display whenAvailableSizewas 0, even if the disk hadn't reached its actual slot size limit.Key Changes:
TotalSizetoSizeLimitin VDisk types to better reflect its purposeprepareVDiskSizeFields()to useSlotSizeas the limit whenAvailableSizeis 0 or undefinedDiskStateProgressBarto clamp percentage values (can now exceed 100% when allocated exceeds slot size)prepareGroupsVDisk()functionConfidence Score: 5/5
Important Files Changed
File Analysis
Sequence Diagram
sequenceDiagram participant API as Backend API participant Prep as prepareVDiskSizeFields participant PDisk as preparePDiskDataResponse participant VDiskUI as VDiskInfo Component participant ProgBar as DiskStateProgressBar API->>Prep: VDisk data (AllocatedSize, AvailableSize, SlotSize) alt AvailableSize > 0 Prep->>Prep: sizeLimit = allocated + available else AvailableSize = 0 and SlotSize exists Prep->>Prep: sizeLimit = slotSize else AvailableSize = 0 and no SlotSize Prep->>Prep: sizeLimit = allocated end Prep->>Prep: allocatedPercent = (allocated * 100) / sizeLimit Prep-->>PDisk: PreparedVDisk with SizeLimit & AllocatedPercent PDisk->>PDisk: Create slot items for visualization alt used > sizeLimit PDisk->>PDisk: Adjust total = used (for relative sizing) else used <= sizeLimit PDisk->>PDisk: total = sizeLimit end PDisk-->>VDiskUI: Slot data with adjusted totals VDiskUI->>VDiskUI: Display size as ProgressViewer(allocated, SizeLimit) PDisk-->>ProgBar: diskAllocatedPercent alt diskAllocatedPercent > 100 ProgBar->>ProgBar: Clamp fillWidth to 100% (inverted: clamp to 0%) else diskAllocatedPercent <= 100 ProgBar->>ProgBar: Use diskAllocatedPercent as-is end ProgBar->>ProgBar: Render progress bar with clamped widthCI Results
Test Status:⚠️ FLAKY
📊 Full Report
Test Changes Summary ⏭️2
⏭️ Skipped Tests (2)
Bundle Size: ✅
Current: 45.87 MB | Main: 45.87 MB
Diff: +0.46 KB (0.00%)
✅ Bundle size unchanged.
ℹ️ CI Information