Skip to content

<feature>[conf]: add live recovery alert schema#4407

Open
ZStack-Robot wants to merge 1 commit into
feature-zsv-5.1.0-zlrfrom
sync/tao.gan/zlr-ZSV-12277@@2
Open

<feature>[conf]: add live recovery alert schema#4407
ZStack-Robot wants to merge 1 commit into
feature-zsv-5.1.0-zlrfrom
sync/tao.gan/zlr-ZSV-12277@@2

Conversation

@ZStack-Robot

Copy link
Copy Markdown
Collaborator

Add ZStack Live Recovery alert receiver persistence tables for the native platform alarm design.

Why is this change necessary?
ZLR pushes finalized local alert events into ZSV as a native ZStack Live Recovery alert source, so ZSV needs durable source registration and per-event ingestion records.

How does it address the problem?
The migration adds LiveRecoveryAlertSourceVO for idempotent source ownership and LiveRecoveryAlertEventVO for deduplicated alert event ingestion by source/event/sequence.

Side effects and compatibility:
This is additive schema only. Existing ZWatch and third-party alert tables are untouched; the new tables are consumed by the premium zwatch implementation in the same branch.

DBImpact

Resolves: ZSV-12277

Change-Id: I6a6f73766d62756b71687077766b787371676e63

sync from gitlab !10366

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 44 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ea871ee3-db77-489d-8fab-8fa3a2f8e5e7

📥 Commits

Reviewing files that changed from the base of the PR and between 767dd29 and 55d3306.

📒 Files selected for processing (3)
  • sdk/src/main/java/org/zstack/sdk/zwatch/liverecovery/api/PushLiveRecoveryAlertEventAction.java
  • sdk/src/main/java/org/zstack/sdk/zwatch/liverecovery/api/PushLiveRecoveryAlertResult.java
  • testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy

Walkthrough

本次变更为 LiveRecovery 告警功能新增数据库表结构(告警源与告警事件表),并在 SDK 中新增对应的实体类、类型映射条目,以及注册告警源和推送告警事件两个 API Action 及其请求/响应模型类。

Changes

LiveRecovery 告警 SDK 与schema

Layer / File(s) Summary
数据库表结构定义
conf/db/zsv/V5.1.1__schema.sql
新增 LiveRecoveryAlertSourceVOLiveRecoveryAlertEventVO 两张表,定义主键、唯一约束及索引。
告警源实体与SDK类型映射
sdk/.../entity/LiveRecoveryAlertSourceInventory.java, sdk/.../SourceClassMap.java
新增 LiveRecoveryAlertSourceInventory 实体类及其字段访问方法,并在类型映射表中注册双向转换条目。
注册告警源 Action
sdk/.../api/RegisterLiveRecoveryAlertSourceAction.java, sdk/.../api/RegisterLiveRecoveryAlertSourceResult.java
新增注册告警源的 SDK Action,包含请求参数、Result 封装、同步/异步 call 方法及 REST 配置,以及对应的结果类。
推送告警事件 Action
sdk/.../api/PushLiveRecoveryAlertEventAction.java, sdk/.../api/PushLiveRecoveryAlertEventResult.java
新增推送告警事件的 SDK Action 及其结果类,支持同步/异步调用与错误处理。

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant RegisterLiveRecoveryAlertSourceAction
  participant PushLiveRecoveryAlertEventAction
  participant ZSClient
  participant Server

  Client->>RegisterLiveRecoveryAlertSourceAction: call()
  RegisterLiveRecoveryAlertSourceAction->>ZSClient: ZSClient.call(this)
  ZSClient->>Server: POST /zwatch/live-recovery/alert-sources
  Server-->>ZSClient: ApiResult(inventory)
  ZSClient-->>Client: Result

  Client->>PushLiveRecoveryAlertEventAction: call()
  PushLiveRecoveryAlertEventAction->>ZSClient: ZSClient.call(this)
  ZSClient->>Server: POST /zwatch/live-recovery/alert-sources/{sourceUuid}/events
  Server-->>ZSClient: ApiResult(PushLiveRecoveryAlertEventResult)
  ZSClient-->>Client: Result
Loading

Poem

兔子敲键咚咚响,新表新类齐上场,
告警源头有归处,事件推送不慌张,
uuid 一对一映射,SDK 里安个家,
🐇 蹦跳提交此 PR,愿评审顺风又顺水~

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了新增 Live Recovery 告警 schema 的主要变更。
Description check ✅ Passed 描述与新增 Live Recovery 告警持久化表及其用途一致。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sync/tao.gan/zlr-ZSV-12277@@2

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

@MatheMatrix MatheMatrix force-pushed the sync/tao.gan/zlr-ZSV-12277@@2 branch from 767dd29 to 5eac46e Compare July 1, 2026 14:45

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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
`@sdk/src/main/java/org/zstack/sdk/zwatch/liverecovery/api/PushLiveRecoveryAlertEventAction.java`:
- Around line 7-104: `PushLiveRecoveryAlertEventAction` is missing the required
`__example__()` implementation, which breaks the API doc generation chain. Add
an `__example__()` method to this action class, following the same pattern used
by other SDK action classes, so the Groovy API Template and API Markdown can be
generated correctly. Ensure the example covers the required request fields like
`sourceUuid` and `payloadJson` and keeps the class consistent with the existing
`call()`/`getRestInfo()` structure.

In
`@sdk/src/main/java/org/zstack/sdk/zwatch/liverecovery/api/RegisterLiveRecoveryAlertSourceAction.java`:
- Around line 7-119: `RegisterLiveRecoveryAlertSourceAction` is missing the
`__example__()` method, which breaks the SDK API documentation generation chain.
Add `__example__()` to this Action class in the same pattern used by other API
action classes, using the class name and its public parameters such as
`sourceUuid`, `sourceSiteId`, and `managementUrl` so the Groovy API Template and
API Markdown can be generated correctly.
🪄 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: c33e77c8-dfdc-4326-9c63-817ca9fefa68

📥 Commits

Reviewing files that changed from the base of the PR and between 1a08b21 and 767dd29.

📒 Files selected for processing (7)
  • conf/db/zsv/V5.1.1__schema.sql
  • sdk/src/main/java/SourceClassMap.java
  • sdk/src/main/java/org/zstack/sdk/zwatch/liverecovery/api/PushLiveRecoveryAlertEventAction.java
  • sdk/src/main/java/org/zstack/sdk/zwatch/liverecovery/api/PushLiveRecoveryAlertEventResult.java
  • sdk/src/main/java/org/zstack/sdk/zwatch/liverecovery/api/RegisterLiveRecoveryAlertSourceAction.java
  • sdk/src/main/java/org/zstack/sdk/zwatch/liverecovery/api/RegisterLiveRecoveryAlertSourceResult.java
  • sdk/src/main/java/org/zstack/sdk/zwatch/liverecovery/entity/LiveRecoveryAlertSourceInventory.java

Comment on lines +7 to +104
public class PushLiveRecoveryAlertEventAction extends AbstractAction {

private static final HashMap<String, Parameter> parameterMap = new HashMap<>();

private static final HashMap<String, Parameter> nonAPIParameterMap = new HashMap<>();

public static class Result {
public ErrorCode error;
public org.zstack.sdk.zwatch.liverecovery.api.PushLiveRecoveryAlertEventResult value;

public Result throwExceptionIfError() {
if (error != null) {
throw new ApiException(
String.format("error[code: %s, description: %s, details: %s]", error.code, error.description, error.details)
);
}

return this;
}
}

@Param(required = true, maxLength = 64, nonempty = false, nullElements = false, emptyString = true, noTrim = false)
public java.lang.String sourceUuid;

@Param(required = true, maxLength = 65536, nonempty = false, nullElements = false, emptyString = true, noTrim = false)
public java.lang.String payloadJson;

@Param(required = false)
public java.util.List systemTags;

@Param(required = false)
public java.util.List userTags;

@Param(required = false)
public String sessionId;

@Param(required = false)
public String accessKeyId;

@Param(required = false)
public String accessKeySecret;

@Param(required = false)
public String requestIp;

@NonAPIParam
public long timeout = -1;

@NonAPIParam
public long pollingInterval = -1;


private Result makeResult(ApiResult res) {
Result ret = new Result();
if (res.error != null) {
ret.error = res.error;
return ret;
}

org.zstack.sdk.zwatch.liverecovery.api.PushLiveRecoveryAlertEventResult value = res.getResult(org.zstack.sdk.zwatch.liverecovery.api.PushLiveRecoveryAlertEventResult.class);
ret.value = value == null ? new org.zstack.sdk.zwatch.liverecovery.api.PushLiveRecoveryAlertEventResult() : value;

return ret;
}

public Result call() {
ApiResult res = ZSClient.call(this);
return makeResult(res);
}

public void call(final Completion<Result> completion) {
ZSClient.call(this, new InternalCompletion() {
@Override
public void complete(ApiResult res) {
completion.complete(makeResult(res));
}
});
}

protected Map<String, Parameter> getParameterMap() {
return parameterMap;
}

protected Map<String, Parameter> getNonAPIParameterMap() {
return nonAPIParameterMap;
}

protected RestInfo getRestInfo() {
RestInfo info = new RestInfo();
info.httpMethod = "POST";
info.path = "/zwatch/live-recovery/alert-sources/{sourceUuid}/events";
info.needSession = true;
info.needPoll = true;
info.parameterName = "params";
return info;
}

}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

补上 __example__(),否则 API 文档链路不完整。

这个 Action 是对外的 SDK API,当前缺失 __example__,会导致对应的 Groovy API Template / API Markdown 生成链路断掉。

As per path instructions, API 类需要实现 __example__ 方法以便生成 API 文档,并确保生成对应的 Groovy API Template 与 API Markdown 文件.

🤖 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
`@sdk/src/main/java/org/zstack/sdk/zwatch/liverecovery/api/PushLiveRecoveryAlertEventAction.java`
around lines 7 - 104, `PushLiveRecoveryAlertEventAction` is missing the required
`__example__()` implementation, which breaks the API doc generation chain. Add
an `__example__()` method to this action class, following the same pattern used
by other SDK action classes, so the Groovy API Template and API Markdown can be
generated correctly. Ensure the example covers the required request fields like
`sourceUuid` and `payloadJson` and keeps the class consistent with the existing
`call()`/`getRestInfo()` structure.

Source: Path instructions

Comment on lines +7 to +119
public class RegisterLiveRecoveryAlertSourceAction extends AbstractAction {

private static final HashMap<String, Parameter> parameterMap = new HashMap<>();

private static final HashMap<String, Parameter> nonAPIParameterMap = new HashMap<>();

public static class Result {
public ErrorCode error;
public org.zstack.sdk.zwatch.liverecovery.api.RegisterLiveRecoveryAlertSourceResult value;

public Result throwExceptionIfError() {
if (error != null) {
throw new ApiException(
String.format("error[code: %s, description: %s, details: %s]", error.code, error.description, error.details)
);
}

return this;
}
}

@Param(required = true, maxLength = 64, nonempty = false, nullElements = false, emptyString = true, noTrim = false)
public java.lang.String sourceUuid;

@Param(required = false, maxLength = 128, nonempty = false, nullElements = false, emptyString = true, noTrim = false)
public java.lang.String sourceSiteId;

@Param(required = false, maxLength = 2048, nonempty = false, nullElements = false, emptyString = true, noTrim = false)
public java.lang.String managementUrl;

@Param(required = false, maxLength = 255, nonempty = false, nullElements = false, emptyString = true, noTrim = false)
public java.lang.String displayName;

@Param(required = false, maxLength = 64, nonempty = false, nullElements = false, emptyString = true, noTrim = false)
public java.lang.String version;

@Param(required = false)
public java.lang.String resourceUuid;

@Param(required = false, nonempty = false, nullElements = false, emptyString = true, noTrim = false)
public java.util.List tagUuids;

@Param(required = false)
public java.util.List systemTags;

@Param(required = false)
public java.util.List userTags;

@Param(required = false)
public String sessionId;

@Param(required = false)
public String accessKeyId;

@Param(required = false)
public String accessKeySecret;

@Param(required = false)
public String requestIp;

@NonAPIParam
public long timeout = -1;

@NonAPIParam
public long pollingInterval = -1;


private Result makeResult(ApiResult res) {
Result ret = new Result();
if (res.error != null) {
ret.error = res.error;
return ret;
}

org.zstack.sdk.zwatch.liverecovery.api.RegisterLiveRecoveryAlertSourceResult value = res.getResult(org.zstack.sdk.zwatch.liverecovery.api.RegisterLiveRecoveryAlertSourceResult.class);
ret.value = value == null ? new org.zstack.sdk.zwatch.liverecovery.api.RegisterLiveRecoveryAlertSourceResult() : value;

return ret;
}

public Result call() {
ApiResult res = ZSClient.call(this);
return makeResult(res);
}

public void call(final Completion<Result> completion) {
ZSClient.call(this, new InternalCompletion() {
@Override
public void complete(ApiResult res) {
completion.complete(makeResult(res));
}
});
}

protected Map<String, Parameter> getParameterMap() {
return parameterMap;
}

protected Map<String, Parameter> getNonAPIParameterMap() {
return nonAPIParameterMap;
}

protected RestInfo getRestInfo() {
RestInfo info = new RestInfo();
info.httpMethod = "POST";
info.path = "/zwatch/live-recovery/alert-sources";
info.needSession = true;
info.needPoll = true;
info.parameterName = "params";
return info;
}

}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

补上 __example__(),否则 API 文档链路不完整。

这个 Action 是对外的 SDK API,当前缺失 __example__,会导致对应的 Groovy API Template / API Markdown 生成链路断掉。

As per path instructions, API 类需要实现 __example__ 方法以便生成 API 文档,并确保生成对应的 Groovy API Template 与 API Markdown 文件.

🤖 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
`@sdk/src/main/java/org/zstack/sdk/zwatch/liverecovery/api/RegisterLiveRecoveryAlertSourceAction.java`
around lines 7 - 119, `RegisterLiveRecoveryAlertSourceAction` is missing the
`__example__()` method, which breaks the SDK API documentation generation chain.
Add `__example__()` to this Action class in the same pattern used by other API
action classes, using the class name and its public parameters such as
`sourceUuid`, `sourceSiteId`, and `managementUrl` so the Groovy API Template and
API Markdown can be generated correctly.

Source: Path instructions

@MatheMatrix MatheMatrix force-pushed the sync/tao.gan/zlr-ZSV-12277@@2 branch 6 times, most recently from a5933a8 to 6ef0d76 Compare July 3, 2026 02:13
Introduce ReportedAlertSourceVO as the generic registry for pushed or
built-in reported alerts.

The schema uses sourceType plus sourceUuid as the idempotency key,
stores display metadata as JSON, and tracks owner, state, and
lastSeenDate for source management.

This replaces the earlier LiveRecovery-specific source and event
tables. Alert event payloads now flow through the native ZWatch
event-record path instead of a product-specific event table.

Remove the generic reported alert source schema and SDK bindings from the ZSV side.
Expose the Live Recovery receiver through dedicated SDK and testlib helpers that push sourceUuid and payloadJson directly.
This is a new Live Recovery integration path, so no source registration table or compatibility fallback remains.

Resolves: ZSV-12277

Change-Id: I6a78716b6f7770686f6e6d6878796b7774707a70
@MatheMatrix MatheMatrix force-pushed the sync/tao.gan/zlr-ZSV-12277@@2 branch from 6ef0d76 to 55d3306 Compare July 3, 2026 02:48
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