<feature>[ai] ZSTAC-84025: schema + SDK actions for inference template auto-match#3891
<feature>[ai] ZSTAC-84025: schema + SDK actions for inference template auto-match#3891zstack-robot-2 wants to merge 3 commits into5.5.22from
Conversation
…erviceRefVO.isDefault/createDate/lastOpDate Resolves: ZSTAC-84025 Change-Id: Ifbb68c9d475aa19762bb053e6545381a305dfe5b
…l.defaultModelServiceUuid Resolves: ZSTAC-84025 Change-Id: I4046976b0c4437ba4c14069946b8075393f152ed
…Model DSL Resolves: ZSTAC-84025 Change-Id: I0df26f7367a28da9c6c825dcddcb829db133374e
走查该 PR 向数据库模式添加新列以支持管道标签和清单 JSON 元数据,同时为 ModelServiceRef 添加状态跟踪字段。在测试库中添加了新的 DSL 助手方法来支持自动匹配模型服务的操作。 改动数据库 Schema 与测试支持
代码审查工作量估计🎯 2 (Simple) | ⏱️ ~12 分钟 诗
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Microsoft Presidio Analyzer (2.2.362)testlib/src/main/java/org/zstack/testlib/ApiHelper.groovyMicrosoft Presidio Analyzer failed to scan this file Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@conf/db/upgrade/V5.5.22__schema.sql`:
- Line 17: 将 ALTER TABLE for `ModelServiceRefVO` 的 `createDate` 列默认值从
'0000-00-00 00:00:00' 改为 DEFAULT CURRENT_TIMESTAMP,并在修改列约束为 NOT NULL
之前为历史行回填合理时间:实现一个短小的存储过程/函数(例如
backfill_model_service_ref_create_date)在升级脚本中先查找并将所有旧值(NULL 或 '0000-00-00
00:00:00')更新为合适的时间戳(如 NOW() 或基于业务规则的时间),执行完回填后再运行 ALTER TABLE 修改列定义为 NOT NULL
DEFAULT CURRENT_TIMESTAMP,以确保在严格模式下升级不会失败并保留历史数据一致性。
🪄 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: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)
Review profile: CHILL
Plan: Pro
Run ID: 457b51f9-3708-456c-b9b3-493701424bf5
⛔ Files ignored due to path filters (3)
sdk/src/main/java/org/zstack/sdk/AutoMatchModelServiceByModelAction.javais excluded by!sdk/**sdk/src/main/java/org/zstack/sdk/AutoMatchModelServiceByModelResult.javais excluded by!sdk/**sdk/src/main/java/org/zstack/sdk/UpdateModelAction.javais excluded by!sdk/**
📒 Files selected for processing (2)
conf/db/upgrade/V5.5.22__schema.sqltestlib/src/main/java/org/zstack/testlib/ApiHelper.groovy
| -- ZSTAC-84025: Add createDate/lastOpDate to ModelServiceRefVO so the auto-match Matcher can | ||
| -- pick the earliest isDefault=true row when DB has the rare 2+ defaults anomaly (Q5). | ||
| ALTER TABLE `zstack`.`ModelServiceRefVO` ADD COLUMN `lastOpDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; | ||
| ALTER TABLE `zstack`.`ModelServiceRefVO` ADD COLUMN `createDate` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# 只读校验:定位 zero-date 默认值及 NOT NULL 时间列定义
rg -n "ADD COLUMN `createDate`|ADD COLUMN `lastOpDate`|DEFAULT '0000-00-00 00:00:00'" conf/db/upgrade/V5.5.22__schema.sqlRepository: MatheMatrix/zstack
Length of output: 535
将第 17 行 createDate 的默认值改为 CURRENT_TIMESTAMP 并处理历史数据
第 17 行使用了 DEFAULT '0000-00-00 00:00:00',违反了 SQL 编码规范。根据要求应改为 DEFAULT CURRENT_TIMESTAMP,并由于列定义为 NOT NULL,必须使用存储过程或函数处理历史数据的回填,确保升级在严格模式下的兼容性。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@conf/db/upgrade/V5.5.22__schema.sql` at line 17, 将 ALTER TABLE for
`ModelServiceRefVO` 的 `createDate` 列默认值从 '0000-00-00 00:00:00' 改为 DEFAULT
CURRENT_TIMESTAMP,并在修改列约束为 NOT NULL 之前为历史行回填合理时间:实现一个短小的存储过程/函数(例如
backfill_model_service_ref_create_date)在升级脚本中先查找并将所有旧值(NULL 或 '0000-00-00
00:00:00')更新为合适的时间戳(如 NOW() 或基于业务规则的时间),执行完回填后再运行 ALTER TABLE 修改列定义为 NOT NULL
DEFAULT CURRENT_TIMESTAMP,以确保在严格模式下升级不会失败并保留历史数据一致性。
Scope (zstack core)
ZSTAC-84025 推理模板自动匹配 (Inference Template Auto-Match) for AIOS 5.5.22 — zstack core slice.
Changes (3 commits)
552558629aV5.5.22__schema.sql— addsModelVO.pipelineTag/manifestJson,ModelServiceRefVO.isDefault/createDate/lastOpDatee088888775AutoMatchModelServiceByModelAction/Result,UpdateModelAction.defaultModelServiceUuidfield8ccf27b358ApiHelper.groovyregenerated withautoMatchModelServiceByModelDSLCross-repo dependencies
This MR is one of three:
.ggufdetection + YAML frontmatter parser + manifest passthroughAll three must land together; premium's runtime depends on schema added here.
Verification
./runMavenProfile premiumBUILD SUCCESS in PR docker (full clean install, 1h45m)createDate DEFAULT '0000-00-00 00:00:00')Spec
sync from gitlab !9772