Skip to content

<fix>[storage]: <description#3848

Open
zstack-robot-2 wants to merge 1 commit intozsv_5.0.0from
sync/tao.gan/ZSV-11826@@2
Open

<fix>[storage]: <description#3848
zstack-robot-2 wants to merge 1 commit intozsv_5.0.0from
sync/tao.gan/ZSV-11826@@2

Conversation

@zstack-robot-2
Copy link
Copy Markdown
Collaborator

Resolves: ZSV-11826

Change-Id: I71746a7768726671706b6a7970776a6d64616d71

sync from gitlab !9719

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

Walkthrough

将卷级联选择与清理逻辑扩展为同时包含 VolumeType.MemoryVolumeType.Data,在基于账户和主存储的删除路径中将卷类型查询/过滤从仅 Data 改为 IN (Data, Memory),并调整内存过滤条件以保留两类可删除卷。

Changes

Cohort / File(s) Summary
卷级联清理逻辑扩展
storage/src/main/java/org/zstack/storage/volume/VolumeCascadeExtension.java
将账户作用域和主存储删除路径中的卷类型过滤从仅 Data 改为 type IN (Data, Memory);内存过滤逻辑改为仅排除既非 Data 也非 Memory 的卷。代码行变更 +4/-3。

Estimated code review effort

🎯 2 (简单) | ⏱️ ~10 分钟

🐰 轻跳林间小径,
内存卷与数据卷并行,
级联清理更周全,
改动不多心欢喜,
春风又来把代码倾。

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning PR标题不完整且缺乏具体描述,使用了占位符'<description'而非实际的变更描述信息。 请补充完整的PR标题,例如'[storage]: Treat VolumeType.Memory the same as VolumeType.Data in cascade cleanup'。
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed PR描述与实际代码变更相关,提及了关联的issue和来源,符合基本要求。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sync/tao.gan/ZSV-11826@@2

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

@MatheMatrix MatheMatrix force-pushed the sync/tao.gan/ZSV-11826@@2 branch from d469e80 to ad6081b Compare April 23, 2026 14:05
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
@MatheMatrix MatheMatrix force-pushed the sync/tao.gan/ZSV-11826@@2 branch from ad6081b to aa1e640 Compare April 24, 2026 02:57
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between ad6081b and aa1e640.

📒 Files selected for processing (1)
  • storage/src/main/java/org/zstack/storage/volume/VolumeCascadeExtension.java

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