Quiet the log: expected states stop reporting as failures #163

Merged
mysticalsoap merged 3 commits from log-noise into trunk 2026-08-24 20:16:15 -04:00
Owner

Problem

After #159 cleaned up the import path, the remaining log noise made every service start, network change and settings apply read like a failure (#160, #161, #162): an ip -6 route replace default via None that can only fail on a v6-less network, WARNING batches from teardown deleting rules that were never added, and three normal startup states (a vanished caller's polkit check, QtWebEngine's deliberate absence, unwritten json files) logged at ERROR/WARNING.

Fix

One commit per issue:

  • #160create_cgroup skips the v6 route when the routes dict carries None for the gateway; the fwmark rule still lands, pointing at a table with no route, which is where v6 traffic on such a network already ended up.
  • #161add_rule now probes deletions with -C the same way it already probed inserts: an absent rule skips quietly at debug, deletions by index stay unprobed (-C takes a rule spec, not a position). Also fixes the warning reporting the probe's exception instead of the apply's own.
  • #162 — a caller whose bus connection died before its polkit check (stale gui racing a service restart) logs at info instead of "polkit unavailable" at ERROR — NameHasNoOwner names the subject, not polkit; QtWebEngine absence drops to info naming what degrades (the location map); load_json treats a missing file as the first-run default at debug, keeping the warning for files that exist but don't parse.

Verification

  • pytest green (369 passed) plus the ruff/compileall gates.
  • New coverage: TestBypassRoutes (no v6 gateway → no v6 route command, v4 route and both fwmark rules untouched), new tests/test_firewall.py (probe-before-act for deletions/inserts/positional/flush, real failures still warn), TestRequireAuthorization (vanished caller quiet, unreachable polkit loud), TestLoadJson (missing quiet, corrupt warns).
  • Live check after merge: a service restart plus a bypass rebuild should produce no WARNING/ERROR lines at all on this network.

Closes #160
Closes #161
Closes #162

🤖 Generated with Claude Code

## Problem After #159 cleaned up the import path, the remaining log noise made every service start, network change and settings apply read like a failure (#160, #161, #162): an `ip -6 route replace default via None` that can only fail on a v6-less network, WARNING batches from teardown deleting rules that were never added, and three normal startup states (a vanished caller's polkit check, QtWebEngine's deliberate absence, unwritten json files) logged at ERROR/WARNING. ## Fix One commit per issue: - **#160** — `create_cgroup` skips the v6 route when the routes dict carries `None` for the gateway; the fwmark rule still lands, pointing at a table with no route, which is where v6 traffic on such a network already ended up. - **#161** — `add_rule` now probes deletions with `-C` the same way it already probed inserts: an absent rule skips quietly at debug, deletions by index stay unprobed (`-C` takes a rule spec, not a position). Also fixes the warning reporting the probe's exception instead of the apply's own. - **#162** — a caller whose bus connection died before its polkit check (stale gui racing a service restart) logs at info instead of "polkit unavailable" at ERROR — `NameHasNoOwner` names the subject, not polkit; QtWebEngine absence drops to info naming what degrades (the location map); `load_json` treats a missing file as the first-run default at debug, keeping the warning for files that exist but don't parse. ## Verification - `pytest` green (369 passed) plus the ruff/compileall gates. - New coverage: `TestBypassRoutes` (no v6 gateway → no v6 route command, v4 route and both fwmark rules untouched), new `tests/test_firewall.py` (probe-before-act for deletions/inserts/positional/flush, real failures still warn), `TestRequireAuthorization` (vanished caller quiet, unreachable polkit loud), `TestLoadJson` (missing quiet, corrupt warns). - Live check after merge: a service restart plus a bypass rebuild should produce no WARNING/ERROR lines at all on this network. Closes #160 Closes #161 Closes #162 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The routes dict carries the literal string 'None' for an absent
gateway, and create_cgroup interpolated it straight into
'ip -6 route replace default via None ...' -- a command that can only
fail, logged as an error on every service start, network change and
settings apply. The fwmark rule still lands, pointing at a table with
no route, which is where v6 traffic on such a network already ended up.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Teardown-before-rebuild deletes rules that may never have been added --
a fresh boot, a repeated bypass rebuild, a v6 list whose inserts were
skipped -- and every miss logged 'iptables: failed to apply' at
warning, in batches, burying real failures. add_rule already probed
inserts with -C; deletions now get the same treatment and skip
quietly when the rule is absent. Deletions by index stay unprobed
(-C takes a rule specification, not a position).

The warning also reported the wrong exception -- the probe's, shadowing
the apply's own error -- and a genuine apply failure now logs itself.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
fix: stop logging expected startup states as errors and warnings
All checks were successful
ci / test (pull_request) Successful in 27s
ci / test (push) Successful in 1m16s
4afaa4ce76
Three normal conditions made every start read like a failure:

- A caller whose bus connection died before its polkit check -- a stale
  gui call racing a service restart -- was logged as 'polkit
  unavailable' at error. NameHasNoOwner names the subject, not polkit;
  it now logs at info as a vanished caller, and only other DBus
  failures keep the error.
- QtWebEngine's absence was an 'Import Error' at error level, though
  it is deliberately optional and only the location map degrades.
- A json file not written yet (profile.json on first run,
  last_server.json before any connection) warned with a raw errno.
  Absent files log debug and return defaults; a file that exists but
  does not parse still warns.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mysticalsoap deleted branch log-noise 2026-08-24 20:16:16 -04:00
Sign in to join this conversation.
No description provided.