Skip to content

fix(ai): add clusterId column to ModelServiceInstanceVO#3358

Open
MatheMatrix wants to merge 1 commit into5.5.6from
sync/ye.zou/fix/ZSTAC-81566
Open

fix(ai): add clusterId column to ModelServiceInstanceVO#3358
MatheMatrix wants to merge 1 commit into5.5.6from
sync/ye.zou/fix/ZSTAC-81566

Conversation

@MatheMatrix
Copy link
Owner

Resolves: ZSTAC-81566

Target: 5.5.6

sync from gitlab !9188

…art recovery

Add flyway migration to persist clusterId on ModelServiceInstanceVO so that
inference service restart can locate the K8s cluster even after Pod eviction.
Includes backfill of existing data from PodVO.

ZSTAC-81566

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

概览

数据库架构升级脚本,在 ModelServiceInstanceVO 表中添加可空的 clusterId 列(BIGINT 类型),并通过与 PodVO 表关联的方式对现有数据进行回填。

变更

群组 / 文件 摘要
数据库架构升级
conf/db/upgrade/V5.5.6__schema.sql
在 ModelServiceInstanceVO 表添加 clusterId 列(BIGINT,可空),并通过 JOIN PodVO 表的方式,将现有记录中 clusterId 为 NULL 的行使用 PodVO 中的 clusterId 值进行回填。

预估代码审查工作量

🎯 1 (Trivial) | ⏱️ ~3 minutes

🐰✨ 小小 SQL 舞步轻,
clusterId 列柔声应,
PodVO 表来相牵,
旧日数据换新容,
架构升级梦成真!

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (9 files):

⚔️ conf/db/upgrade/V5.5.6__schema.sql (content)
⚔️ identity/src/main/java/org/zstack/identity/QuotaUtil.java (content)
⚔️ longjob/src/main/java/org/zstack/longjob/LongJobManagerImpl.java (content)
⚔️ network/src/main/java/org/zstack/network/service/DhcpExtension.java (content)
⚔️ plugin/applianceVm/src/main/java/org/zstack/appliancevm/ApplianceVmFacadeImpl.java (content)
⚔️ plugin/flatNetworkProvider/src/main/java/org/zstack/network/service/flat/FlatUserdataBackend.java (content)
⚔️ sdk/src/main/java/org/zstack/sdk/GpuAllocateStatus.java (content)
⚔️ search/src/main/java/org/zstack/query/MysqlQueryBuilderImpl3.java (content)
⚔️ search/src/main/java/org/zstack/query/QueryFacadeImpl.java (content)

These conflicts must be resolved before merging into 5.5.6.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed 标题遵循了指定的格式 [scope]: ,长度为55个字符,在72字符的限制内,清晰地总结了PR的主要改动。
Description check ✅ Passed 描述与变更集相关,包含问题追踪ID (ZSTAC-81566)、目标版本 (5.5.6) 和来源信息,与PR目标相符。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sync/ye.zou/fix/ZSTAC-81566
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch sync/ye.zou/fix/ZSTAC-81566
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

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

Copy link

@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

🤖 Fix all issues with AI agents
In `@conf/db/upgrade/V5.5.6__schema.sql`:
- Around line 183-186: The SQL UPDATE uses unquoted identifiers which can break
on MySQL/GreatSQL reserved words; update the statement to wrap all table and
column names in backticks—specifically reference the tables
ModelServiceInstanceVO and PodVO and the columns vmInstanceUuid, uuid, and
clusterId—so change the UPDATE/INNER JOIN/SET/WHERE identifiers to use backticks
around `ModelServiceInstanceVO`, `msi`, `PodVO`, `p`, `vmInstanceUuid`, `uuid`,
and `clusterId`.

Comment on lines +183 to +186
UPDATE ModelServiceInstanceVO msi
INNER JOIN PodVO p ON msi.vmInstanceUuid = p.uuid
SET msi.clusterId = p.clusterId
WHERE msi.clusterId IS NULL AND p.clusterId IS NOT NULL;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

表名和列名需要使用反引号包裹。

根据编码规范,所有表名和列名必须使用反引号包裹,以避免 MySQL 8.0 / GreatSQL 保留关键字冲突导致的语法错误。例如 uuid 在某些数据库版本中可能是保留字。

♻️ 建议修改
-UPDATE ModelServiceInstanceVO msi
-INNER JOIN PodVO p ON msi.vmInstanceUuid = p.uuid
-SET msi.clusterId = p.clusterId
-WHERE msi.clusterId IS NULL AND p.clusterId IS NOT NULL;
+UPDATE `ModelServiceInstanceVO` `msi`
+INNER JOIN `PodVO` `p` ON `msi`.`vmInstanceUuid` = `p`.`uuid`
+SET `msi`.`clusterId` = `p`.`clusterId`
+WHERE `msi`.`clusterId` IS NULL AND `p`.`clusterId` IS NOT NULL;

As per coding guidelines: "所有表名和列名必须使用反引号包裹(例如:WHERE `system` = 1),以避免 MySQL 8.0 / GreatSQL 保留关键字冲突导致的语法错误"

🤖 Prompt for AI Agents
In `@conf/db/upgrade/V5.5.6__schema.sql` around lines 183 - 186, The SQL UPDATE
uses unquoted identifiers which can break on MySQL/GreatSQL reserved words;
update the statement to wrap all table and column names in
backticks—specifically reference the tables ModelServiceInstanceVO and PodVO and
the columns vmInstanceUuid, uuid, and clusterId—so change the UPDATE/INNER
JOIN/SET/WHERE identifiers to use backticks around `ModelServiceInstanceVO`,
`msi`, `PodVO`, `p`, `vmInstanceUuid`, `uuid`, and `clusterId`.

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