Skip to content

fix(localstorage): check local capacity by disk requirements - #4669

Open
MatheMatrix wants to merge 1 commit into
5.5.38from
sync/xiangheng.zhao/fix/ZSTAC-84163-local-storage-capacity
Open

fix(localstorage): check local capacity by disk requirements#4669
MatheMatrix wants to merge 1 commit into
5.5.38from
sync/xiangheng.zhao/fix/ZSTAC-84163-local-storage-capacity

Conversation

@MatheMatrix

Copy link
Copy Markdown
Owner

Jira: ZSTAC-84163

Reason: LocalStorageAllocatorFactory used HostAllocatorSpec.getDiskSize() to pre-check each local storage host ref during VM creation. getDiskSize() represented the total size of all VM disks, so when root and data volumes could be placed on different primary storages, the local storage precheck could compare the full VM disk size against a single local primary storage and incorrectly filter out candidate hosts.

Solution: Replace the independent diskSize state with RequiredDiskCapacity entries in AllocateHostMsg and HostAllocatorSpec. VM creation records root and data disk capacity requirements with the determined primary storage UUID when available, or null when primary storage is not determined yet. LocalStorageAllocatorFactory now checks only the capacity requirements that explicitly belong to the current local primary storage, while migration keeps using getDiskSize() because it has one destination primary storage.

Change-Id: I3f9895c605819a570a580cedfeaf1d80db300c80

sync from gitlab !10722

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 12 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)

Review profile: CHILL

Plan: Pro

Run ID: fb1a3175-0c95-4cb1-a0bd-549535a6f47c

📥 Commits

Reviewing files that changed from the base of the PR and between 8948841 and 8e13bb2.

📒 Files selected for processing (6)
  • compute/src/main/java/org/zstack/compute/vm/VmAllocateHostFlow.java
  • header/src/main/java/org/zstack/header/allocator/AllocateHostMsg.java
  • header/src/main/java/org/zstack/header/allocator/HostAllocatorSpec.java
  • header/src/main/java/org/zstack/header/allocator/RequiredDiskCapacity.java
  • plugin/localstorage/src/main/java/org/zstack/storage/primary/local/LocalStorageAllocatorFactory.java
  • test/src/test/groovy/org/zstack/test/integration/storage/primary/local_nfs/allocator/host/CreateVmHostAllocateCase.groovy

Comment @coderabbitai help to get the list of available commands.

@MatheMatrix
MatheMatrix force-pushed the sync/xiangheng.zhao/fix/ZSTAC-84163-local-storage-capacity branch 4 times, most recently from aed0cda to 4c0b75f Compare August 13, 2026 09:55
Reason: LocalStorageAllocatorFactory used HostAllocatorSpec.getDiskSize() to pre-check each local storage host ref during VM creation. getDiskSize() represented the total size of all VM disks, so when root and data volumes could be placed on different primary storages, the local storage precheck could compare the full VM disk size against a single local primary storage and incorrectly filter out candidate hosts.

The opposite case also needs to be handled: when a disk has no determined primary storage but the candidate host has only one accessible primary storage and it is local storage, the disk can only be placed on that local storage. Skipping it from the precheck may let a local-capacity-insufficient host pass host allocation and fail later in primary storage allocation.

Solution: Replace the independent diskSize state with RequiredDiskCapacity entries in AllocateHostMsg and HostAllocatorSpec. VM creation records root and data disk capacity requirements with the determined primary storage UUID when available, or null when primary storage is not determined yet.

LocalStorageAllocatorFactory now checks capacity requirements that explicitly belong to the current local primary storage. For undetermined requirements, it counts them only when the current local primary storage is the host's only accessible primary storage. Migration keeps using getDiskSize() because it has one destination primary storage.

Resolves: ZSTAC-84163

Change-Id: I3f9895c605819a570a580cedfeaf1d80db300c80
@MatheMatrix
MatheMatrix force-pushed the sync/xiangheng.zhao/fix/ZSTAC-84163-local-storage-capacity branch from 4c0b75f to 8e13bb2 Compare August 13, 2026 10:06
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.

1 participant