Skip to content

<fix>[localstorage]: ZSTAC-84163 check capacity by target primary storage - #4689

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

<fix>[localstorage]: ZSTAC-84163 check capacity by target primary storage#4689
MatheMatrix wants to merge 1 commit into
5.5.38from
sync/xiangheng.zhao/fix/ZSTAC-84163-local-storage-capacity@@2

Conversation

@MatheMatrix

Copy link
Copy Markdown
Owner

Root Cause:
LocalStorageAllocatorFactory used HostAllocatorSpec.getDiskSize() to check every local storage host ref. The value was the total size of root and data disks, so disks assigned to non-local primary storage were also counted against local storage and could incorrectly filter out a valid host.

Solution:
Carry root and data disk capacity requirements as primary-storage UUID and size tuples. Local storage sums requirements assigned to the current local primary storage. If any requirement has no determined primary storage and the host cluster only attaches local storage, retain the conservative total-size check. Migration uses the same per-primary-storage calculation because its producer records the destination primary storage with the migration capacity.

Test:
Update CreateVmHostAllocateCase to cover insufficient all-local capacity, mixed local/NFS placement, and partially undetermined primary storage.

Verified with:
Not run as requested.

Resolves: ZSTAC-84163

Change-Id: I3f9895c605819a570a580cedfeaf1d80db300c80

sync from gitlab !10742

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 54 minutes.

View limit details

Limit details: You’ve used the included review currently available. Your 98 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

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).

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 58b84178-ffa7-4ab5-a6fe-d93e1683022a

📥 Commits

Reviewing files that changed from the base of the PR and between fd74d8c and ce94ff0.

📒 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

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

Parsing errors (1)
Could not fetch remote config from http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml: TimeoutError: The operation timed out.
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

@MatheMatrix
MatheMatrix force-pushed the sync/xiangheng.zhao/fix/ZSTAC-84163-local-storage-capacity@@2 branch 2 times, most recently from ddad333 to f01e018 Compare August 19, 2026 08:20
@ZStack-Robot

Copy link
Copy Markdown
Collaborator

Comment on plugin/localstorage/src/main/java/org/zstack/storage/primary/local/LocalStorageAllocatorFactory.java:

Comment from jin.ma:

写C语言呢?

@MatheMatrix

Copy link
Copy Markdown
Owner Author

Comment on plugin/localstorage/src/main/java/org/zstack/storage/primary/local/LocalStorageAllocatorFactory.java:

Comment from jin.ma:

不要 bool 当参数

…rage

Root Cause:
LocalStorageAllocatorFactory used HostAllocatorSpec.getDiskSize() to check every local storage host ref. The value was the total size of root and data disks, so disks assigned to non-local primary storage were also counted against local storage and could incorrectly filter out a valid host.

Solution:
Carry each disk capacity requirement with its primary-storage UUID. Check only capacities assigned to the current local primary storage; when a host is attached only to local storage, also include disks whose primary storage is undetermined. Keep the host classification and capacity calculation together in LocalStorageAllocatorFactory.

Test:
Update CreateVmHostAllocateCase to cover insufficient all-local capacity, mixed local/NFS placement, and partially undetermined primary storage. Verify the existing one-primary-storage creation scenario.

Verified with:
./runMavenProfile premium
mvn test -Dtest=CreateVmHostAllocateCase -DskipJacoco=true -Dmanagement.server.ip=127.0.0.1 -Dsurefire.useFile=false
mvn test -Dtest=OnePsCreateVmCase -DskipJacoco=true -Dmanagement.server.ip=127.0.0.1 -Dsurefire.useFile=false

Resolves: ZSTAC-84163

Change-Id: I3f9895c605819a570a580cedfeaf1d80db300c80
@MatheMatrix
MatheMatrix force-pushed the sync/xiangheng.zhao/fix/ZSTAC-84163-local-storage-capacity@@2 branch from f01e018 to ce94ff0 Compare August 26, 2026 10:29
@ZStack-Robot

Copy link
Copy Markdown
Collaborator

Comment on plugin/localstorage/src/main/java/org/zstack/storage/primary/local/LocalStorageAllocatorFactory.java:

Comment from 赵祥亨:

去掉了

@MatheMatrix

Copy link
Copy Markdown
Owner Author

Comment on plugin/localstorage/src/main/java/org/zstack/storage/primary/local/LocalStorageAllocatorFactory.java:

Comment from 赵祥亨:

改了

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.

2 participants