-
Notifications
You must be signed in to change notification settings - Fork 0
<fix>[zbs]: sync cow snapshot size in scheduled volume resource sync #4446
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: 5.5.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package org.zstack.header.storage.primary; | ||
|
|
||
| public class StorageResourceStats { | ||
| protected String installPath; | ||
| protected Long actualSize; | ||
| protected Long size; | ||
|
|
||
| public String getInstallPath() { | ||
| return installPath; | ||
| } | ||
|
|
||
| public void setInstallPath(String installPath) { | ||
| this.installPath = installPath; | ||
| } | ||
|
|
||
| public Long getActualSize() { | ||
| return actualSize; | ||
| } | ||
|
|
||
| public void setActualSize(Long actualSize) { | ||
| this.actualSize = actualSize; | ||
| } | ||
|
|
||
| public Long getSize() { | ||
| return size; | ||
| } | ||
|
|
||
| public void setSize(long size) { | ||
| this.size = size; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,6 @@ | ||
| package org.zstack.header.storage.snapshot; | ||
|
|
||
| public class VolumeSnapshotStats { | ||
| private String installPath; | ||
| private long actualSize; | ||
| import org.zstack.header.storage.primary.StorageResourceStats; | ||
|
|
||
| public String getInstallPath() { | ||
| return installPath; | ||
| } | ||
|
|
||
| public void setInstallPath(String installPath) { | ||
| this.installPath = installPath; | ||
| } | ||
|
|
||
| public long getActualSize() { | ||
| return actualSize; | ||
| } | ||
|
|
||
| public void setActualSize(long actualSize) { | ||
| this.actualSize = actualSize; | ||
| } | ||
| public class VolumeSnapshotStats extends StorageResourceStats { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package org.zstack.header.volume; | ||
|
|
||
| import org.zstack.header.message.MessageReply; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| public class BatchSyncVolumeResourceSizeOnPrimaryStorageReply extends MessageReply { | ||
| private Map<String, Long> volumeActualSizes = new HashMap<>(); | ||
|
|
||
| private Map<String, Long> snapshotActualSizes = new HashMap<>(); | ||
|
|
||
| public void setVolumeActualSizes(Map<String, Long> actualSizes) { | ||
| this.volumeActualSizes = actualSizes; | ||
| } | ||
|
|
||
| public Map<String, Long> getVolumeActualSizes() { | ||
| return volumeActualSizes; | ||
| } | ||
|
|
||
| public Map<String, Long> getSnapshotActualSizes() { | ||
| return snapshotActualSizes; | ||
| } | ||
|
|
||
| public void setSnapshotActualSizes(Map<String, Long> snapshotActualSizes) { | ||
| this.snapshotActualSizes = snapshotActualSizes; | ||
| } | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3325,11 +3325,16 @@ protected void handle(AskVolumeSnapshotCapabilityMsg msg) { | |
| AskVolumeSnapshotCapabilityReply reply = new AskVolumeSnapshotCapabilityReply(); | ||
| VolumeSnapshotCapability cap = new VolumeSnapshotCapability(); | ||
|
|
||
| String volumeType = msg.getVolume().getType(); | ||
| String volumeType = msg.getVolumeType(); | ||
| if (volumeType == null) { | ||
| volumeType = msg.getVolume().getType(); | ||
| } | ||
|
|
||
| if (VolumeType.Data.toString().equals(volumeType) || VolumeType.Root.toString().equals(volumeType)) { | ||
| cap.setSupport(true); | ||
| cap.setArrangementType(VolumeSnapshotArrangementType.INDIVIDUAL); | ||
| cap.setPlacementType(VolumeSnapshotCapability.VolumeSnapshotPlacementType.INTERNAL); | ||
| cap.setMode(VolumeSnapshotCapability.VolumeSnapshotMode.REDIRECT_ON_WRITE); | ||
| cap.setVolumePathFromInternalSnapshotRegex("^[^@]+"); | ||
| } else if (VolumeType.Memory.toString().equals(volumeType)) { | ||
| cap.setSupport(false); | ||
|
|
@@ -3397,10 +3402,10 @@ public void fail(ErrorCode errorCode) { | |
| } | ||
|
|
||
| @Override | ||
| protected void handle(BatchSyncVolumeSizeOnPrimaryStorageMsg msg) { | ||
| protected void handle(BatchSyncVolumeResourceSizeOnPrimaryStorageMsg msg) { | ||
| inQueue().name(String.format("batch-sync-volume-size-on-primarystorage-%s", self.getUuid())) | ||
| .asyncBackup(msg) | ||
| .run(chain -> BatchSyncVolumeSizeOnPrimaryStorage(msg, new NoErrorCompletion(chain) { | ||
| .run(chain -> BatchSyncVolumeResourceSizeOnPrimaryStorage(msg, new NoErrorCompletion(chain) { | ||
|
Comment on lines
+3405
to
+3408
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. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win 私有方法名违反 lowerCamelCase 命名规范 私有方法 ♻️ 建议修正- .run(chain -> BatchSyncVolumeResourceSizeOnPrimaryStorage(msg, new NoErrorCompletion(chain) {
+ .run(chain -> batchSyncVolumeResourceSizeOnPrimaryStorage(msg, new NoErrorCompletion(chain) {- private void BatchSyncVolumeResourceSizeOnPrimaryStorage(BatchSyncVolumeResourceSizeOnPrimaryStorageMsg msg, NoErrorCompletion completion) {
+ private void batchSyncVolumeResourceSizeOnPrimaryStorage(BatchSyncVolumeResourceSizeOnPrimaryStorageMsg msg, NoErrorCompletion completion) {As per path instructions, "方法名、参数名、成员变量和局部变量:使用 lowerCamelCase 风格。" Also applies to: 3427-3457 🤖 Prompt for AI AgentsSource: Path instructions |
||
| @Override | ||
| public void done() { | ||
| chain.next(); | ||
|
|
@@ -3419,8 +3424,8 @@ protected void syncVolumeSize(String volumeUuid, String installPath, final Retur | |
| httpCall(GET_VOLUME_SIZE_PATH, cmd, GetVolumeSizeRsp.class, completion); | ||
| } | ||
|
|
||
| private void BatchSyncVolumeSizeOnPrimaryStorage(BatchSyncVolumeSizeOnPrimaryStorageMsg msg, NoErrorCompletion completion) { | ||
| BatchSyncVolumeSizeOnPrimaryStorageReply reply = new BatchSyncVolumeSizeOnPrimaryStorageReply(); | ||
| private void BatchSyncVolumeResourceSizeOnPrimaryStorage(BatchSyncVolumeResourceSizeOnPrimaryStorageMsg msg, NoErrorCompletion completion) { | ||
| BatchSyncVolumeResourceSizeOnPrimaryStorageReply reply = new BatchSyncVolumeResourceSizeOnPrimaryStorageReply(); | ||
|
|
||
| GetBatchVolumeSizeCmd cmd = new GetBatchVolumeSizeCmd(); | ||
| cmd.volumeUuidInstallPaths = msg.getVolumeUuidInstallPaths(); | ||
|
|
@@ -3436,7 +3441,7 @@ public void success(GetBatchVolumeSizeRsp rsp) { | |
| markVolumeActualSize(volumeUuid, actualSize); | ||
| } | ||
|
|
||
| reply.setActualSizes(rsp.actualSizes); | ||
| reply.setVolumeActualSizes(rsp.actualSizes); | ||
| bus.reply(msg, reply); | ||
| completion.done(); | ||
| } | ||
|
|
||
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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
为新增接口契约补充有效 Javadoc。
batchStats现在同时承担卷/快照资源统计,建议明确参数含义及返回值可能是VolumeStats或VolumeSnapshotStats,避免实现方误用。根据路径指令,接口方法必须配有有效 Javadoc。
📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Path instructions