Open
Conversation
Walkthrough将卷级联选择与清理逻辑扩展为同时包含 Changes
Estimated code review effort🎯 2 (简单) | ⏱️ ~10 分钟 诗
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
d469e80 to
ad6081b
Compare
Extend VolumeCascadeExtension to match VolumeType.Memory alongside Data when cascading PrimaryStorage/Account deletion, so memory snapshot volumes and their snapshot/tree records are cleaned up instead of becoming orphaned rows pointing at deleted resources. Resolves: ZSV-11826 Change-Id: I71746a7768726671706b6a7970776a6d64616d71
ad6081b to
aa1e640
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
storage/src/main/java/org/zstack/storage/volume/VolumeCascadeExtension.java (1)
178-180: 建议抽取统一的“可级联删除卷类型”常量,避免三处硬编码漂移。当前逻辑正确,但类型集合在多个位置重复,后续扩展时容易漏改。
♻️ 可选重构示例
@@ public class VolumeCascadeExtension extends AbstractAsyncCascadeExtension { @@ + private static final EnumSet<VolumeType> CASCADE_DELETABLE_VOLUME_TYPES = + EnumSet.of(VolumeType.Data, VolumeType.Memory); @@ - volumeUuids = ResourceHelper.findOwnResourceUuidList(VolumeEO.class, auuids, - q -> q.in(VolumeVO_.type, Arrays.asList(VolumeType.Data, VolumeType.Memory))); + volumeUuids = ResourceHelper.findOwnResourceUuidList(VolumeEO.class, auuids, + q -> q.in(VolumeVO_.type, CASCADE_DELETABLE_VOLUME_TYPES)); @@ - q.add(VolumeVO_.type, Op.IN, Arrays.asList(VolumeType.Data, VolumeType.Memory)); + q.add(VolumeVO_.type, Op.IN, CASCADE_DELETABLE_VOLUME_TYPES); @@ - vos.removeIf(volume -> volume.getType() != VolumeType.Data - && volume.getType() != VolumeType.Memory); + vos.removeIf(volume -> !CASCADE_DELETABLE_VOLUME_TYPES.contains(volume.getType()));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@storage/src/main/java/org/zstack/storage/volume/VolumeCascadeExtension.java` around lines 178 - 180, Extract a shared constant (e.g., CASCADE_DELETABLE_VOLUME_TYPES) containing the allowed VolumeType values instead of hardcoding checks in VolumeCascadeExtension; replace the predicate using volume.getType() != VolumeType.Data && volume.getType() != VolumeType.Memory with a membership check against the new constant, update ResourceHelper.findOwnResources usage accordingly, and move the constant to a common utility/class (or VolumeType if appropriate) so other callers can reuse it to avoid duplicated hard-coded type lists.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@storage/src/main/java/org/zstack/storage/volume/VolumeCascadeExtension.java`:
- Around line 178-180: Extract a shared constant (e.g.,
CASCADE_DELETABLE_VOLUME_TYPES) containing the allowed VolumeType values instead
of hardcoding checks in VolumeCascadeExtension; replace the predicate using
volume.getType() != VolumeType.Data && volume.getType() != VolumeType.Memory
with a membership check against the new constant, update
ResourceHelper.findOwnResources usage accordingly, and move the constant to a
common utility/class (or VolumeType if appropriate) so other callers can reuse
it to avoid duplicated hard-coded type lists.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 85eb833d-2e9b-44aa-b620-ffed074221db
📒 Files selected for processing (1)
storage/src/main/java/org/zstack/storage/volume/VolumeCascadeExtension.java
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves: ZSV-11826
Change-Id: I71746a7768726671706b6a7970776a6d64616d71
sync from gitlab !9719