<feature>[conf]: add live recovery alert schema#4407
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 44 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
Walkthrough本次变更为 LiveRecovery 告警功能新增数据库表结构(告警源与告警事件表),并在 SDK 中新增对应的实体类、类型映射条目,以及注册告警源和推送告警事件两个 API Action 及其请求/响应模型类。 ChangesLiveRecovery 告警 SDK 与schema
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
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
767dd29 to
5eac46e
Compare
There was a problem hiding this comment.
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
📒 Files selected for processing (7)
conf/db/zsv/V5.1.1__schema.sqlsdk/src/main/java/SourceClassMap.javasdk/src/main/java/org/zstack/sdk/zwatch/liverecovery/api/PushLiveRecoveryAlertEventAction.javasdk/src/main/java/org/zstack/sdk/zwatch/liverecovery/api/PushLiveRecoveryAlertEventResult.javasdk/src/main/java/org/zstack/sdk/zwatch/liverecovery/api/RegisterLiveRecoveryAlertSourceAction.javasdk/src/main/java/org/zstack/sdk/zwatch/liverecovery/api/RegisterLiveRecoveryAlertSourceResult.javasdk/src/main/java/org/zstack/sdk/zwatch/liverecovery/entity/LiveRecoveryAlertSourceInventory.java
| 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; | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
📐 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
| 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; | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
📐 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
a5933a8 to
6ef0d76
Compare
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
6ef0d76 to
55d3306
Compare
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