Skip to content

chore(glances): HA add-on best practices improvements#628

Open
ChrisHaPunkt wants to merge 18 commits into
hassio-addons:mainfrom
ChrisHaPunkt:fix/influxdb-export-v4
Open

chore(glances): HA add-on best practices improvements#628
ChrisHaPunkt wants to merge 18 commits into
hassio-addons:mainfrom
ChrisHaPunkt:fix/influxdb-export-v4

Conversation

@ChrisHaPunkt

@ChrisHaPunkt ChrisHaPunkt commented May 4, 2026

Copy link
Copy Markdown

Overview

Aligns the Glances Community App with current hassio-addons best practices. This is a separate PR from the InfluxDB bug fix — it contains no functional changes to Glances behaviour.

Changes

Dockerfile — correct io.hass.type label

  • "addon""app": this is a Community App, not a Supervisor-managed add-on

build.yaml — remove pinned base image versions

  • Deleted the file entirely; the pinned ghcr.io/hassio-addons/base:20.1.1 entries are deprecated in favour of the unpinned base image resolution used by the build system

config.yaml — three improvements

  • watchdog: http://[HOST]:61209 — enables Home Assistant to automatically restart the addon if the Glances HTTP endpoint stops responding
  • init: false — documents that S6-Overlay init is disabled (was already the runtime behaviour)
  • homeassistant_config:rwhomeassistant_config — drops unnecessary write access to the HA config directory; Glances only reads it
  • token: str?token: password? — masks the InfluxDB token in the UI instead of displaying it in plain text

translations/en.yaml — add full English translations

  • Provides human-readable labels and descriptions for every config option shown in the addon UI

@ChrisHaPunkt ChrisHaPunkt changed the title Fix/influxdb export v4 fix: InfluxDB export for Glances v4 + HA best practices improvements May 4, 2026
@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@ChrisHaPunkt, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 25 minutes and 5 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bcd5abd3-3f82-4444-8e56-91ea9677da2e

📥 Commits

Reviewing files that changed from the base of the PR and between 1bb9342 and 7234105.

📒 Files selected for processing (1)
  • glances/rootfs/etc/services.d/glances/run

Walkthrough

Container label changed to "app"; build refs updated; config defaults and schema adjusted; startup script runs exporter and webserver as coordinated background processes with shutdown handling; English translations for new configuration fields added.

Changes

Glances App Migration & Exporter Refactoring

Layer / File(s) Summary
Container Metadata
glances/Dockerfile
io.hass.type changed from "addon""app".
Build Base References
glances/build.yaml
Removed pinned build_from entries referencing ghcr.io/hassio-addons/base:20.1.1 for aarch64 and amd64.
Configuration Schema / Defaults
glances/config.yaml
Added watchdog: http://[HOST]:61209 and init: false; changed map entry for homeassistant_config to a bare presence entry; updated influxdb.token from str?password?.
Runtime Control / Startup Script
glances/rootfs/etc/services.d/glances/run
When exporters configured, builds exporter_options and starts Glances exporter as a background process (--export, --quiet, optional --disable-process) and records EXPORTER_PID; starts webserver in background (WEBSERVER_PID), installs trap to SIGTERM/SIGINT both PIDs, uses wait -n to detect unexpected child exit and kills both on failure. If no exporters, retains direct exec glances "${options[@]}".
UI Localization
glances/translations/en.yaml
Adds configuration translations: log_level, process_info, refresh_time, ssl, certfile, keyfile, leave_front_door_open, and an influxdb subsection (bucket, enabled, host, port, username, password, database, org, prefix, interval, ssl, token, version).

Sequence Diagram

sequenceDiagram
  autonumber
  participant Init as Init Script
  participant Exporter as Glances Exporter (background)
  participant Web as Glances Webserver
  participant Sys as System Signal

  Init->>Exporter: if exporters configured -> start (--export, --quiet)
  Init->>Init: store EXPORTER_PID
  Init->>Web: start webserver (no --export)
  Init->>Init: store WEBSERVER_PID
  Sys->>Init: send TERM/INT
  Init->>Exporter: forward TERM/INT (kill EXPORTER_PID)
  Init->>Web: forward TERM/INT (kill WEBSERVER_PID)
  Exporter-->>Init: exit
  Web-->>Init: exit
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

maintenance

"I hopped through Dockerfiles and scripts today,
exporters humming softly in the fray,
watchdog set to guard the gate,
configs polished, translations great —
a rabbit's nod to tidy play."

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore(glances): HA add-on best practices improvements' accurately describes the main changes in the PR, which are best-practice improvements to the Home Assistant add-on (now app) configuration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🧹 Nitpick comments (1)
glances/Dockerfile (1)

58-70: ⚡ Quick win

Remove duplicate io.hass.version label entry.

Line 70 duplicates the same key already defined on Line 58. Keeping a single definition avoids ambiguity and future drift in this label block.

Proposed cleanup
 LABEL \
     io.hass.name="${BUILD_NAME}" \
     io.hass.description="${BUILD_DESCRIPTION}" \
     io.hass.arch="${BUILD_ARCH}" \
     io.hass.type="app" \
     io.hass.version=${BUILD_VERSION} \
     maintainer="Franck Nijhof <opensource@frenck.dev>" \
     org.opencontainers.image.title="${BUILD_NAME}" \
     org.opencontainers.image.description="${BUILD_DESCRIPTION}" \
     org.opencontainers.image.vendor="Home Assistant Community Apps" \
     org.opencontainers.image.authors="Franck Nijhof <opensource@frenck.dev>" \
     org.opencontainers.image.licenses="MIT" \
     org.opencontainers.image.url="https://frenck.dev/home-assistant-apps" \
     org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \
     org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \
     org.opencontainers.image.created=${BUILD_DATE} \
-    org.opencontainers.image.revision=${BUILD_REF} \
-    io.hass.version=${BUILD_VERSION}
+    org.opencontainers.image.revision=${BUILD_REF}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@glances/Dockerfile` around lines 58 - 70, The Dockerfile LABEL block contains
a duplicate key "io.hass.version" (appears both in the first and last entries of
the shown LABEL list); remove the redundant occurrence so only one
"io.hass.version=${BUILD_VERSION}" remains, leaving all other labels
(maintainer, org.opencontainers.image.* and so on) untouched; update the LABEL
block where "io.hass.version" is defined to keep the single, canonical instance
and ensure no other duplicate keys are present.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@glances/rootfs/etc/services.d/glances/run`:
- Around line 34-38: The exporter invocation currently builds its own argv so
the process_info flag (when false) isn't applied; modify the run logic so the
exporter command includes the same process info setting as the main glances
invocation — e.g., reuse the existing options array or append the same
"--disable-process" flag to the exporter argv when process_info=false; update
the code that builds exporters (the exporters variable/array and the glances
start command) to ensure the exporter process is started with the same options
as the main glances instance.

In `@glances/translations/en.yaml`:
- Line 5: The description entry in glances/translations/en.yaml currently uses
the term "addon"; update the user-facing copy for the "description" key to use
"app" instead (for example change "The log level for the addon." to "The log
level for the app.") so the translation matches the PR's reclassification of
Glances as an app.

---

Nitpick comments:
In `@glances/Dockerfile`:
- Around line 58-70: The Dockerfile LABEL block contains a duplicate key
"io.hass.version" (appears both in the first and last entries of the shown LABEL
list); remove the redundant occurrence so only one
"io.hass.version=${BUILD_VERSION}" remains, leaving all other labels
(maintainer, org.opencontainers.image.* and so on) untouched; update the LABEL
block where "io.hass.version" is defined to keep the single, canonical instance
and ensure no other duplicate keys are present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 42d01af0-c3e0-4482-b993-aeb4a67ba394

📥 Commits

Reviewing files that changed from the base of the PR and between 9f526b7 and 189d08b.

📒 Files selected for processing (5)
  • glances/Dockerfile
  • glances/build.yaml
  • glances/config.yaml
  • glances/rootfs/etc/services.d/glances/run
  • glances/translations/en.yaml
💤 Files with no reviewable changes (1)
  • glances/build.yaml

Comment thread glances/rootfs/etc/services.d/glances/run Outdated
Comment thread glances/rootfs/etc/services.d/glances/run Outdated
Comment thread glances/translations/en.yaml Outdated
@ChrisHaPunkt

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
glances/rootfs/etc/services.d/glances/run (1)

61-65: 💤 Low value

On graceful shutdown (SIGTERM), the log message is misleading and exit code is non-zero.

When the container receives SIGTERM (e.g., HA stops the addon), the trap kills both children, but the script continues to wait -n, logs "exited unexpectedly", and exits 1. This isn't strictly incorrect—processes are stopped cleanly—but the log is misleading and exit code 1 may confuse orchestration layers expecting 0 for graceful shutdown.

♻️ Optional: Exit cleanly from trap
-    trap 'kill "${WEBSERVER_PID}" "${EXPORTER_PID}" 2>/dev/null' TERM INT
+    trap 'kill "${WEBSERVER_PID}" "${EXPORTER_PID}" 2>/dev/null; exit 0' TERM INT

This way, SIGTERM/INT results in immediate clean exit (code 0), while a child crash still logs the fatal message and exits 1.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@glances/rootfs/etc/services.d/glances/run` around lines 61 - 65, The shutdown
behavior is misleading: the trap currently kills WEBSERVER_PID and EXPORTER_PID
but the main flow still runs wait -n then logs via bashio::log.fatal and exits
1; change this so SIGTERM/INT performs a clean exit (0) instead of treating it
as an unexpected crash — either make the trap itself kill the children and
immediately exit 0, or have the trap set a flag (e.g., SHUTTING_DOWN=1) and
after wait -n check that flag: if set exit 0, otherwise call bashio::log.fatal
and exit 1; update references to trap, WEBSERVER_PID, EXPORTER_PID, wait -n, and
bashio::log.fatal accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@glances/rootfs/etc/services.d/glances/run`:
- Around line 61-65: The shutdown behavior is misleading: the trap currently
kills WEBSERVER_PID and EXPORTER_PID but the main flow still runs wait -n then
logs via bashio::log.fatal and exits 1; change this so SIGTERM/INT performs a
clean exit (0) instead of treating it as an unexpected crash — either make the
trap itself kill the children and immediately exit 0, or have the trap set a
flag (e.g., SHUTTING_DOWN=1) and after wait -n check that flag: if set exit 0,
otherwise call bashio::log.fatal and exit 1; update references to trap,
WEBSERVER_PID, EXPORTER_PID, wait -n, and bashio::log.fatal accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7a2a09cd-d9d1-4c7f-9358-9314aae0c21e

📥 Commits

Reviewing files that changed from the base of the PR and between 189d08b and 067bcd9.

📒 Files selected for processing (2)
  • glances/rootfs/etc/services.d/glances/run
  • glances/translations/en.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • glances/translations/en.yaml

@ChrisHaPunkt ChrisHaPunkt force-pushed the fix/influxdb-export-v4 branch from 36032bd to 781cf29 Compare May 4, 2026 13:51
@ChrisHaPunkt

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ChrisHaPunkt

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ChrisHaPunkt

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
glances/Dockerfile (1)

69-69: 💤 Low value

Consider restoring org.opencontainers.image.version for OCI compliance.

org.opencontainers.image.version is part of the OCI Image Annotation spec. Removing it means standard OCI tooling (Crane, Skopeo, ghcr.io UI) won't surface the image version from the standard label — only the HA-specific io.hass.version at line 58 remains. The fix is a single line.

♻️ Proposed restoration
     org.opencontainers.image.created=${BUILD_DATE} \
-    org.opencontainers.image.revision=${BUILD_REF}
+    org.opencontainers.image.revision=${BUILD_REF} \
+    org.opencontainers.image.version=${BUILD_VERSION}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@glances/Dockerfile` at line 69, Restore the OCI standard version label by
adding back the label org.opencontainers.image.version to the Dockerfile and set
it to the same value used for the HA-specific version label (i.e., mirror the
value used for io.hass.version) so standard OCI tooling can surface the image
version; locate the label block in the Dockerfile near the existing
io.hass.version and add a line with
org.opencontainers.image.version=<same-value-as-io.hass.version>.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@glances/Dockerfile`:
- Line 69: Restore the OCI standard version label by adding back the label
org.opencontainers.image.version to the Dockerfile and set it to the same value
used for the HA-specific version label (i.e., mirror the value used for
io.hass.version) so standard OCI tooling can surface the image version; locate
the label block in the Dockerfile near the existing io.hass.version and add a
line with org.opencontainers.image.version=<same-value-as-io.hass.version>.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ddbcb5ae-1ac5-46a2-9928-e6a840a075be

📥 Commits

Reviewing files that changed from the base of the PR and between 96ea3c5 and 9e16ea9.

📒 Files selected for processing (1)
  • glances/Dockerfile

@ChrisHaPunkt

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ChrisHaPunkt

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ChrisHaPunkt ChrisHaPunkt marked this pull request as draft May 4, 2026 17:43
@ChrisHaPunkt

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ChrisHaPunkt

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ChrisHaPunkt ChrisHaPunkt marked this pull request as ready for review May 4, 2026 18:55
@ChrisHaPunkt

Copy link
Copy Markdown
Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown
✅ Actions performed

Reviews resumed.

@ChrisHaPunkt

Copy link
Copy Markdown
Author

@frenck I kindly ask for a review :)

@ChrisHaPunkt ChrisHaPunkt force-pushed the fix/influxdb-export-v4 branch from 3d12019 to 978c4b1 Compare May 26, 2026 14:05
Glances v4 requires explicit --export flag, but combining it with -w
(webserver mode) triggers 'Export is only available in standalone or
client mode' and exits.

Run a separate lightweight Glances instance in quiet/standalone mode
for exports while the webserver runs without --export.
This is a Home Assistant Community App, not an addon. The OCI vendor
label already reflects this ("Home Assistant Community Apps").
ChrisHaPunkt and others added 15 commits May 26, 2026 16:08
Enables HA to auto-restart the addon when the Glances web server
becomes unresponsive.
Provides user-friendly labels and descriptions for all configuration
options in the HA UI.
Build configuration belongs in config.yaml per current HA developer
docs. The ARG in the Dockerfile already specifies BUILD_FROM.
Glances only reads system metrics, it never writes to the HA config
directory. Removed unnecessary :rw access.
S6-Overlay cannot be used with host_pid: true (requires PID 1).
Make this explicit in config.yaml to match the Dockerfile's
ENTRYPOINT [] override.
The InfluxDB token is a secret and should be masked in the UI,
consistent with the password field.
The exporter process built its own argv and did not include the
--disable-process flag when process_info was false, causing
inconsistent behavior between the webserver and exporter.
Consistent with the reclassification of Glances as an app.
When InfluxDB export is enabled, both processes now run in the
background with `wait -n` to detect the first exit. SIGTERM is
forwarded to both children for clean shutdown from the HA UI.

Without an exporter, the webserver runs via exec as before.
Use a SHUTTING_DOWN flag so SIGTERM/INT from HA exits cleanly (0)
instead of logging a fatal error and exiting 1.
Co-authored-by: Copilot <copilot@github.com>
@ChrisHaPunkt ChrisHaPunkt force-pushed the fix/influxdb-export-v4 branch from 978c4b1 to 1bb9342 Compare May 26, 2026 14:08
@ChrisHaPunkt

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ChrisHaPunkt

Copy link
Copy Markdown
Author

rebased, @frenck I kindly ask for a review :)

@ChrisHaPunkt ChrisHaPunkt changed the title fix: InfluxDB export for Glances v4 + HA best practices improvements chore(glances): HA add-on best practices improvements Jun 1, 2026
@ChrisHaPunkt

Copy link
Copy Markdown
Author

This PR has been split. The InfluxDB bug fix (the run script change) has been moved to a dedicated PR — #639 — so maintainers can review and merge the regression fix independently of these best-practices changes.

This PR now contains only: Dockerfile label, build.yaml removal, config.yaml improvements, and the new translations/en.yaml.

@ChrisHaPunkt

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.

@github-actions github-actions Bot added the stale There has not been activity on this issue or PR for quite some time. label Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale There has not been activity on this issue or PR for quite some time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant