Skip to content

<fix>[header]: add taskUuid to CancelDownloadFileMsg#3703

Closed
ZStack-Robot wants to merge 1 commit intofeature-zsv-5.0.0-zmigratefrom
sync/tao.gan/ZSV-11693@@4
Closed

<fix>[header]: add taskUuid to CancelDownloadFileMsg#3703
ZStack-Robot wants to merge 1 commit intofeature-zsv-5.0.0-zmigratefrom
sync/tao.gan/ZSV-11693@@4

Conversation

@ZStack-Robot
Copy link
Copy Markdown
Collaborator

Add taskUuid field to CancelDownloadFileOnBackupStorageHostMsg
so imagestore agent can locate and cancel the specific file
download/upload task by its taskUuid.

Resolves: ZSV-11693

Change-Id: I1c19ef972df4289aee784431ceea42e62d07dce8

sync from gitlab !9566

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4bbf5ff3-d9c3-42cd-88c3-d865f332eed3

📥 Commits

Reviewing files that changed from the base of the PR and between 4cd6628 and 5f6b79b.

📒 Files selected for processing (1)
  • header/src/main/java/org/zstack/header/storage/backup/CancelDownloadFileOnBackupStorageHostMsg.java
✅ Files skipped from review due to trivial changes (1)
  • header/src/main/java/org/zstack/header/storage/backup/CancelDownloadFileOnBackupStorageHostMsg.java

Walkthrough

CancelDownloadFileOnBackupStorageHostMsg 类添加了新的 taskUuid 字段,并新增公开访问器 getTaskUuid()setTaskUuid(String),其余字段与行为未变。

Changes

Cohort / File(s) Summary
字段与访问器添加
header/src/main/java/org/zstack/header/storage/backup/CancelDownloadFileOnBackupStorageHostMsg.java
新增 private String taskUuid;,并添加 public String getTaskUuid()public void setTaskUuid(String taskUuid)

Estimated code review effort

🎯 1 (极简) | ⏱️ ~3 分钟

新增一串小标识,🐇
任务轻声入消息,
方法字段手相牵,
备存路上更分明。

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (2 passed)
Check name Status Explanation
Title check ✅ Passed PR标题准确地总结了主要变更:向CancelDownloadFileMsg添加taskUuid字段,与实际代码变更相符。
Description check ✅ Passed PR描述清晰说明了变更目的和相关context,与代码变更内容相关且提供了足够的背景信息。

✏️ 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-11693@@4

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

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@header/src/main/java/org/zstack/header/storage/backup/CancelDownloadFileOnBackupStorageHostMsg.java`:
- Line 8: The field taskUuid in CancelDownloadFileOnBackupStorageHostMsg is
unused and should be removed to avoid dead code; update the message class by
deleting the taskUuid member and any accessors, and ensure any
serialization/constructor logic referencing taskUuid is cleaned up.
Alternatively, if you intend to support cancellation by taskUuid later,
implement the cancel path in the backend handler
handle(CancelDownloadFileOnBackupStorageHostMsg) to consult taskUuid (with clear
precedence vs cancellationApiId) and add documentation/tests; pick one approach
and apply it consistently so CancelDownloadFileOnBackupStorageHostMsg, its
taskUuid, and cancellationApiId semantics are no longer ambiguous.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 94f9ba41-23da-45cb-89f3-f4140573c660

📥 Commits

Reviewing files that changed from the base of the PR and between 456b20c and 4cd6628.

📒 Files selected for processing (1)
  • header/src/main/java/org/zstack/header/storage/backup/CancelDownloadFileOnBackupStorageHostMsg.java

public class CancelDownloadFileOnBackupStorageHostMsg extends CancelMessage implements BackupStorageMessage {
private String backupStorageUuid;
private String backupStorageHostUuid;
private String taskUuid;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) 查找该消息的所有处理入口
rg -n -C3 --type=java 'handle\s*\(\s*CancelDownloadFileOnBackupStorageHostMsg\s+\w+\s*\)'

# 2) 查找 taskUuid 在代码中的读写位置
rg -n -C2 --type=java '\b(getTaskUuid|setTaskUuid)\s*\('

# 3) 对比 cancellationApiId 的依赖点,判断是否仍是主取消键
rg -n -C3 --type=java '\bgetCancellationApiId\s*\('

Repository: MatheMatrix/zstack

Length of output: 33377


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) 查找所有后端对 CancelDownloadFileOnBackupStorageHostMsg 的实现
echo "=== 所有 handle(CancelDownloadFileOnBackupStorageHostMsg) 实现 ==="
rg -n 'handle\s*\(\s*CancelDownloadFileOnBackupStorageHostMsg' --type=java -A 20 | head -100

# 2) 检查 imagestore 相关的实现
echo -e "\n=== ImageStore 相关实现 ==="
find . -path "*imagestore*" -name "*.java" | xargs rg -l 'CancelDownloadFileOnBackupStorageHostMsg' 2>/dev/null || echo "No imagestore implementations found"

# 3) 检查 taskUuid 在 CancelDownloadFileOnBackupStorageHostMsg 中是否被任何后端使用
echo -e "\n=== 查找对 msg.getTaskUuid() 的调用 (CancelDownloadFileOnBackupStorageHostMsg 上下文) ==="
rg -n 'getTaskUuid\s*\(\s*\)' --type=java -B 3 -A 3 | grep -A 5 -B 5 'CancelDownloadFileOnBackupStorageHostMsg\|cancel.*download' | head -60

Repository: MatheMatrix/zstack

Length of output: 6940


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) 查看 CancelDownloadFileOnBackupStorageHostMsg 完整定义
echo "=== CancelDownloadFileOnBackupStorageHostMsg 完整定义 ==="
cat header/src/main/java/org/zstack/header/storage/backup/CancelDownloadFileOnBackupStorageHostMsg.java

# 2) 查找谁设置了 taskUuid 在 CancelDownloadFileOnBackupStorageHostMsg 上
echo -e "\n=== 查找 CancelDownloadFileOnBackupStorageHostMsg 的构造和使用 ==="
rg -n 'CancelDownloadFileOnBackupStorageHostMsg' --type=java -B 2 -A 2 | head -150

# 3) 对比:GetFileDownloadProgressFromBackupStorageHostMsg 的实现
echo -e "\n=== GetFileDownloadProgressFromBackupStorageHostMsg 在 Ceph 中的实现 ==="
rg -n 'handle.*GetFileDownloadProgressFromBackupStorageHostMsg' --type=java -A 30 | grep -A 30 'CephBackupStorageBase'

Repository: MatheMatrix/zstack

Length of output: 7982


taskUuid 在取消操作中完全未被消费,存在死代码风险。

经验证,当前 Ceph 后端(唯一实现该消息处理的后端)的 handle(CancelDownloadFileOnBackupStorageHostMsg) 实现中,taskUuid 字段虽然存在但从未被读取或使用。取消操作仅依赖 cancellationApiId,且在其为空时直接返回错误,不存在降级或优先级逻辑。

这与 GetFileDownloadProgressFromBackupStorageHostMsg 的语义不一致:后者明确要求 taskUuid 非空且在实现中活跃使用(第2340行),而取消消息中的 taskUuid 形同虚设。

建议:

  1. taskUuid 不适用于取消操作,应从消息类中删除,避免接口混淆。
  2. 若日后计划基于 taskUuid 实现取消(如替代或补充 cancellationApiId),应明确文档约定并一并实现相关逻辑。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@header/src/main/java/org/zstack/header/storage/backup/CancelDownloadFileOnBackupStorageHostMsg.java`
at line 8, The field taskUuid in CancelDownloadFileOnBackupStorageHostMsg is
unused and should be removed to avoid dead code; update the message class by
deleting the taskUuid member and any accessors, and ensure any
serialization/constructor logic referencing taskUuid is cleaned up.
Alternatively, if you intend to support cancellation by taskUuid later,
implement the cancel path in the backend handler
handle(CancelDownloadFileOnBackupStorageHostMsg) to consult taskUuid (with clear
precedence vs cancellationApiId) and add documentation/tests; pick one approach
and apply it consistently so CancelDownloadFileOnBackupStorageHostMsg, its
taskUuid, and cancellationApiId semantics are no longer ambiguous.

Add taskUuid field to CancelDownloadFileOnBackupStorageHostMsg
so imagestore agent can locate and cancel the specific file
download/upload task by its taskUuid.

Resolves: ZSV-11693

Change-Id: I1c19ef972df4289aee784431ceea42e62d07dce8
@MatheMatrix MatheMatrix force-pushed the sync/tao.gan/ZSV-11693@@4 branch from 4cd6628 to 5f6b79b Compare April 12, 2026 13:03
@zstack-robot-2 zstack-robot-2 deleted the sync/tao.gan/ZSV-11693@@4 branch April 12, 2026 14:37
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.

3 participants