Skip to content

refactor(xmrig-guard): dedup deployment<->node join into one recording rule - #4416

Closed
Tanguille wants to merge 1 commit into
mainfrom
fix/xmrig-guard-dedup-deployment-join
Closed

refactor(xmrig-guard): dedup deployment<->node join into one recording rule#4416
Tanguille wants to merge 1 commit into
mainfrom
fix/xmrig-guard-dedup-deployment-join

Conversation

@Tanguille

Copy link
Copy Markdown
Owner

Summary

  • XmrigGuardEnforcementBypassed and XmrigGuardThermalPanic each independently re-implemented the xmrig-<node> Deployment-naming join via their own label_replace; a rename needed both edited in lockstep (flagged by its own comment).
  • Adds one xmrig_guard_deployment_node recording rule as the single source for that join; both alerts consume it instead.

Verified with promtool check rules (6/6 rules parse) and kubectl kustomize.

Test plan

  • promtool check rules on the extracted rule group
  • kubectl kustomize kubernetes/apps/web3/monero/guard
  • Confirm alerts still fire/clear identically once live (same set semantics, no threshold change)

…g rule

XmrigGuardEnforcementBypassed and XmrigGuardThermalPanic each ran
their own label_replace encoding the "xmrig-<node>" Deployment naming
convention; a rename required editing both in lockstep. Move it into
a single xmrig_guard_deployment_node recording rule both alerts join
through instead.
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Tanguille, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 11 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dc1cf814-83e8-4088-9bb2-7ebcce4fcb45

📥 Commits

Reviewing files that changed from the base of the PR and between f70fc97 and 1fd015c.

📒 Files selected for processing (1)
  • kubernetes/apps/web3/monero/guard/prometheusrule.yaml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@deepsource-io

deepsource-io Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

DeepSource Code Review

We reviewed changes in f70fc97...1fd015c on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript Aug 9, 2026 10:11a.m. Review ↗
Shell Aug 9, 2026 10:11a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@tanguille-cluster

Copy link
Copy Markdown
@@ spec.groups.guard.rules.rules @@
# monitoring.coreos.com/v1/PrometheusRule/web3/guard-rules
! - two list entries removed:
- - alert: XmrigGuardEnforcementBypassed
-   annotations:
-     summary: "{{ $labels.deployment }} is running while its node's thermal gate should be closed — the KEDA trip is not being enforced (operator down, HPA wedged, or manual scale)"
-   expr: |
-     kube_deployment_status_replicas{namespace="web3", deployment=~"xmrig-control-.+"} > 0
-     unless on (deployment)
-     label_replace(
-       (xmrig_guard_safe == 1)
-       and on (node) (count by (node) (xmrig_guard_safe) == 1)
-       and on (node) (timestamp(xmrig_guard_safe) >= time() - 120),
-       "deployment", "xmrig-$1", "node", "(.*)"
-     )
-   for: 10m
-   labels:
-     severity: critical
- - alert: XmrigGuardThermalPanic
-   annotations:
-     summary: "{{ $labels.node }} is above the 67C panic trip with a miner still running — the zero-dwell fast path did not shed it and the drive is near its 70C rating"
-   expr: |
-     max by (node) (xmrig_guard_nvme_temp_max_celsius) > 67
-     and on (node)
-     label_replace(
-       kube_deployment_status_replicas{namespace="web3", deployment=~"xmrig-control-.+"} > 0,
-       "node", "$1", "deployment", "xmrig-(.*)"
-     )
-   for: 2m
-   labels:
-     severity: critical
! + three list entries added:
+ - expr: "label_replace(xmrig_guard_rank, \"deployment\", \"xmrig-$1\", \"node\", \"(.*)\")"
+   record: xmrig_guard_deployment_node
+ - alert: XmrigGuardEnforcementBypassed
+   annotations:
+     summary: "{{ $labels.deployment }} is running while its node's thermal gate should be closed — the KEDA trip is not being enforced (operator down, HPA wedged, or manual scale)"
+   expr: |
+     kube_deployment_status_replicas{namespace="web3", deployment=~"xmrig-control-.+"} > 0
+     unless on (deployment)
+     (
+       xmrig_guard_deployment_node
+       and on (node)
+       (
+         (xmrig_guard_safe == 1)
+         and on (node) (count by (node) (xmrig_guard_safe) == 1)
+         and on (node) (timestamp(xmrig_guard_safe) >= time() - 120)
+       )
+     )
+   for: 10m
+   labels:
+     severity: critical
+ - alert: XmrigGuardThermalPanic
+   annotations:
+     summary: "{{ $labels.node }} is above the 67C panic trip with a miner still running — the zero-dwell fast path did not shed it and the drive is near its 70C rating"
+   expr: |
+     max by (node) (xmrig_guard_nvme_temp_max_celsius) > 67
+     and on (node)
+     (
+       xmrig_guard_deployment_node
+       and on (deployment)
+       (kube_deployment_status_replicas{namespace="web3", deployment=~"xmrig-control-.+"} > 0)
+     )
+   for: 2m
+   labels:
+     severity: critical

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

AI Automated Review

Analysis engine: omniroute@http://litellm.ai.svc.cluster.local/v1 (openai)

Recommendation: Approve. The refactoring correctly deduplicates the deployment-to-node join logic into a single recording rule, reducing maintenance risk without altering alert semantics.

Change Analysis

  • kubernetes/apps/web3/monero/guard/prometheusrule.yaml: Introduces xmrig_guard_deployment_node as the canonical source for the xmrig-<node> naming convention. Both XmrigGuardEnforcementBypassed and XmrigGuardThermalPanic now consume this metric instead of inline label_replace calls. The PromQL vector matching (on (deployment) / on (node)) is consistent with the new metric's labels. Comments are updated to reflect the shared dependency.

Standards Compliance

  • Follows Conventional Commit title format (refactor(scope): description).
  • Changes are small, focused, and preserve existing alert thresholds and durations.
  • No secrets or sensitive data introduced.

Tool Harness Findings

No tool harness findings.

Unknowns or Needs Verification

None. The diff is self-contained and syntactically valid YAML/PromQL.

@Tanguille

Copy link
Copy Markdown
Owner Author

Folded into #4394.

@Tanguille Tanguille closed this Aug 9, 2026
@Tanguille
Tanguille deleted the fix/xmrig-guard-dedup-deployment-join branch August 9, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant