Skip to content

Conversation

@zstack-robot-1
Copy link
Collaborator

convert memory snapshot install path from absolute path to protocol path

Resolves/Related: ZSTAC-79756

Change-Id: I6e626d68626461627a737765786a676e6b617064

sync from gitlab !8687

…e path to protocol path

convert memory snapshot install path from absolute path to protocol path

Resolves/Related: ZSTAC-79756

Change-Id: I6e626d68626461627a737765786a676e6b617064
@coderabbitai
Copy link

coderabbitai bot commented Nov 11, 2025

Note

http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml) has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'auto_resolve_threads'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

概览

本次变更在数据库升级脚本中添加了一条数据迁移语句,用于更新 SharedBlock 主存储上内存卷快照的 installPath,将 "/dev/" 替换为 "sharedblock://"。通过 JOIN 操作连接 VolumeSnapshotVO 和 PrimaryStorageVO 表,针对 SharedBlock 存储类型且路径匹配 /dev/ 模式的记录进行更新。

变更

内聚组 / 文件 变更摘要
数据库升级脚本
conf/db/upgrade/V5.4.2__schema.sql
新增数据迁移 SQL 语句,将 SharedBlock 主存储上内存卷快照的安装路径从 "/dev/" 前缀更新为 "sharedblock://" 前缀

代码审查工作量评估

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

  • SQL 迁移脚本为单一、非复杂的数据更新操作
  • 无新增代码逻辑或核心业务流程变更
  • 建议关注点:验证 SQL JOIN 条件的正确性和过滤条件的精准性,确保只影响目标记录

🐰 ✨
快照路径焕新颜,
共享块上展新篇,
从 /dev 到云间,
升级脚本无复杂,
数据迁移一句完!

Pre-merge checks and finishing touches

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)
Check name Status Explanation Resolution
Title check ❌ Error PR标题超过72字符限制(92字符),不符合格式要求。 缩短标题以符合72字符限制,例如:[sharedblock]: Convert memory snapshot install path to protocol path
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed PR描述与变更集相关,清晰地说明了将内存快照安装路径从绝对路径转换为协议路径的变更。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sync/shan.wu/fix-ZSTAC-79756@@2

📜 Recent review details

Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f90d54 and d31c829.

📒 Files selected for processing (1)
  • conf/db/upgrade/V5.4.2__schema.sql (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.*

⚙️ CodeRabbit configuration file

**/*.*: - 代码里不应当有有中文,包括报错、注释等都应当使用正确的、无拼写错误的英文来写

Files:

  • conf/db/upgrade/V5.4.2__schema.sql
**/*.sql

⚙️ CodeRabbit configuration file

**/*.sql: - Review the SQL code, make sure has no errors and confirm that:

  • Upgrading scene has been carefully handled
  • Do not use DEFAULT 0000-00-00 00:00:00 , use DEFAULT CURRENT_TIMESTAMP instead
  • When NOT NULL exists, must use stored procedure or other functions to process historical data, this is very very important
  • 数据库记录中,如果字符串长度不可控,不要用 vchar,用 text 类型

Files:

  • conf/db/upgrade/V5.4.2__schema.sql
🧠 Learnings (3)
📓 Common learnings
Learnt from: MatheMatrix
Repo: MatheMatrix/zstack PR: 2504
File: plugin/localstorage/src/main/java/org/zstack/storage/primary/local/LocalStorageKvmBackend.java:1010-1010
Timestamp: 2025-08-25T03:53:30.749Z
Learning: The OFFLINE_COMMIT_PATH ("/localstorage/snapshot/offlinecommit") for local storage snapshot commit operations is properly handled on both the ZStack management node side (in LocalStorageKvmBackend.java) and the KVM Agent side, providing complete end-to-end offline snapshot commit functionality.
📚 Learning: 2025-08-03T04:10:21.683Z
Learnt from: zstack-robot-1
Repo: MatheMatrix/zstack PR: 0
File: :0-0
Timestamp: 2025-08-03T04:10:21.683Z
Learning: ZStack 数据库升级脚本 V4.10.16__schema.sql 中的 UPGRADE_VM_METADATA_TABLES_DIRECT 存储过程使用直接 RENAME TABLE 操作,不具备幂等性。需要通过 information_schema 检查表和约束的存在性来确保脚本可以安全重复执行。

Applied to files:

  • conf/db/upgrade/V5.4.2__schema.sql
📚 Learning: 2025-08-25T03:55:07.988Z
Learnt from: zstack-robot-1
Repo: MatheMatrix/zstack PR: 2504
File: plugin/nfsPrimaryStorage/src/main/java/org/zstack/storage/primary/nfs/NfsPrimaryStorageKVMBackend.java:2046-2078
Timestamp: 2025-08-25T03:55:07.988Z
Learning: The OFFLINE_SNAPSHOT_COMMIT path for NFS primary storage snapshot commit operations is properly handled in the test infrastructure via NfsPrimaryStorageSpec.groovy, which includes both simulator and VFS hook implementations for testing the offline snapshot commit functionality.

Applied to files:

  • conf/db/upgrade/V5.4.2__schema.sql
🔇 Additional comments (1)
conf/db/upgrade/V5.4.2__schema.sql (1)

182-184: SQL 升级语句正确且幂等,无需修改。

验证结果确认该 UPDATE 语句完全符合 ZStack 升级规范:

  1. 字段定义验证primaryStorageInstallPath 定义为 varchar(1024) DEFAULT NULL(V0.6 schema),字符串长度控制合理,无 NOT NULL 约束,不需要存储过程处理历史数据。

  2. 幂等性保证:WHERE 条件中的 LIKE '/dev/%' 正确保障了幂等性。重复执行时,已转换为 sharedblock:// 前缀的路径将不匹配此条件,不会发生重复修改。

  3. 升级场景处理完善

    • JOIN 逻辑正确过滤 SharedBlock 存储的快照
    • volumeType = 'Memory' 精确定位目标数据
    • REPLACE 函数安全可靠

无需改动,该升级脚本可直接使用。


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

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