Skip to content

feat(monitoring): manage the exporter firewall guard and keep exporters up across docker restarts - #84

Merged
entelecheia merged 3 commits into
mainfrom
feat/exporter-firewall
Oct 20, 2026
Merged

entelecheia merged 3 commits into
mainfrom
feat/exporter-firewall

Conversation

@entelecheia

Copy link
Copy Markdown
Member

Implements #83.

  • modules.monitoring.exporter_firewall: true installs the embedded rootfiles-exporter-firewall helper and its config, runs setup, and checks it with helper check. Paths, chains and the owner marker match the hand-installed v1 template, so the 8 guarded hosts are adopted without rule changes.
  • Exporter drop-ins: After= the guard plus ExecStartPre=+helper verify-host (node) / verify-docker (DCGM) instead of Requires=; the guard unit Wants=docker.service. check also compares unit and drop-in contents.
  • DCGM exporter and hub units: WantedBy=multi-user.target docker.service, with systemctl reenable on change or a missing wants link.
  • Apply starts an enabled exporter that was refused while rules were missing.
  • doctor: coverage from the guard check; warns about an unmanaged guard. With the option off nothing is touched.
  • Validation: IPv4 listen_address, exactly one IPv4 /32 in allow_from, an enabled exporter, default ports.
  • New CI job exporter-firewall-scenario runs on the runner's Docker/iptables/systemd: invalid config and dry run (AC5), v1 adoption with an unchanged iptables -S (AC1), source filtering (AC2), guard unit stop and missing rules (AC4), docker stop/start (AC3).
  • Release notes: docs/releases/v0.18.0.md.

Closes #83

🤖 Generated with Claude Code

https://claude.ai/code/session_0177Zk7to4EYohgM59v4Fcj7

…rs up across docker restarts

Embed the hand-installed rootfiles-exporter-firewall helper (same paths,
chains and owner marker, so existing guards are adopted in place) behind
modules.monitoring.exporter_firewall. Exporter drop-ins now order after the
guard and verify their rules in ExecStartPre instead of Requires=, the guard
unit only Wants docker, and the DCGM exporter and hub units are wanted by
docker.service. Doctor reports coverage from the guard check and names an
unmanaged guard. A runner scenario covers adoption, filtering, guard and
docker restarts and fail-closed starts.

Closes #83

Claude-Session: https://claude.ai/code/session_0177Zk7to4EYohgM59v4Fcj7
Copilot AI balanced review requested due to automatic review settings October 20, 2026 10:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T10:58:43.531605Z 02a4a2f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

exporters, exportErr := applyMonitoringExporters(ctx, rc)

P1 Badge Install the firewall before starting exporters

On a first apply with exporter_firewall: true and no pre-existing guard, this starts/enables node exporter or DCGM before applyExporterGuard installs either the firewall rules or the exporters' ExecStartPre drop-ins. On the intended hosts without UFW, the exporter is therefore reachable by every network peer until the hub setup and guard setup finish, which can be prolonged by Compose image pulls. Install an initial fail-closed guard and drop-ins before starting the exporters, then update it with the hub bridge afterward.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/module/monitoring_guard.go
Comment thread internal/module/assets/exporter-firewall.sh
@entelecheia

Copy link
Copy Markdown
Member Author

Re the Codex review-body finding "Install the firewall before starting exporters": fixed in 5bfed9f. Apply now runs the guard before the exporters, and runs it again after the hub on hub hosts so a first apply still admits the bridge the hub just created. The step that starts refused exporters now only starts enabled units, so a fresh host without node exporter gets no spurious start.

@entelecheia
entelecheia merged commit a1781ee into main Oct 20, 2026
56 checks passed
@entelecheia
entelecheia deleted the feat/exporter-firewall branch October 20, 2026 11:26
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.

feat(monitoring): manage the exporter firewall guard and keep exporters up across docker restarts

2 participants