-
Notifications
You must be signed in to change notification settings - Fork 8
fix(homelab): make memory and ZFS alerts durable #2008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shepherdjerred
wants to merge
1
commit into
main
Choose a base branch
from
pagerduty-alerts-last-7d
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
packages/docs/plans/2026-08-08_memory-and-zfs-alert-remediation.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| --- | ||
| id: plan-2026-08-08-memory-and-zfs-alert-remediation | ||
| type: plan | ||
| status: in-progress | ||
| board: false | ||
| --- | ||
|
|
||
| # Durable memory and ZFS alert remediation | ||
|
|
||
| ## Context | ||
|
|
||
| The `MemoryLeakSuspected` PagerDuty incident on `liskov` was a false positive: | ||
| the PromQL `offset 24h` modifier applied only to the historical ZFS ARC selector, | ||
| so a large ARC drop looked like non-ARC memory growth. The corrected expression | ||
| must offset total memory, available memory, and ARC together. | ||
|
|
||
| The weekly `runZfsMaintenanceWorkflow` failed on 2026-08-02 after selecting the | ||
| `liskov` `zfs-zpool-collector` pod through `kubectl exec daemonset/...`. The | ||
| activity assumed that pod also contained `zfspv-pool-hdd`, but that pool exists | ||
| only on `torvalds`; the failure occurred before either node reached the scrub | ||
| loop. The maintenance activity now discovers one Ready collector pod per node | ||
| and only operates on that node's managed `zfspv-pool-*` inventory. | ||
|
|
||
| ## Changes | ||
|
|
||
| - Correct and regression-test the memory alert expression. | ||
| - Make ZFS maintenance pod- and pool-aware, with fail-fast errors carrying node, | ||
| pod, pool, and command context. | ||
| - Treat a zero scrub timestamp as an alert condition so never-scrubbed pools are | ||
| visible instead of silently excluded. | ||
| - Document per-node verification and the Temporal workflow failure mode in the | ||
| homelab runbook. | ||
|
|
||
| ## Verification | ||
|
|
||
| - Focused Temporal and CDK8s tests and lint pass; CDK8s typecheck passes. | ||
| - The Temporal package-wide typecheck remains blocked by pre-existing missing | ||
| `@shepherdjerred/glitter-context/schema` and `@shepherdjerred/llm-models` | ||
| workspace artifacts plus dependent Glitter errors; no changed-file errors | ||
| were reported. | ||
| - Rendered Prometheus rules contain the corrected memory and ZFS expressions. | ||
| - After the GitOps rollout, run the weekly workflow once, verify each node's | ||
| managed pools have current scrub timestamps and no ZFS errors, then wait for | ||
| Prometheus/Alertmanager to clear the incidents. This operator step is not part | ||
| of the repository-only implementation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/homelab/src/cdk8s/src/resources/monitoring/monitoring/rules/zfs-maintenance.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { describe, expect, it } from "bun:test"; | ||
| import { getZfsMaintenanceRuleGroups } from "./zfs-maintenance.ts"; | ||
|
|
||
| describe("ZfsScrubOverdue", () => { | ||
| it("fires for pools that have never recorded a completed scrub or are overdue", () => { | ||
| const group = getZfsMaintenanceRuleGroups().find( | ||
| (candidate) => candidate.name === "zfs-maintenance", | ||
| ); | ||
| if (group?.rules === undefined) { | ||
| throw new Error("expected zfs-maintenance rules"); | ||
| } | ||
|
|
||
| const alert = group.rules.find((rule) => rule.alert === "ZfsScrubOverdue"); | ||
| if (alert === undefined) { | ||
| throw new Error("expected ZfsScrubOverdue alert"); | ||
| } | ||
|
|
||
| expect(alert.expr.value).toBe( | ||
| "zfs_zpool_last_scrub_completion_timestamp == 0 or (time() - zfs_zpool_last_scrub_completion_timestamp) > 777600", | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,11 +56,11 @@ export function getZfsMaintenanceRuleGroups(): PrometheusRuleSpecGroups[] { | |
| "ZFS scrub overdue on {{ $labels.zpool_name }}", | ||
| ), | ||
| description: escapePrometheusTemplate( | ||
| "ZFS pool {{ $labels.zpool_name }} has not been scrubbed in over 9 days. The weekly Temporal maintenance workflow may have failed.", | ||
| "ZFS pool {{ $labels.zpool_name }} has never completed a scrub or has not been scrubbed in over 9 days. The weekly Temporal maintenance workflow may have failed.", | ||
| ), | ||
| }, | ||
| expr: PrometheusRuleSpecGroupsRulesExpr.fromString( | ||
| "zfs_zpool_last_scrub_completion_timestamp > 0 and (time() - zfs_zpool_last_scrub_completion_timestamp) > 777600", | ||
| "zfs_zpool_last_scrub_completion_timestamp == 0 or (time() - zfs_zpool_last_scrub_completion_timestamp) > 777600", | ||
| ), | ||
|
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Scrub alert value zero ZfsScrubOverdue now uses ts == 0 or (time() - ts) > 777600, which (for never-scrubbed pools) yields a sample value of 0 due to or preferring the left-hand side. The alert still fires, but the notification value becomes less useful (it no longer reflects elapsed time for the never-scrubbed case). Agent Prompt
|
||
| for: "1h", | ||
| labels: { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Promql string exceeds 120 chars
📘 Rule violation⚙ MaintainabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools