Skip to content

feat(install): bind grafana and influxdb to loopback by default - #359

Merged
CameronBrooks11 merged 4 commits into
mainfrom
feat/observability-loopback-bind
Oct 15, 2026
Merged

CameronBrooks11 merged 4 commits into
mainfrom
feat/observability-loopback-bind

Conversation

@CameronBrooks11

@CameronBrooks11 CameronBrooks11 commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

feat(install): bind grafana and influxdb to loopback by default

--with-observability left Grafana and InfluxDB on every interface:
neither listen address was set, so both kept the vendor default, and
Grafana serves its dashboards to anonymous viewers. Nothing off the
device needs InfluxDB, since the runtime and Grafana reach it at
http://127.0.0.1:8086.

InfluxDB now always binds 127.0.0.1:8086. A new systemd drop-in,
/etc/systemd/system/influxdb.service.d/anolis.conf, sets
INFLUXD_HTTP_BIND_ADDRESS. influxdb is restarted on every observability
run instead of enable --now, because a running influxd keeps the bind
it started with. The separate-host compose stack is unchanged.

Grafana binds 127.0.0.1 by default through GF_SERVER_HTTP_ADDR in its
existing drop-in. The new flag --with-grafana-network opens Grafana,
and only Grafana, to the network by setting 0.0.0.0, which Grafana's
documentation gives as the equivalent of its empty default. Given
without --with-observability, the flag warns that it has no effect.

The summary reports the bind only once it is applied, that is, after
grafana-server restarts with the new drop-in. By default it prints
ssh -L 3000:127.0.0.1:3000 <user>@<host> (the user is $SUDO_USER
when set; on x86_64 the host is a placeholder) and
http://localhost:3000. With the flag it prints the network address as
before. The drop-in is rewritten on every run, so a re-run without the
flag after one with it binds loopback again, and the summary says
Grafana is no longer on the network. If the observability step fails
before the restart, the summary says the Grafana bind is unchanged
instead of printing an address or a tunnel.

Uninstall removes the InfluxDB drop-in with Grafana's. Its check for a
provisioned stack is now _obs_provisioned, so a test can drive the
uninstall path without the host's /etc.

docs/security.md gains an Observability section: a table of both
ports with bind, authentication (including anonymous Viewer on
Grafana, and where the InfluxDB admin token is kept, among them
/etc/anolis/observability.env) and who needs each, the tunnel, when
the bind goes back to loopback, and a line saying the install
configures no host firewall. The --with-grafana-network row in
docs/deploy/install-sh.md links to it.

observability_test.bats gains fourteen cases: the flag parses, and
alone it warns; Grafana's drop-in binds 127.0.0.1 by default and
0.0.0.0 with the flag; InfluxDB's drop-in binds 127.0.0.1:8086 either
way; a drop-in written with the flag is recognised as network-bound
and one without it is not; the InfluxDB drop-in is written before
influxdb is restarted, never only enable --now; the default summary
prints the tunnel and no network address; the flag's summary prints
the address and no tunnel; a re-run without the flag reports the
return to loopback; on x86_64 the tunnel names ; failed
provisioning reports the bind as unchanged; a successful run reports
the bind it applied; uninstall removes the InfluxDB drop-in (rm,
systemctl and the rest stubbed). Twelve fail before the change. The
flag's summary case and the successful-run case pass before it too,
because they pin existing output. Each new behaviour case was broken
on its own, and each mutation failed only its target. The InfluxDB
drop-in writer is stubbed with the other host-touching calls in the
existing phase_observability cases. bats tests/shell/: 191 of 191
pass, none skipped. shellcheck tools/install.sh is clean, and
markdownlint-cli2 reports 0 issues on both docs.

Not run on a device. The bind addresses and the restart want a rig
check: after a default install, ss -ltnp shows 3000 and 8086 on
127.0.0.1 only; after one with --with-grafana-network, 3000 on
0.0.0.0 and 8086 still on 127.0.0.1.

Closes #351

--with-observability left Grafana and InfluxDB on every interface:
neither listen address was set, so both kept the vendor default, and
Grafana serves its dashboards to anonymous viewers. Nothing off the
device needs InfluxDB, since the runtime and Grafana reach it at
http://127.0.0.1:8086.

InfluxDB now always binds 127.0.0.1:8086. A new systemd drop-in,
/etc/systemd/system/influxdb.service.d/anolis.conf, sets
INFLUXD_HTTP_BIND_ADDRESS. influxdb is restarted on every observability
run instead of `enable --now`, because a running influxd keeps the bind
it started with. The separate-host compose stack is unchanged.

Grafana binds 127.0.0.1 by default through GF_SERVER_HTTP_ADDR in its
existing drop-in. The new flag --with-grafana-network opens Grafana,
and only Grafana, to the network by setting 0.0.0.0, which Grafana's
documentation gives as the equivalent of its empty default. The
default summary prints
`ssh -L 3000:127.0.0.1:3000 <user>@<host>` (the user is $SUDO_USER
when set) and http://localhost:3000. With the flag it prints the
network address as before. The drop-in is rewritten on every run, so a
re-run without the flag after one with it binds loopback again, and
the summary says Grafana is no longer on the network. Uninstall
removes the InfluxDB drop-in with Grafana's.

docs/security.md gains an Observability section: a table of both
ports with bind, authentication (including anonymous Viewer on
Grafana) and who needs each, the tunnel, and a line saying the install
configures no host firewall. The --with-grafana-network row in
docs/deploy/install-sh.md links to it.

observability_test.bats gains nine cases: the flag parses; Grafana's
drop-in binds 127.0.0.1 by default and 0.0.0.0 with the flag;
InfluxDB's drop-in binds 127.0.0.1:8086 either way; a drop-in written
with the flag is recognised as network-bound and one without it is
not; the InfluxDB drop-in is written before influxdb is restarted,
never only `enable --now`; the default summary prints the tunnel and
no network address; the flag's summary prints the address and no
tunnel; a re-run without the flag reports the return to loopback.
Eight fail before the change. The flag's summary case passes before
it too, because it pins the existing output. The InfluxDB drop-in
writer is stubbed with the other host-touching calls in the existing
phase_observability cases. bats tests/shell/: 186 of 186 pass, none
skipped. shellcheck tools/install.sh is clean, and markdownlint-cli2
reports 0 issues on both docs.

Not run on a device. The bind addresses and the restart want a rig
check: after a default install, `ss -ltnp` shows 3000 and 8086 on
127.0.0.1 only; after one with --with-grafana-network, 3000 on
0.0.0.0 and 8086 still on 127.0.0.1.

Closes #351
A re-run whose observability step failed still reported Grafana on
loopback, with the tunnel, while it was on the network. The drop-in is
written at the end of _obs_provision_grafana and grafana-server is
restarted after it. If _obs_setup_influx or _obs_provision_grafana
failed, phase_observability returned early, but the summary, gated
only on WITH_OBSERVABILITY, printed the requested bind as if applied.

_OBS_GRAFANA_BIND_APPLIED is now set only after grafana-server
restarts with the new drop-in. Until then the summary prints "Grafana
bind unchanged: the observability step did not finish" instead of an
address or a tunnel.

Also:
- On x86_64 the tunnel line named localhost, which is useless from
  another machine. It now prints a <host> placeholder there.
- --with-grafana-network without --with-observability warns that it
  has no effect.
- The uninstall check for a provisioned stack is now _obs_provisioned,
  so a test can drive the uninstall path without the host's /etc.
- docs/security.md: the InfluxDB admin token is also written to
  /etc/anolis/observability.env as INFLUXDB_ADMIN_TOKEN. Going back to
  loopback needs a later install with --with-observability, and a
  failed one leaves the bind as it was.

Five new bats cases: failed provisioning gives "bind unchanged" and no
tunnel; a successful run reports the bind it applied; x86_64 prints
<host>, not localhost; the flag alone warns; uninstall removes the
InfluxDB drop-in with Grafana's (rm, systemctl and the rest stubbed).
Four fail before the change. The successful-run case passed before
too, because it pins the existing output. Each was broken on its own
(setting the flag before provisioning, never setting it, dropping the
placeholder, the warning, or the influx drop-in from rm), and each
mutation failed only its target. The three existing summary cases set
the applied flag explicitly. bats tests/shell/: 191 of 191 pass, none
skipped. shellcheck is clean, and markdownlint-cli2 reports 0 issues
on security.md.

Refs #351
@CameronBrooks11
CameronBrooks11 enabled auto-merge (squash) October 15, 2026 12:41
@CameronBrooks11
CameronBrooks11 merged commit 1152a99 into main Oct 15, 2026
29 checks passed
@CameronBrooks11
CameronBrooks11 deleted the feat/observability-loopback-bind branch October 15, 2026 13:23
CameronBrooks11 added a commit to anolishq/anolis-workbench that referenced this pull request Oct 15, 2026
`anolis-provision install|remote --with-observability` now forwards
`--with-observability` to `install.sh`, which installs InfluxDB and
Grafana natively on the target (anolishq/anolis#162). The flag used to
download the runtime release's Docker Compose stack and run it on the
machine running the workbench, not on the target; on a local install
its `:8086` collided with the native InfluxDB.

BREAKING: the flag's meaning changes and `--start-observability` is
removed, so this ships in a minor release. Both are in CHANGELOG
[Unreleased].

- `deploy._install_args`, `deploy_local` and `deploy_remote` take
  `with_observability` and append `--with-observability`, as they
  already do for `--with-telemetry-export`.
- `provision_cli` passes the flag to both deploy paths. The Docker step
  (`_run_observability_step`), `--start-observability`, and the
  `GITHUB_TOKEN` reads that only fed that step are removed.
- `anolis_workbench/core/observability.py` and its tests are deleted,
  and the executor allowlist drops `docker`, whose only caller was that
  module.
- install.sh's observability phase reports every failure as a warning
  and still exits 0. With the flag, the install and remote summaries
  repeat its `observability:` and `Grafana:` lines with the indented
  detail under each (`deploy.observability_lines`). A warning line
  also prints a WARNING to stderr. When install.sh printed no such
  lines, the summary shows the last 10 lines of its output and warns.
  The exit code stays 0: the runtime is installed either way.
- README:
  - how to request observability, and how to read the summary;
  - reaching Grafana: an ssh tunnel to `127.0.0.1:3000` on releases
    that bind it to loopback (anolishq/anolis#359), or install.sh's
    `--with-grafana-network`, which `anolis-provision` does not
    forward;
  - the admin password: `GRAFANA_ADMIN_PASSWORD` in
    `/etc/anolis/observability.env`, root only;
  - switching: run `docker compose down` in `~/.anolis/observability`
    before a local install, since a leftover InfluxDB container on
    `0.0.0.0:8086` keeps native `influxd` from binding (read from
    install.sh, not reproduced);
  - a separate monitoring host runs the release's
    `anolis-<version>-observability.tar.gz` compose stack itself.

Tests:
- `test_deploy.py`: the flag reaches install.sh on the local and remote
  paths and is absent by default.
- `test_provision_cli.py`, through the real parser:
  - `with_observability=True` reaches both deploy calls;
  - `--start-observability` is rejected and the Docker module is gone;
  - an offline warning from install.sh reaches stdout and stderr;
  - the remote summary shows the Grafana line and its tunnel hint;
  - missing lines fall back to a tail;
  - without the flag there is no observability section.

Before the change these two files gave 7 failed, 45 passed for the
flag tests and 3 failed, 20 passed for the summary tests; after, 56
passed. Six mutations of the summary code each reddened only their
target test. Full suite: 433 passed, 1 skipped (the frozen-sidecar
test).

Closes #227
CameronBrooks11 added a commit to anolishq/anolis-workbench that referenced this pull request Oct 15, 2026
Commission's Deploy to device section gets an "Also install
observability (InfluxDB + Grafana)" checkbox beside the
telemetry-export one. When it is ticked, the deploy posts
`with_observability: true`, and the local and remote provision jobs
pass it to deploy, which runs install.sh --with-observability (#462).
Like with_telemetry_export, only a literal true turns it on.

install.sh reports an observability failure as a warning and still
exits 0, so a ticked box on an offline target would otherwise read
"Deployed" with nothing installed. Both jobs now put
deploy.observability_lines(output) in the done event's
summary.observability, and Commission's deploy result shows them. A
line starting with ⚠ is styled as a warning, and the block is headed
"Observability needs attention: install.sh reported a problem."
Below it, the "Reaching Grafana:" block from #241 says how to reach
Grafana.

The note under the checkbox holds for local and remote deploys and
for runtimes before and after anolishq/anolis#359: Grafana listens on
port 3000, on the target's 127.0.0.1 only with a current runtime and
on its network address with an older one, and the deploy result shows
install.sh's report and how to reach Grafana.

Onboarding already has no install-option toggles and no template
picker, so this completes #229: Commission's deploy section now
passes both toggles through to install.sh.

Builds on #241, which builds on #469: the summary carries
grafana_access beside observability, and observability_lines needs
#469's parsing fix.

Tests:
- the remote job passes with_observability through; the local job
  turns it on for true only, not None, "true" or 1;
- both jobs' done events carry install.sh's observability lines for
  the offline fixture (tests/fixtures/install-sh/offline.txt), led by
  its ⚠ line, and no Grafana access;
- Commission posts with_observability when the box is ticked, and the
  local deploy test still posts none when it is not;
- Commission heads an offline report "Observability needs attention"
  and styles only the ⚠ line as a warning; a clean report shows no
  warning; the note names 127.0.0.1 and the network address.

Before the toggle: 2 failed, 5 passed (test_provision_jobs.py) and
1 failed, 11 passed (commission.test.ts). Before the report change:
2 failed, 9 passed and 3 failed, 14 passed. After: 11 and 17 passed.
Dropping the observability lines from the local job's summary fails
only its test. `just check`, `just build` and `just test` pass (496
passed, 1 skipped; 115 unit and 120 component frontend tests).

Still needs a visual check: Commission, Deploy to device:
- the new checkbox and its note under the telemetry-export one;
- a deploy result with an observability warning (offline target):
  the heading and the ⚠ line in the warning colour, one line each;
- a clean one: "install.sh's observability report:" then "Reaching
  Grafana:".

Closes #229
CameronBrooks11 added a commit that referenced this pull request Oct 16, 2026
test(install): pin the grafana bind flag and the rollback restart

Two orderings in install.sh had no test behind them.

- _OBS_GRAFANA_BIND_APPLIED is set only after grafana-server restarts
  with the new drop-in (#359). A new case in observability_test.bats
  fails that restart and expects the summary to say "Grafana bind
  unchanged" and to print neither address.
- The rollback case where copying the saved manifest fails (#354) never
  reached the restart, because no unit file existed. It now sources
  install.sh with SYSTEMD_DIR pointed at a temp dir that holds
  anolis-runtime.service, stubs systemctl and phase_health, and expects
  "systemctl restart anolis-runtime.service" after the warning and
  before "rollback complete".

install.sh is unchanged. With the flag assignment moved above the
grafana restart, the new observability case fails and no other does.
With the restart removed from do_rollback, the rollback case fails.
shellcheck tools/install.sh is clean and bats tests/shell/ passes 203
of 203.

Closes #364
CameronBrooks11 added a commit that referenced this pull request Oct 16, 2026
Bumps `project(VERSION)` and `vcpkg.json` to 0.1.45 and rolls the
CHANGELOG. Ships, among others:
- `safety.on_startup`, default `safe_state`: the declared safe state
  runs once at every runtime start (#392, closes #362);
- Grafana and InfluxDB bound to loopback under `--with-observability`,
  with `--with-grafana-network` to open Grafana to the LAN (#359,
  closes #351);
- `install.sh` refuses a downgrade unless `--allow-downgrade` (#382,
  closes #366);
- the zero rung no longer sends a guessed boolean (#367), e-stop
  `safe_state_achieved` (#368), dispatchable coverage counts (#369),
  and startup warnings for fault-hook gaps (#370) and disarmed
  watchdogs (#371);
- `health.excluded_signals` (#377), signal unit and description in
  capabilities (#365);
- a half-open probe of an open provider circuit every 60 s, a restart
  that stops the old process first, and a restart clock that starts
  after it stops (#376, #391);
- automation status: `idle` outside AUTO, and `failed` cleared by a
  load or a new AUTO run (#373, #386);
- `install.sh`: provider liveness in the health phase (#355, #383),
  `manifest.json` restored on `--rollback` (#354), Grafana restarted
  on every observability run (#343), the datasource debug lines
  filtered from the journal (#360), and the uninstall prefix guard
  (#342);
- no ERROR lines for reads that fail during shutdown (#381).

The CHANGELOG opens 0.1.45 with upgrade notes: Grafana is on loopback
by default, `safety.on_startup` drives outputs at boot by default, and
downgrades need `--allow-downgrade`. The 0.1.44 note about restarting
grafana-server by hand is not repeated, since #343 restarts it on
every run.

The OpenAPI changes are additive: `SignalSpec.unit` and
`.description`, `EstopResponse.safe_state_achieved`,
`ParameterDefinition.source` and the runtime status
`startup_safe_state`. No provider-protocol change. anolis-workbench
vendors the OpenAPI file and needs a repin to this release.

Every commit in `git log v0.1.44..main` is in the CHANGELOG except
CI, test-only and docs-lint commits (#380, #384, #389).

After merge, tag `v0.1.45`.
CameronBrooks11 added a commit to anolishq/anolis-projects that referenced this pull request Oct 16, 2026
Move bioreactor-v1 onto the current releases: anolis 0.1.45,
anolis-provider-bread 0.5.2 and anolis-provider-ezo 0.4.1.

- machine-profile.yaml: runtime 0.1.44 -> 0.1.45, bread 0.5.1 -> 0.5.2,
  ezo 0.4.0 -> 0.4.1.
- schema-source.json: 0.1.44 -> 0.1.45, so CI validates against the
  0.1.45 machine-profile schema.
- quickstart-on-pi.md: the install.sh download URL, the pinned
  versions the install reports, and the version runtime/status
  returns.
- quickstart-on-pi.md section 4: 0.1.45 binds Grafana to 127.0.0.1 by
  default (anolishq/anolis#359), so http://<pi-ip>:3000 no longer
  answers. The step now opens `ssh -L 3000:127.0.0.1:3000 <user>@<pi>`
  and browses http://localhost:3000, names GRAFANA_ADMIN_PASSWORD in
  /etc/anolis/observability.env (root only) as the admin password,
  and gives --with-grafana-network on the install line as the way to
  open Grafana to the LAN.

telemetry_export stays at 0.1.1, the latest anolis-telemetry-export
release (`gh release list -R anolishq/anolis-telemetry-export`:
v0.1.1 Latest, 2026-07-04).

A grep for 0.1.44, 0.5.1 and 0.4.0 over the repo now finds one line:
quickstart-on-pi.md:304, the record of the 2026-10-12 walk-through
(anolis 0.1.43, bread 0.5.0, ezo 0.4.0). It states what was run on
that date, so it keeps its versions.

Validation, the CI validate job run locally against the v0.1.45
release assets (both tarballs' sha256 match their manifests):
21 YAML files load; every project has a machine-profile.yaml; no
.anpkg; check-jsonschema with the 0.1.45 machine-profile schema on
projects/*/machine-profile.yaml: "ok -- validation done"; shellcheck
clean. Beyond CI, the 0.1.45 runtime-config schema also accepts all
eight bioreactor-v1 runtime configs (config/ and config-release/).

Not run on a device.
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.

Observability install listens on every interface: bind Grafana and InfluxDB to loopback by default

1 participant