fix(ai): ZSTAC-68709 add evaluation task queuing with per-endpoint concurrency control#3438
fix(ai): ZSTAC-68709 add evaluation task queuing with per-endpoint concurrency control#3438zstack-robot-1 wants to merge 1 commit into5.5.12from
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
演练数据库升级脚本向ModelEvaluationTaskVO表添加了一个新的TEXT类型列targetQueueKey。该更改通过V5.5.12版本的升级脚本实现,使用ADD_COLUMN调用执行,未对现有列或索引进行修改。 变更
预估代码审查工作量🎯 1 (琐碎) | ⏱️ ~3 分钟 诗
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 1 warning)
✅ Passed checks (1 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
conf/db/upgrade/V5.5.12__schema.sql (1)
35-36: 考虑为targetQueueKey添加索引根据 PR 描述,
targetQueueKey用于按服务端点进行任务队列管理和并发控制。如果业务逻辑需要频繁按此列查询待处理任务(例如WHERE targetQueueKey = 'http://host:port' AND state = 'Pending'),建议添加索引以提升查询性能。参考同文件中
totalScore和endTime的处理方式(第 12-13 行),可考虑:💡 建议添加索引
-- ZSTAC-68709: Add targetQueueKey for evaluation task queuing per service endpoint CALL ADD_COLUMN('ModelEvaluationTaskVO', 'targetQueueKey', 'VARCHAR(256)', 1, NULL); +CALL CREATE_INDEX('ModelEvaluationTaskVO', 'idx_ModelEvaluationTaskVO_targetQueueKey', 'targetQueueKey');请确认主逻辑中是否有按
targetQueueKey进行查询的场景,如果有频繁查询需求,索引会显著提升性能。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@conf/db/upgrade/V5.5.12__schema.sql` around lines 35 - 36, The migration adds a new column targetQueueKey on ModelEvaluationTaskVO but does not create an index; if code queries by targetQueueKey (e.g., WHERE targetQueueKey = ... AND state = 'Pending') you should add an index in this migration similar to how totalScore/endTime are handled—update V5.5.12__schema.sql to include an index creation for ModelEvaluationTaskVO.targetQueueKey (use a VARCHAR(256)-compatible index name) and ensure the index is added via the same DB helper/call pattern used elsewhere in the file so the migration and rollback paths remain consistent; also scan codepaths that reference ModelEvaluationTaskVO (queries filtering by targetQueueKey) to confirm indexing is required.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@conf/db/upgrade/V5.5.12__schema.sql`:
- Around line 35-36: The migration adds a new column targetQueueKey on
ModelEvaluationTaskVO but does not create an index; if code queries by
targetQueueKey (e.g., WHERE targetQueueKey = ... AND state = 'Pending') you
should add an index in this migration similar to how totalScore/endTime are
handled—update V5.5.12__schema.sql to include an index creation for
ModelEvaluationTaskVO.targetQueueKey (use a VARCHAR(256)-compatible index name)
and ensure the index is added via the same DB helper/call pattern used elsewhere
in the file so the migration and rollback paths remain consistent; also scan
codepaths that reference ModelEvaluationTaskVO (queries filtering by
targetQueueKey) to confirm indexing is required.
ℹ️ 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: d8c3b873-6088-4c35-9b2c-f6ee3efa4714
📒 Files selected for processing (1)
conf/db/upgrade/V5.5.12__schema.sql
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (5)
header/src/main/java/org/zstack/header/core/APIShowPoolStatusMsg.java (1)
14-15: 缺少__example__方法根据编码规范,API 类需要实现
__example__方法以便生成 API 文档。请添加该方法。♻️ 建议添加
public class APIShowPoolStatusMsg extends APISyncCallMessage { + public static APIShowPoolStatusMsg __example__() { + APIShowPoolStatusMsg msg = new APIShowPoolStatusMsg(); + return msg; + } }🤖 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/core/APIShowPoolStatusMsg.java` around lines 14 - 15, Add a static __example__ method to the APIShowPoolStatusMsg class that returns a populated example instance for API documentation; implement public static APIShowPoolStatusMsg __example__() { APIShowPoolStatusMsg msg = new APIShowPoolStatusMsg(); /* set example fields if any */ return msg; } so the class (APIShowPoolStatusMsg) provides a concrete example object for doc generation.core/src/main/java/org/zstack/core/CoreManagerImpl.java (1)
151-173: 避免使用魔法值
limit(20)中的数字20应提取为命名常量,以提高代码可读性和可维护性。♻️ 建议定义常量
public class CoreManagerImpl extends AbstractService implements CoreManager { private static final CLogger logger = Utils.getLogger(CoreManagerImpl.class); + private static final int TOP_ENTRIES_LIMIT = 20; // ... 省略其他代码 ... chainStats.entrySet().stream() .sorted((a, b) -> Long.compare(b.getValue().getPendingTaskNum(), a.getValue().getPendingTaskNum())) - .limit(20) + .limit(TOP_ENTRIES_LIMIT) .forEach(e -> { // ... 同样适用于 syncStats 的 limit(20) ...🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@core/src/main/java/org/zstack/core/CoreManagerImpl.java` around lines 151 - 173, The code in CoreManagerImpl uses the magic number 20 in limit(20) for both chain and sync task stats; extract this into a named constant (e.g., private static final int POOL_STATUS_LIMIT = 20) and replace both occurrences of limit(20) with limit(POOL_STATUS_LIMIT) so the purpose is clear and maintainable; update any related Javadoc or comments near the class-level constant and ensure the constant name is descriptive (such as POOL_STATUS_TOP_N or POOL_STATUS_LIMIT) and placed as a static field in CoreManagerImpl.header/src/main/java/org/zstack/header/core/APIShowPoolStatusReply.java (1)
10-24: 缺少__example__方法根据编码规范,API Reply 类也需要实现
__example__方法以便生成 API 文档。♻️ 建议添加
public class APIShowPoolStatusReply extends APIReply { private List<PoolStatusEntry> entries = new ArrayList<>(); + public static APIShowPoolStatusReply __example__() { + APIShowPoolStatusReply reply = new APIShowPoolStatusReply(); + PoolStatusEntry entry = new PoolStatusEntry(); + entry.setName("main-thread-pool"); + entry.setPoolType("ThreadPool"); + entry.setActive(5); + entry.setPending(10); + entry.setMax(50); + entry.setUtilization(10.0); + entry.setStatus("OK"); + reply.addEntry(entry); + return reply; + } + public List<PoolStatusEntry> getEntries() {🤖 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/core/APIShowPoolStatusReply.java` around lines 10 - 24, Add a static __example__ method to APIShowPoolStatusReply that returns a populated example instance for docs; implement __example__ in the APIShowPoolStatusReply class to create a new APIShowPoolStatusReply, construct one or more PoolStatusEntry examples (filling required fields on PoolStatusEntry), use addEntry or setEntries to attach them, and return the reply. Ensure the method is public static APIShowPoolStatusReply __example__() and uses realistic sample values so automatic API documentation can render the reply example.header/src/main/java/org/zstack/header/core/PoolStatusEntry.java (2)
22-22: 避免使用魔法值,建议使用常量或枚举状态阈值
80和60以及状态字符串"CRITICAL"、"WARNING"、"OK"属于魔法值,应提取为常量或枚举类型以提高可读性和可维护性。♻️ 建议使用常量定义
public class PoolStatusEntry { + private static final int CRITICAL_THRESHOLD = 80; + private static final int WARNING_THRESHOLD = 60; + + public static final String STATUS_CRITICAL = "CRITICAL"; + public static final String STATUS_WARNING = "WARNING"; + public static final String STATUS_OK = "OK"; + private String name; // ... 其他字段 ... public PoolStatusEntry(String name, String poolType, int active, int pending, int max) { // ... 初始化字段 ... this.utilization = max > 0 ? (double) active * 100 / max : 0; - this.status = utilization >= 80 ? "CRITICAL" : utilization >= 60 ? "WARNING" : "OK"; + this.status = utilization >= CRITICAL_THRESHOLD ? STATUS_CRITICAL + : utilization >= WARNING_THRESHOLD ? STATUS_WARNING : STATUS_OK; }🤖 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/core/PoolStatusEntry.java` at line 22, The inline ternary uses magic numbers and strings—refactor PoolStatusEntry to replace the hard-coded thresholds and status strings: introduce static final int WARNING_THRESHOLD and CRITICAL_THRESHOLD (e.g., WARNING_THRESHOLD = 60, CRITICAL_THRESHOLD = 80) or, better, define an enum (e.g., PoolStatus {OK, WARNING, CRITICAL}) and use that for the status field; then change the assignment that references utilization to compare against the new constants/enum and set status to the enum value (or enum.name()) instead of literal strings to improve readability and maintainability.
12-23: 通过 setter 设置字段时utilization和status不会自动计算使用无参构造函数后通过 setter 设置字段时,
utilization和status不会被自动计算,可能导致数据不一致。如果支持通过 setter 构建对象,建议在相关 setter 中触发重新计算,或者将计算逻辑移到 getter 中实现惰性计算。♻️ 可选方案:在 getter 中惰性计算
public double getUtilization() { + if (max > 0 && utilization == 0 && active > 0) { + return (double) active * 100 / max; + } return utilization; } public String getStatus() { + if (status == null && max > 0) { + double util = getUtilization(); + return util >= 80 ? "CRITICAL" : util >= 60 ? "WARNING" : "OK"; + } return status; }🤖 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/core/PoolStatusEntry.java` around lines 12 - 23, The class PoolStatusEntry currently computes utilization and status only in the all-args constructor (PoolStatusEntry(String name, String poolType, int active, int pending, int max)), so objects built via the no-arg constructor and setters end up with stale utilization/status; update the setters for active, pending and max (and any other setters that affect those values) to call a private helper (e.g., recalcUtilizationAndStatus()) after mutating fields, or alternatively move the computation into the getters for utilization and status to compute lazily based on current active/max values; reference PoolStatusEntry, its setters for active/pending/max and the constructor when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@core/src/main/java/org/zstack/core/CoreManagerImpl.java`:
- Around line 147-148: The code casts long results from tps.getQueuedTaskNum()
and tps.getMaxPoolSize() to int when constructing the PoolStatusEntry (in the
reply.addEntry call), which can overflow; change the conversion to a safe
conversion using Math.toIntExact(...) for both queued and max pool values or
alternatively change PoolStatusEntry's corresponding fields to long and update
its constructor and usages accordingly; if you choose Math.toIntExact, also
handle/propagate the possible ArithmeticException where values exceed int range
so the system fails fast with a clear error.
---
Nitpick comments:
In `@core/src/main/java/org/zstack/core/CoreManagerImpl.java`:
- Around line 151-173: The code in CoreManagerImpl uses the magic number 20 in
limit(20) for both chain and sync task stats; extract this into a named constant
(e.g., private static final int POOL_STATUS_LIMIT = 20) and replace both
occurrences of limit(20) with limit(POOL_STATUS_LIMIT) so the purpose is clear
and maintainable; update any related Javadoc or comments near the class-level
constant and ensure the constant name is descriptive (such as POOL_STATUS_TOP_N
or POOL_STATUS_LIMIT) and placed as a static field in CoreManagerImpl.
In `@header/src/main/java/org/zstack/header/core/APIShowPoolStatusMsg.java`:
- Around line 14-15: Add a static __example__ method to the APIShowPoolStatusMsg
class that returns a populated example instance for API documentation; implement
public static APIShowPoolStatusMsg __example__() { APIShowPoolStatusMsg msg =
new APIShowPoolStatusMsg(); /* set example fields if any */ return msg; } so the
class (APIShowPoolStatusMsg) provides a concrete example object for doc
generation.
In `@header/src/main/java/org/zstack/header/core/APIShowPoolStatusReply.java`:
- Around line 10-24: Add a static __example__ method to APIShowPoolStatusReply
that returns a populated example instance for docs; implement __example__ in the
APIShowPoolStatusReply class to create a new APIShowPoolStatusReply, construct
one or more PoolStatusEntry examples (filling required fields on
PoolStatusEntry), use addEntry or setEntries to attach them, and return the
reply. Ensure the method is public static APIShowPoolStatusReply __example__()
and uses realistic sample values so automatic API documentation can render the
reply example.
In `@header/src/main/java/org/zstack/header/core/PoolStatusEntry.java`:
- Line 22: The inline ternary uses magic numbers and strings—refactor
PoolStatusEntry to replace the hard-coded thresholds and status strings:
introduce static final int WARNING_THRESHOLD and CRITICAL_THRESHOLD (e.g.,
WARNING_THRESHOLD = 60, CRITICAL_THRESHOLD = 80) or, better, define an enum
(e.g., PoolStatus {OK, WARNING, CRITICAL}) and use that for the status field;
then change the assignment that references utilization to compare against the
new constants/enum and set status to the enum value (or enum.name()) instead of
literal strings to improve readability and maintainability.
- Around line 12-23: The class PoolStatusEntry currently computes utilization
and status only in the all-args constructor (PoolStatusEntry(String name, String
poolType, int active, int pending, int max)), so objects built via the no-arg
constructor and setters end up with stale utilization/status; update the setters
for active, pending and max (and any other setters that affect those values) to
call a private helper (e.g., recalcUtilizationAndStatus()) after mutating
fields, or alternatively move the computation into the getters for utilization
and status to compute lazily based on current active/max values; reference
PoolStatusEntry, its setters for active/pending/max and the constructor when
making the change.
ℹ️ 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: 0bbd15fe-c740-49d6-8f8f-e4fb732d6469
📒 Files selected for processing (4)
core/src/main/java/org/zstack/core/CoreManagerImpl.javaheader/src/main/java/org/zstack/header/core/APIShowPoolStatusMsg.javaheader/src/main/java/org/zstack/header/core/APIShowPoolStatusReply.javaheader/src/main/java/org/zstack/header/core/PoolStatusEntry.java
| reply.addEntry(new PoolStatusEntry("main-thread-pool", "ThreadPool", | ||
| tps.getActiveThreadNum(), (int) tps.getQueuedTaskNum(), (int) tps.getMaxPoolSize())); |
There was a problem hiding this comment.
long 转 int 存在潜在溢出风险
tps.getQueuedTaskNum() 和 tps.getMaxPoolSize() 返回 long 类型,强制转换为 int 在极端情况下可能导致数据溢出。建议使用 Math.toIntExact() 进行安全转换,或将 PoolStatusEntry 的字段类型改为 long。
♻️ 使用安全转换
if (thdf instanceof ThreadFacadeMXBean) {
ThreadPoolStatistic tps = ((ThreadFacadeMXBean) thdf).getThreadPoolStatistic();
reply.addEntry(new PoolStatusEntry("main-thread-pool", "ThreadPool",
- tps.getActiveThreadNum(), (int) tps.getQueuedTaskNum(), (int) tps.getMaxPoolSize()));
+ tps.getActiveThreadNum(),
+ (int) Math.min(tps.getQueuedTaskNum(), Integer.MAX_VALUE),
+ (int) Math.min(tps.getMaxPoolSize(), Integer.MAX_VALUE)));
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@core/src/main/java/org/zstack/core/CoreManagerImpl.java` around lines 147 -
148, The code casts long results from tps.getQueuedTaskNum() and
tps.getMaxPoolSize() to int when constructing the PoolStatusEntry (in the
reply.addEntry call), which can overflow; change the conversion to a safe
conversion using Math.toIntExact(...) for both queued and max pool values or
alternatively change PoolStatusEntry's corresponding fields to long and update
its constructor and usages accordingly; if you choose Math.toIntExact, also
handle/propagate the possible ArithmeticException where values exceed int range
so the system fails fast with a clear error.
9856e6f to
68af768
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
conf/db/upgrade/V5.5.12__schema.sql (1)
36-38: 代码变更看起来没问题。新增
targetQueueKey列的实现遵循了文件中已有的模式,列设为可空(nullable)对于新功能的上线是安全的,现有数据无需回填处理。
VARCHAR(256)对于存储服务端点 URL(scheme://host:port格式)是合理的长度选择。可选建议:如果后续会频繁按
targetQueueKey进行查询或分组(例如队列管理、并发控制逻辑),可以考虑添加索引以提升查询性能:CALL CREATE_INDEX('ModelEvaluationTaskVO', 'idx_ModelEvaluationTaskVO_targetQueueKey', 'targetQueueKey');这取决于实际的查询模式,如果只是写入时设置该字段而不常查询,则无需添加索引。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@conf/db/upgrade/V5.5.12__schema.sql` around lines 36 - 38, New nullable column targetQueueKey was added to ModelEvaluationTaskVO; if this field will be frequently queried or grouped, add an index to improve performance by calling CREATE_INDEX for ModelEvaluationTaskVO on targetQueueKey (e.g., CREATE_INDEX('ModelEvaluationTaskVO','idx_ModelEvaluationTaskVO_targetQueueKey','targetQueueKey')); if queries are rare, leave as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@conf/db/upgrade/V5.5.12__schema.sql`:
- Around line 36-38: New nullable column targetQueueKey was added to
ModelEvaluationTaskVO; if this field will be frequently queried or grouped, add
an index to improve performance by calling CREATE_INDEX for
ModelEvaluationTaskVO on targetQueueKey (e.g.,
CREATE_INDEX('ModelEvaluationTaskVO','idx_ModelEvaluationTaskVO_targetQueueKey','targetQueueKey'));
if queries are rare, leave as-is.
ℹ️ 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: 7d742591-34c4-451b-b429-0147b38730c4
📒 Files selected for processing (1)
conf/db/upgrade/V5.5.12__schema.sql
68af768 to
32decb6
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
header/src/main/java/org/zstack/header/core/PoolStatusEntry.java (1)
6-23:⚠️ Potential issue | 🟠 Major
int容量不够,当前统计值已经被调用侧强转了。这些池统计量在当前实现里来自
long,这里定义成int会迫使调用侧截断,极端情况下会把返回值和利用率/状态一起算错。更稳妥的是把active、pending、max以及对应构造参数统一改成long。Based on learnings, “在 ZStack 代码库中,当响应类包含数值字段(如 size、actualSize)时,优先使用原始类型(long)而不是包装类型(Long),以避免 NPE 风险和不必要的装箱/拆箱操作。”
🤖 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/core/PoolStatusEntry.java` around lines 6 - 23, The fields active, pending, and max in PoolStatusEntry are declared as int but should be long to match callers and avoid truncation; change the field types (active, pending, max) and the constructor signature PoolStatusEntry(String name, String poolType, int active, int pending, int max) to use long parameters, update assignments accordingly, and recalc utilization using a long-to-double cast (e.g., (double) active * 100 / max with a max>0 guard) and keep the status logic the same; also search for any usages that construct PoolStatusEntry and update those call sites to pass long values.
🧹 Nitpick comments (1)
header/src/main/java/org/zstack/header/core/PoolStatusEntry.java (1)
45-79: 派生字段会和基础字段失去同步。
utilization和status只在构造函数里计算一次,但setActive()、setMax()、setUtilization()、setStatus()都是公开的;后续只要有人改了基础值,这个 DTO 就可能返回自相矛盾的数据。建议要么改成不可变对象,要么在基础字段 setter 里统一重算,并去掉派生字段的 setter。🤖 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/core/PoolStatusEntry.java` around lines 45 - 79, PoolStatusEntry exposes mutable derived fields (utilization, status) that are only computed in the constructor, causing inconsistency when base fields change; make the DTO consistent by removing public setters for derived fields (remove setUtilization and setStatus) and recomputing derived values inside the base-field setters (setActive, setPending if present, setMax) or alternatively make the whole PoolStatusEntry immutable; update methods in PoolStatusEntry so setActive and setMax always recalculate utilization and status from active/max (and pending if used) and ensure getters return those recomputed values.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@conf/db/upgrade/V5.5.12__schema.sql`:
- Around line 48-49: The new column targetQueueKey on ModelEvaluationTaskVO uses
VARCHAR(256) which is too small for external endpoint keys; change the migration
CALL ADD_COLUMN('ModelEvaluationTaskVO', 'targetQueueKey', ...) to use a TEXT
type instead of VARCHAR(256) (or alternatively pick a documented upper bound and
sync upstream validation and the column width), ensuring the change is applied
in the ADD_COLUMN invocation so the DB stores arbitrary-length endpoint keys
without truncation or write failure.
In `@header/src/main/java/org/zstack/header/core/APIShowPoolStatusMsg.java`:
- Around line 8-15: Add a static example factory to the new API message class so
the docs/templates can be generated: implement a public static
APIShowPoolStatusMsg __example__() method in APIShowPoolStatusMsg that
constructs and returns a populated example instance (use default/sample values
if any fields exist) and ensure it follows the same pattern as other API message
classes (create instance, set any sample properties, return instance).
---
Duplicate comments:
In `@header/src/main/java/org/zstack/header/core/PoolStatusEntry.java`:
- Around line 6-23: The fields active, pending, and max in PoolStatusEntry are
declared as int but should be long to match callers and avoid truncation; change
the field types (active, pending, max) and the constructor signature
PoolStatusEntry(String name, String poolType, int active, int pending, int max)
to use long parameters, update assignments accordingly, and recalc utilization
using a long-to-double cast (e.g., (double) active * 100 / max with a max>0
guard) and keep the status logic the same; also search for any usages that
construct PoolStatusEntry and update those call sites to pass long values.
---
Nitpick comments:
In `@header/src/main/java/org/zstack/header/core/PoolStatusEntry.java`:
- Around line 45-79: PoolStatusEntry exposes mutable derived fields
(utilization, status) that are only computed in the constructor, causing
inconsistency when base fields change; make the DTO consistent by removing
public setters for derived fields (remove setUtilization and setStatus) and
recomputing derived values inside the base-field setters (setActive, setPending
if present, setMax) or alternatively make the whole PoolStatusEntry immutable;
update methods in PoolStatusEntry so setActive and setMax always recalculate
utilization and status from active/max (and pending if used) and ensure getters
return those recomputed values.
ℹ️ 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: 8abd8e8f-6bcc-41af-89f0-cbdf4d9117b3
📒 Files selected for processing (5)
conf/db/upgrade/V5.5.12__schema.sqlcore/src/main/java/org/zstack/core/CoreManagerImpl.javaheader/src/main/java/org/zstack/header/core/APIShowPoolStatusMsg.javaheader/src/main/java/org/zstack/header/core/APIShowPoolStatusReply.javaheader/src/main/java/org/zstack/header/core/PoolStatusEntry.java
| @Action(category = CoreConstant.ACTION_CATEGORY, adminOnly = true) | ||
| @RestRequest( | ||
| path = "/core/pool-status", | ||
| method = HttpMethod.GET, | ||
| responseClass = APIShowPoolStatusReply.class | ||
| ) | ||
| public class APIShowPoolStatusMsg extends APISyncCallMessage { | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
补上 __example__(),否则这个新 API 不满足仓库约定。
当前类是新增 API Message,但没有 __example__(),后面的 API 文档和模板生成链就缺少示例入口了。
As per coding guidelines, “API 类需要实现 __example__ 方法以便生成 API 文档,并确保生成对应的 Groovy API Template 与 API Markdown 文件”。
🤖 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/core/APIShowPoolStatusMsg.java` around
lines 8 - 15, Add a static example factory to the new API message class so the
docs/templates can be generated: implement a public static APIShowPoolStatusMsg
__example__() method in APIShowPoolStatusMsg that constructs and returns a
populated example instance (use default/sample values if any fields exist) and
ensure it follows the same pattern as other API message classes (create
instance, set any sample properties, return instance).
2de9a58 to
b9ead87
Compare
Resolves: ZSTAC-68709 Change-Id: I66b2038656387bc3b3555db20cdfddb31d82d914
b9ead87 to
363238c
Compare
ZSTAC-68709: 评测任务排队机制
问题
评测任务同时提交到同一服务端点时,会导致端点过载。缺少按端点的并发控制机制。
方案
targetQueueKey列到ModelEvaluationTaskVO,标识目标服务端点(scheme://host:port)Pending状态用于排队等待的任务zstack 仓库改动
V5.5.12__schema.sql: 添加targetQueueKeyVARCHAR(256) 列关联 MR
sync from gitlab !9295