forked from zstackio/zstack
-
Notifications
You must be signed in to change notification settings - Fork 0
<fix>[storage]: ZSTAC-84163 local PS capacity excludes non-local data disk #4364
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
Open
ZStack-Robot
wants to merge
1
commit into
5.5.28
Choose a base branch
from
sync/jin.ma/fix/ZSTAC-84163
base: 5.5.28
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
...on/storage/primary/local_nfs/allocator/host/CreateVmDataDiskOnNfsLocalCapacityCase.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| package org.zstack.test.integration.storage.primary.local_nfs.allocator.host | ||
|
|
||
| import org.zstack.compute.vm.VmSystemTags | ||
| import org.zstack.sdk.* | ||
| import org.zstack.test.integration.storage.StorageTest | ||
| import org.zstack.testlib.EnvSpec | ||
| import org.zstack.testlib.SubCase | ||
| import org.zstack.utils.data.SizeUnit | ||
|
|
||
| /** | ||
| * Regression: mixed storage. Root volume on local PS (fits), data volumes on NFS. | ||
| * Local PS host capacity only fits root; LocalStorageAllocatorFactory must NOT | ||
| * sum root+data (200G) against local host ref, otherwise NO_AVAILABLE_HOST is | ||
| * wrongly raised. See "no hosts with enough disk capacity[214748364800 bytes]". | ||
| */ | ||
| class CreateVmDataDiskOnNfsLocalCapacityCase extends SubCase { | ||
| EnvSpec env | ||
|
|
||
| @Override | ||
| void setup() { | ||
| useSpring(StorageTest.springSpec) | ||
| } | ||
|
|
||
| @Override | ||
| void environment() { | ||
| env = env { | ||
| instanceOffering { | ||
| name = "instanceOffering" | ||
| memory = SizeUnit.GIGABYTE.toByte(1) | ||
| cpu = 1 | ||
| } | ||
|
|
||
| diskOffering { | ||
| name = "rootDisk" | ||
| diskSize = SizeUnit.GIGABYTE.toByte(40) | ||
| } | ||
|
|
||
| diskOffering { | ||
| name = "dataDisk" | ||
| diskSize = SizeUnit.GIGABYTE.toByte(80) | ||
| } | ||
|
|
||
| sftpBackupStorage { | ||
| name = "sftp" | ||
| url = "/sftp" | ||
| username = "root" | ||
| password = "password" | ||
| hostname = "localhost" | ||
|
|
||
| image { | ||
| name = "image" | ||
| url = "http://zstack.org/download/test.qcow2" | ||
| format = "raw" | ||
| mediaType = "ISO" | ||
| size = 0 | ||
| } | ||
| } | ||
|
|
||
| zone { | ||
| name = "zone" | ||
| description = "test" | ||
|
|
||
| cluster { | ||
| name = "cluster" | ||
| hypervisorType = "KVM" | ||
|
|
||
| kvm { | ||
| name = "kvm" | ||
| managementIp = "localhost" | ||
| username = "root" | ||
| password = "password" | ||
| totalCpu = 88 | ||
| totalMem = SizeUnit.GIGABYTE.toByte(100) | ||
| } | ||
|
|
||
| attachPrimaryStorage("local") | ||
| attachPrimaryStorage("nfs") | ||
| attachL2Network("l2") | ||
| } | ||
|
|
||
| nfsPrimaryStorage { | ||
| name = "nfs" | ||
| url = "172.20.0.1:/nfs_root" | ||
| totalCapacity = SizeUnit.GIGABYTE.toByte(1000) | ||
| availableCapacity = SizeUnit.GIGABYTE.toByte(1000) | ||
| } | ||
|
|
||
| localPrimaryStorage { | ||
| name = "local" | ||
| url = "/local_ps" | ||
| totalCapacity = SizeUnit.GIGABYTE.toByte(50) | ||
| availableCapacity = SizeUnit.GIGABYTE.toByte(50) | ||
| } | ||
|
|
||
| l2NoVlanNetwork { | ||
| name = "l2" | ||
| physicalInterface = "eth0" | ||
|
|
||
| l3Network { | ||
| name = "l3" | ||
|
|
||
| ip { | ||
| startIp = "12.16.10.10" | ||
| endIp = "12.16.10.100" | ||
| netmask = "255.255.255.0" | ||
| gateway = "12.16.10.1" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| attachBackupStorage("sftp") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| void test() { | ||
| env.create { | ||
| testCreateVmRootLocalDataNfs() | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| void clean() { | ||
| env.delete() | ||
| } | ||
|
|
||
| void testCreateVmRootLocalDataNfs() { | ||
| InstanceOfferingInventory instanceOffering = env.inventoryByName("instanceOffering") as InstanceOfferingInventory | ||
| DiskOfferingInventory rootDisk = env.inventoryByName("rootDisk") as DiskOfferingInventory | ||
| DiskOfferingInventory dataDisk = env.inventoryByName("dataDisk") as DiskOfferingInventory | ||
| ImageInventory image = env.inventoryByName("image") as ImageInventory | ||
| L3NetworkInventory l3 = env.inventoryByName("l3") as L3NetworkInventory | ||
| HostInventory host = env.inventoryByName("kvm") | ||
| PrimaryStorageInventory nfs = env.inventoryByName("nfs") | ||
| PrimaryStorageInventory local = env.inventoryByName("local") | ||
|
|
||
| CreateVmInstanceAction a = new CreateVmInstanceAction( | ||
| name: "mixed", | ||
| instanceOfferingUuid: instanceOffering.uuid, | ||
| imageUuid: image.uuid, | ||
| l3NetworkUuids: [l3.uuid], | ||
| hostUuid: host.uuid, | ||
| rootDiskOfferingUuid: rootDisk.uuid, | ||
| dataDiskOfferingUuids: [dataDisk.uuid, dataDisk.uuid], | ||
| primaryStorageUuidForRootVolume: local.uuid, | ||
| systemTags: [VmSystemTags.PRIMARY_STORAGE_UUID_FOR_DATA_VOLUME.instantiateTag( | ||
| [(VmSystemTags.PRIMARY_STORAGE_UUID_FOR_DATA_VOLUME_TOKEN): nfs.uuid])], | ||
| sessionId: currentEnvSpec.session.uuid | ||
| ) | ||
|
|
||
| CreateVmInstanceAction.Result r = a.call() | ||
| assert r.error == null: | ||
| "root(40G) on local(50G), data(160G) on nfs: local capacity check wrongly summed root+data " + | ||
| "and raised NO_AVAILABLE_HOST. error=${r.error}" | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
localStorageDiskSize仍然漏掉了“按数据盘分别选主存储”的路径。Line 67 这里只看单个
spec.getRequiredPrimaryStorageUuidForDataVolume(),但同一个prepareMsg()在 Line 139-154 已经支持多候选 data PS 以及APICreateVmInstanceMsg.DiskAO.primaryStorageUuid。这样一来,只要一次创建里部分数据盘落在 local、部分落在 NFS,这里的本地容量还是会被按“全算/全不算”处理,继续把 mixed-storage 请求误判为NO_AVAILABLE_HOST(或反向少算)。这里需要按每块数据盘的目标 PS 逐个累加本地容量,而不是依赖单个 data-volume PS 提示。🤖 Prompt for AI Agents