-
Notifications
You must be signed in to change notification settings - Fork 0
<fix>[volume]: optimization of Local and NFS Storage Provisioning #2990
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
base: zsv_4.10.28
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,8 @@ | |
| import org.zstack.header.vm.VmInstanceConstant.VmOperation; | ||
| import org.zstack.header.volume.*; | ||
| import org.zstack.kvm.KVMConstant; | ||
| import org.zstack.resourceconfig.ResourceConfig; | ||
| import org.zstack.resourceconfig.ResourceConfigFacade; | ||
| import org.zstack.storage.primary.PrimaryStorageCapacityChecker; | ||
|
Comment on lines
+50
to
52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LocalStorage qcow2 预分配改为 ResourceConfig 驱动, fallback 建议改用运行时 GlobalConfig 值 整体逻辑没问题:
需要注意的是 fallback 分支当前使用的是编译期默认值: String psPreallocation = rcf.getResourceConfigValueByResourceType(
LocalStoragePrimaryStorageGlobalConfig.QCOW2_ALLOCATION,
msg.getVolume().getPrimaryStorageUuid(), PrimaryStorageVO.class.getSimpleName(), String.class);
if (psPreallocation == null) {
psPreallocation = LocalStoragePrimaryStorageGlobalConfig.QCOW2_ALLOCATION.getDefaultValue();
}这会忽略管理员在运行时通过 GlobalConfig API 修改 建议这里改为使用运行时全局值作为最终 fallback,例如: - if (psPreallocation == null) {
- psPreallocation = LocalStoragePrimaryStorageGlobalConfig.QCOW2_ALLOCATION.getDefaultValue();
- }
+ if (psPreallocation == null) {
+ // 使用运行时全局配置值作为最终 fallback, 保持与现有 GlobalConfig 语义一致
+ psPreallocation = LocalStoragePrimaryStorageGlobalConfig.QCOW2_ALLOCATION.value(String.class);
+ }同时建议在 NFS/SMP 的对应逻辑中做同样调整,以保证三种主存储的 qcow2 预分配在 “卷级 > PS 级 > 全局级” 三层 fallback 语义上一致。 Also applies to: 107-108, 270-284 |
||
| import org.zstack.storage.snapshot.PostMarkRootVolumeAsSnapshotExtension; | ||
| import org.zstack.storage.snapshot.reference.VolumeSnapshotReferenceUtils; | ||
|
|
@@ -60,6 +62,7 @@ | |
| import java.util.concurrent.TimeUnit; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import static org.zstack.compute.vm.VmCpuVendor.AuthenticAMD; | ||
| import static org.zstack.core.Platform.argerr; | ||
| import static org.zstack.core.Platform.err; | ||
| import static org.zstack.core.Platform.operr; | ||
|
|
@@ -101,6 +104,8 @@ public boolean isSupportVmLiveMigration() { | |
| private CloudBus bus; | ||
| @Autowired | ||
| private ErrorFacade errf; | ||
| @Autowired | ||
| private ResourceConfigFacade rcf; | ||
|
|
||
| private Map<String, LocalStorageBackupStorageMediator> backupStorageMediatorMap = new HashMap<String, LocalStorageBackupStorageMediator>(); | ||
|
|
||
|
|
@@ -261,11 +266,21 @@ public void afterInstantiateVolume(InstantiateVolumeOnPrimaryStorageMsg msg) { | |
| hasBackingFile = true; | ||
| } | ||
| } | ||
|
|
||
| VolumeInventory volume = msg.getVolume(); | ||
| volume.setPrimaryStorageUuid(msg.getPrimaryStorageUuid()); | ||
| for (CreateQcow2VolumeProvisioningStrategyExtensionPoint exp : pluginRgty.getExtensionList(CreateQcow2VolumeProvisioningStrategyExtensionPoint.class)) { | ||
| exp.saveQcow2VolumeProvisioningStrategy(volume, hasBackingFile); | ||
|
|
||
| String preallocation = rcf.getResourceConfigValueByResourceType(LocalStoragePrimaryStorageGlobalConfig.QCOW2_ALLOCATION, | ||
| msg.getVolume().getUuid(), VolumeVO.class.getSimpleName(), String.class); | ||
| if (preallocation != null) { | ||
| return; | ||
| } | ||
|
|
||
| if (hasBackingFile) { | ||
| ResourceConfig rc = rcf.getResourceConfig(LocalStoragePrimaryStorageGlobalConfig.QCOW2_ALLOCATION.getIdentity()); | ||
| String psPreallocation = rcf.getResourceConfigValueByResourceType(LocalStoragePrimaryStorageGlobalConfig.QCOW2_ALLOCATION, | ||
| msg.getVolume().getPrimaryStorageUuid(), PrimaryStorageVO.class.getSimpleName(), String.class); | ||
| if (psPreallocation == null) { | ||
| psPreallocation = LocalStoragePrimaryStorageGlobalConfig.QCOW2_ALLOCATION.getDefaultValue(); | ||
| } | ||
| rc.updateValue(msg.getVolume().getUuid(), psPreallocation); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,8 @@ | |
| import org.zstack.header.vo.ResourceVO; | ||
| import org.zstack.header.volume.*; | ||
| import org.zstack.kvm.KVMConstant; | ||
| import org.zstack.resourceconfig.ResourceConfig; | ||
| import org.zstack.resourceconfig.ResourceConfigFacade; | ||
| import org.zstack.storage.primary.ChangePrimaryStorageStatusMsg; | ||
|
Comment on lines
+43
to
45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NFS qcow2 预分配改为 ResourceConfig 流程合理, 建议修正 fallback 以尊重运行时全局配置 在 NFS factory 中引入 需要注意的是, 这里的 PS 级 fallback 同样使用了默认值: String psPreallocation = rcf.getResourceConfigValueByResourceType(
NfsPrimaryStorageGlobalConfig.QCOW2_ALLOCATION,
msg.getVolume().getPrimaryStorageUuid(), PrimaryStorageVO.class.getSimpleName(), String.class);
if (psPreallocation == null) {
psPreallocation = NfsPrimaryStorageGlobalConfig.QCOW2_ALLOCATION.getDefaultValue();
}这会忽略运行时通过 GlobalConfig 修改 - if (psPreallocation == null) {
- psPreallocation = NfsPrimaryStorageGlobalConfig.QCOW2_ALLOCATION.getDefaultValue();
- }
+ if (psPreallocation == null) {
+ psPreallocation = NfsPrimaryStorageGlobalConfig.QCOW2_ALLOCATION.value(String.class);
+ }这样三类主存储在预分配配置上的优先级和 GlobalConfig 语义就完全一致了。 Also applies to: 85-86, 800-813 🤖 Prompt for AI Agents |
||
| import org.zstack.storage.primary.PrimaryStorageCapacityUpdater; | ||
| import org.zstack.storage.primary.PrimaryStorageSystemTags; | ||
|
|
@@ -80,6 +82,8 @@ public class NfsPrimaryStorageFactory implements NfsPrimaryStorageManager, Prima | |
| private RESTFacade restf; | ||
| @Autowired | ||
| protected EventFacade evtf; | ||
| @Autowired | ||
| private ResourceConfigFacade rcf; | ||
|
|
||
| private Map<String, NfsPrimaryStorageBackend> backends = new HashMap<String, NfsPrimaryStorageBackend>(); | ||
| private Map<String, Map<String, NfsPrimaryToBackupStorageMediator>> mediators = | ||
|
|
@@ -793,10 +797,20 @@ public void afterInstantiateVolume(InstantiateVolumeOnPrimaryStorageMsg msg) { | |
| } | ||
| } | ||
|
|
||
| VolumeInventory volume = msg.getVolume(); | ||
| volume.setPrimaryStorageUuid(msg.getPrimaryStorageUuid()); | ||
| for (CreateQcow2VolumeProvisioningStrategyExtensionPoint exp : pluginRgty.getExtensionList(CreateQcow2VolumeProvisioningStrategyExtensionPoint.class)) { | ||
| exp.saveQcow2VolumeProvisioningStrategy(volume, hasBackingFile); | ||
| String preallocation = rcf.getResourceConfigValueByResourceType(NfsPrimaryStorageGlobalConfig.QCOW2_ALLOCATION, | ||
| msg.getVolume().getUuid(), VolumeVO.class.getSimpleName(), String.class); | ||
| if (preallocation != null) { | ||
| return; | ||
| } | ||
|
|
||
| if (hasBackingFile) { | ||
| ResourceConfig rc = rcf.getResourceConfig(NfsPrimaryStorageGlobalConfig.QCOW2_ALLOCATION.getIdentity()); | ||
| String psPreallocation = rcf.getResourceConfigValueByResourceType(NfsPrimaryStorageGlobalConfig.QCOW2_ALLOCATION, | ||
| msg.getVolume().getPrimaryStorageUuid(), PrimaryStorageVO.class.getSimpleName(), String.class); | ||
| if (psPreallocation == null) { | ||
| psPreallocation = NfsPrimaryStorageGlobalConfig.QCOW2_ALLOCATION.getDefaultValue(); | ||
| } | ||
| rc.updateValue(msg.getVolume().getUuid(), psPreallocation); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,8 @@ | |
| import org.zstack.header.storage.snapshot.CreateTemplateFromVolumeSnapshotExtensionPoint; | ||
| import org.zstack.header.storage.snapshot.VolumeSnapshotInventory; | ||
| import org.zstack.header.volume.*; | ||
| import org.zstack.resourceconfig.ResourceConfig; | ||
| import org.zstack.resourceconfig.ResourceConfigFacade; | ||
|
Comment on lines
+31
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SMP qcow2 预分配逻辑与 Local 一致, 但 fallback 同样应尊重运行时 GlobalConfig 新增的 ResourceConfig 驱动逻辑整体合理:
和 LocalStorageFactory 一样, 这里的 fallback 目前使用的是编译期默认值: String psPreallocation = rcf.getResourceConfigValueByResourceType(
SMPPrimaryStorageGlobalConfig.QCOW2_ALLOCATION,
msg.getVolume().getPrimaryStorageUuid(), PrimaryStorageVO.class.getSimpleName(), String.class);
if (psPreallocation == null) {
psPreallocation = SMPPrimaryStorageGlobalConfig.QCOW2_ALLOCATION.getDefaultValue();
}这会忽略运行时通过 GlobalConfig 调整过的 - if (psPreallocation == null) {
- psPreallocation = SMPPrimaryStorageGlobalConfig.QCOW2_ALLOCATION.getDefaultValue();
- }
+ if (psPreallocation == null) {
+ psPreallocation = SMPPrimaryStorageGlobalConfig.QCOW2_ALLOCATION.value(String.class);
+ }这样可以保证预分配策略的优先级为:卷级 ResourceConfig > PS 级 ResourceConfig > 运行时全局 GlobalConfig。 Also applies to: 67-68, 429-442 🤖 Prompt for AI Agents |
||
| import org.zstack.storage.snapshot.PostMarkRootVolumeAsSnapshotExtension; | ||
| import org.zstack.utils.Utils; | ||
| import org.zstack.utils.logging.CLogger; | ||
|
|
@@ -62,6 +64,8 @@ public class SMPPrimaryStorageFactory implements PrimaryStorageFactory, CreateTe | |
| private ErrorFacade errf; | ||
| @Autowired | ||
| private PluginRegistry pluginRgty; | ||
| @Autowired | ||
| private ResourceConfigFacade rcf; | ||
|
|
||
| @Override | ||
| public PrimaryStorageType getPrimaryStorageType() { | ||
|
|
@@ -422,10 +426,20 @@ public void afterInstantiateVolume(InstantiateVolumeOnPrimaryStorageMsg msg) { | |
| } | ||
| } | ||
|
|
||
| VolumeInventory volume = msg.getVolume(); | ||
| volume.setPrimaryStorageUuid(msg.getPrimaryStorageUuid()); | ||
| for (CreateQcow2VolumeProvisioningStrategyExtensionPoint exp : pluginRgty.getExtensionList(CreateQcow2VolumeProvisioningStrategyExtensionPoint.class)) { | ||
| exp.saveQcow2VolumeProvisioningStrategy(volume, hasBackingFile); | ||
| String preallocation = rcf.getResourceConfigValueByResourceType(SMPPrimaryStorageGlobalConfig.QCOW2_ALLOCATION, | ||
| msg.getVolume().getUuid(), VolumeVO.class.getSimpleName(), String.class); | ||
| if (preallocation != null) { | ||
| return; | ||
| } | ||
|
|
||
| if (hasBackingFile) { | ||
| ResourceConfig rc = rcf.getResourceConfig(SMPPrimaryStorageGlobalConfig.QCOW2_ALLOCATION.getIdentity()); | ||
| String psPreallocation = rcf.getResourceConfigValueByResourceType(SMPPrimaryStorageGlobalConfig.QCOW2_ALLOCATION, | ||
| msg.getVolume().getPrimaryStorageUuid(), PrimaryStorageVO.class.getSimpleName(), String.class); | ||
| if (psPreallocation == null) { | ||
| psPreallocation = SMPPrimaryStorageGlobalConfig.QCOW2_ALLOCATION.getDefaultValue(); | ||
| } | ||
| rc.updateValue(msg.getVolume().getUuid(), psPreallocation); | ||
| } | ||
| } | ||
| } | ||
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.
预分配常量命名存在拼写错误, 建议在本 PR 即时修正
这里三个常量名中的
PREALLOCTION少了一个字母A(应为PREALLOCATION),不影响运行时行为,但会降低可读性且不利于后续搜索/维护,建议在引入阶段就修正,同时统一修改所有引用处:另外, GlobalConfig 的
validValues还包含"metadata",如希望完全避免 magic string,也可以考虑后续补充一个METADATA_PREALLOCATION常量(可选优化)。📝 Committable suggestion
🤖 Prompt for AI Agents