Skip to content

fix(mdadm): honor repeat notifications and retry failed degraded alerts - #1128

Merged
Starosdev merged 3 commits into
developfrom
fix/1109-mdadm-notify-repeat
Nov 5, 2026
Merged

Starosdev merged 3 commits into
developfrom
fix/1109-mdadm-notify-repeat

Conversation

@Starosdev

@Starosdev Starosdev commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

A degraded MDADM array was announced only on the transition from healthy, and the alert was lost for good if that one delivery failed. This makes MDADM notifications honor Repeat Notifications and retry until delivered.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD or infrastructure change

Related Issues

Fixes #1109

Changes Made

  • Add MDADMTracker to the notification gate (notify/mdadm.go). It records, per array, the degradation last announced, and records it only when TrySend reports the notification delivered or queued. A send error or a rate-limit drop is retried on the next collection.
  • Repeat Notifications on: every collection notifies while the array stays degraded, consistent with SMART failures.
  • Repeat Notifications off: notify when the array becomes degraded, and again when it loses an active member or gains a failed one. An improvement becomes the new baseline, so a later relapse is announced. A healthy upload clears the record.
  • The tracker compares active and failed member counts, not the State string. mdadm flips clean and active with write activity, so comparing the string would re-announce an unchanged degradation. A state change with the same counts, such as the start of a rebuild, is therefore not announced.
  • Remove the InfluxDB history lookup from the notification path. It also caused an accidental repeat on every run when collections were more than a day apart, because the day window then held a single point.
  • Document the notification behavior and the permanently degraded Synology md0/md1 system and swap arrays in docs/MDADM_MONITORING.md.

The tracker state is in memory, like the other notification dedup state (rate limit, quiet queue, collector errors, missed ping, temperature). A web server restart announces each array that is still degraded once more. Persisting it was considered and rejected to stay consistent with that rule and avoid a migration.

Testing

  • I have tested this locally
  • I have added/updated tests that prove my fix/feature works
  • All existing tests pass

Local: go build ./... and go vet ./web/handler ./notify pass (vet compiles the tests). Tests were not run locally; CI runs them.

New tests: six MDADMTracker tests (single announcement, repeat on, retry after failed delivery, worsening, relapse after improvement, re-announce after recovery) and handler tests for mute, the unmuted path, and forgetting on a healthy upload.

Checklist

  • My code follows the project's code style
  • I have performed a self-review of my code
  • I have commented my code where necessary (particularly complex areas)
  • I have updated the documentation if needed
  • My changes generate no new warnings
  • No console.log, debug statements, or commented-out code

Additional Notes

Review: not required (merging to develop ships nothing until a manual release; no migration, security boundary, or shared contract change).

Not included: a hint in the MDADM page or notification text about Synology system arrays. Adding it to every notification would add noise to real alerts; the docs entry and the existing mute cover it for now.

A degraded MDADM array was announced only on the transition from healthy,
decided by comparing with the previous Influx submission. The Repeat
Notifications setting was never read, and when delivery failed the next
collection saw the array as already degraded, so the alert was lost.

An in-memory MDADMTracker on the notification gate now records the
degradation last announced per array, and records it only when TrySend
reports the notification delivered or queued. With repeat on, every
collection notifies. With repeat off, the array is announced when it
becomes degraded and again when it loses an active member or gains a
failed one. A healthy upload clears the record. The history lookup is
removed from the notification path, which also ends the accidental repeat
when collections were more than a day apart.

Documents the behavior and the permanently degraded Synology md0/md1
system and swap arrays.

Fixes #1109
…ify-repeat

# Conflicts:
#	webapp/backend/pkg/web/handler/mdadm_upload_metrics.go
@Starosdev
Starosdev merged commit 62f9cef into develop Nov 5, 2026
19 checks passed
Starosdev pushed a commit that referenced this pull request Nov 5, 2026
## [1.80.0](v1.79.3...v1.80.0) (2026-11-05)

### Features

* **btrfs:** notify on degraded filesystems, device errors and scrub errors ([#1127](#1127)) ([36e1e23](36e1e23)), closes [#1110](#1110)
* manual release trigger ([44f3e44](44f3e44))
* **notify:** alert when Btrfs or ZFS usage reaches a configurable threshold ([#1133](#1133)) ([6e79118](6e79118)), closes [#1127](#1127) [#1132](#1132) [#1127](#1127)
* **zfs:** notify on unhealthy pools, error totals and scrub errors ([#1131](#1131)) ([9c6544c](9c6544c)), closes [#1127](#1127) [#1130](#1130) [#1127](#1127)

### Bug Fixes

* **database:** inline validated ids in Btrfs and ZFS history queries for InfluxDB OSS ([#1111](#1111)) ([#1124](#1124)) ([b0a1c69](b0a1c69)), closes [#157](#157) [#155](#155) [#157](#157) [#157](#157)
* **mdadm:** honor repeat notifications and retry failed degraded alerts ([#1128](#1128)) ([62f9cef](62f9cef)), closes [#1109](#1109)
* **notify:** notify on manufacturer SMART failures at every notify level ([#1126](#1126)) ([5cb3622](5cb3622))
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.

1 participant