Skip to content

<fix>[zwatch]: clean alarm resource state label and prune stale ones#4341

Open
MatheMatrix wants to merge 1 commit into
feature-5.5.28-alarm-optimizefrom
sync/yaohua.wu/bugfix/ZSTAC-85397@@2
Open

<fix>[zwatch]: clean alarm resource state label and prune stale ones#4341
MatheMatrix wants to merge 1 commit into
feature-5.5.28-alarm-optimizefrom
sync/yaohua.wu/bugfix/ZSTAC-85397@@2

Conversation

@MatheMatrix

Copy link
Copy Markdown
Owner

ZSTAC-85397

Root Cause

The alarm resource state row was keyed only by (alarmUuid, identifyLabel). Now that identifyLabel stores the clean per-resource label (e.g. CPUNum:19), two resources under one multi-resource alarm can share the same label, so the unique key must also include resourceUuid.

Changes

Module Change
conf AlarmResourceStateVO unique key extended with resourceUuid; identifyLabel 200 to 191 so the composite unique key stays within the CI MySQL 255-char limit

Test

  • this is the AlarmResourceStateVO table in the in-development V5.5.28 migration (table was added on this same feature branch, so the create statement is amended in place)

Related MRs

  • premium MR: !14451 (the zwatch code change carrying the clean-label + prune logic)

Related: ZSTAC-85397
Related: SUG-2677

sync from gitlab !10302

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@MatheMatrix, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 8 minutes and 28 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

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 credits.

🚦 How do rate 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 see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 54c7face-7036-4768-9d8a-88c16dcc83f9

📥 Commits

Reviewing files that changed from the base of the PR and between 1acd8e1 and 6058905.

📒 Files selected for processing (1)
  • conf/db/upgrade/V5.5.28__schema.sql

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Could not fetch remote config from http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml: TimeoutError: The operation was aborted due to timeout
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sync/yaohua.wu/bugfix/ZSTAC-85397@@2

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

The per-resource alarm state now stores a clean identify label and
drops residual states when a metric series disappears.

1. Why is this change necessary?
AlarmResourceState.identifyLabel stored the whole metric series key
(e.g. ::CPUNum:19::::VMUuid:x::), so the alarm detail page showed the
VMUuid that resourceUuid already carries. And when a series vanished
while its resource stayed (e.g. a vCPU dropped after a cpu downsize),
the state was only marked InsufficientData and lingered forever.

2. How does it address the problem?
identifyLabel now persists the clean per-resource label (CPUNum:19);
the resource identity stays in resourceUuid, so the row key becomes
(alarmUuid, identifyLabel, resourceUuid) and its unique index follows
(identifyLabel shrinks to 191 to keep the composite key within the CI
MySQL limit). Rule rebuild reconstructs the full series key from the
stored row, so the recovery pairing keeps matching the rule engine.
A series missing this round whose resource still reports other series
is deleted; a fully silent resource stays InsufficientData.

3. Are there any side effects?
identifyLabel of existing rows changes shape; acceptable on this
unreleased feature branch. No behavior change for silent resources.

# Summary of changes (by module):
- zwatch: store clean identifyLabel, (alarm,label,resourceUuid) row
  key, series-key reconstruction on rebuild, prune departed series
- conf: AlarmResourceStateVO unique key + identifyLabel length

Related: ZSTAC-85397
Related: SUG-2677
Change-Id: Ie8fa813292de89766f0733089a3610e09f88cfae
@MatheMatrix MatheMatrix force-pushed the sync/yaohua.wu/bugfix/ZSTAC-85397@@2 branch from c2bd291 to 6058905 Compare June 26, 2026 09:29
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