Skip to content

Redirect LOG_FD also when suppressing log messages#669

Open
lmagyar wants to merge 1 commit into
hassio-addons:mainfrom
lmagyar:pr-logfd-redirect
Open

Redirect LOG_FD also when suppressing log messages#669
lmagyar wants to merge 1 commit into
hassio-addons:mainfrom
lmagyar:pr-logfd-redirect

Conversation

@lmagyar

@lmagyar lmagyar commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

Proposed Changes

Sadly we must use eval, ${LOG_FD}> /dev/null never redirected, only string constants (like 10> /dev/null are interpreted as file descriptor. This is how bash works.

Related Issues

Summary by CodeRabbit

  • Refactor
    • Improved internal supervisor API call execution and logging configuration across startup initialization scripts to enhance reliability and consistency in command processing.

@lmagyar lmagyar added the bugfix Inconsistencies or issues which will cause a problem for users or implementors. label Apr 15, 2026
@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown

Walkthrough

Three bash scripts in the Tailscale addon are updated to wrap supervisor API calls with eval and incorporate ${LOG_FD} into output redirection, altering how logging and file descriptor streams are handled during startup checks and polling loops without changing control flow logic.

Changes

Cohort / File(s) Summary
Startup API Calls
tailscale/rootfs/etc/s6-overlay/s6-rc.d/forwarding/run, tailscale/rootfs/etc/s6-overlay/s6-rc.d/local-network/run
Wraps bashio::api.supervisor GET calls with eval to adjust output redirection using ${LOG_FD} during network interface initialization checks.
Supervisor Readiness Polling
tailscale/rootfs/usr/bin/protect-subnet-routes
Wraps two bashio::api.supervisor GET calls with eval incorporating ${LOG_FD} redirection in the supervisor-readiness polling loop.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

no-stale

Suggested reviewers

  • frenck

Poem

🐰 A rabbit hops through logs so bright,
Redirecting streams with eval's might,
Where LOG_FD flows like morning dew,
The scripts now log what they pursue! 📝✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: redirecting LOG_FD when suppressing log messages, which is the core objective across all three modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

@lmagyar

lmagyar commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 15, 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.

@hassio-addons hassio-addons deleted a comment from coderabbitai Bot Apr 15, 2026

@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: 1

🧹 Nitpick comments (1)
tailscale/rootfs/usr/bin/protect-subnet-routes (1)

29-30: Consider a shared silent Supervisor probe helper.

This exact eval + dynamic LOG_FD redirection now appears twice in this file and in both s6 run scripts. A small wrapper would give you one place to validate LOG_FD and one place to adjust the redirection syntax later.

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

In `@tailscale/rootfs/usr/bin/protect-subnet-routes` around lines 29 - 30, Extract
the duplicated silent Supervisor probe logic (the eval "bashio::api.supervisor
GET ... &> /dev/null ${LOG_FD}> /dev/null" pattern) into a single helper
function (e.g., supervisor_silent_probe or probe_supervisor) that
validates/normalizes LOG_FD and performs the dynamic redirection, then replace
both occurrences (the while loop condition in protect-subnet-routes and the two
s6 run scripts) with calls to that helper; ensure the helper accepts the full
API path string and returns the original command exit status so existing
while/if logic (using the helper name) works unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tailscale/rootfs/etc/s6-overlay/s6-rc.d/forwarding/run`:
- Line 79: LOG_FD is interpolated directly into eval which breaks when it
contains non-digits; add the same guard used in healthcheck/protect-subnets to
validate LOG_FD is numeric before embedding it. Specifically, in forwarding/run
(the eval invoking "bashio::api.supervisor GET /network/interface/default/info
..."), and likewise in protect-subnet-routes and local-network/run, check that
LOG_FD matches a digits-only regex (e.g. ^[0-9]+$) and only append the
redirection token into the eval when that check passes (otherwise fall back to a
safe default or omit the redirection). Reference the existing validation pattern
in healthcheck/protect-subnets and apply it to these eval usages so non-numeric
inherited values do not produce shell syntax errors.

---

Nitpick comments:
In `@tailscale/rootfs/usr/bin/protect-subnet-routes`:
- Around line 29-30: Extract the duplicated silent Supervisor probe logic (the
eval "bashio::api.supervisor GET ... &> /dev/null ${LOG_FD}> /dev/null" pattern)
into a single helper function (e.g., supervisor_silent_probe or
probe_supervisor) that validates/normalizes LOG_FD and performs the dynamic
redirection, then replace both occurrences (the while loop condition in
protect-subnet-routes and the two s6 run scripts) with calls to that helper;
ensure the helper accepts the full API path string and returns the original
command exit status so existing while/if logic (using the helper name) works
unchanged.
🪄 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: e8b0276c-2761-423a-b7b4-98a7d3c307ae

📥 Commits

Reviewing files that changed from the base of the PR and between 02fbebc and f2323ce.

📒 Files selected for processing (3)
  • tailscale/rootfs/etc/s6-overlay/s6-rc.d/forwarding/run
  • tailscale/rootfs/etc/s6-overlay/s6-rc.d/local-network/run
  • tailscale/rootfs/usr/bin/protect-subnet-routes

Comment thread tailscale/rootfs/etc/s6-overlay/s6-rc.d/forwarding/run
@lmagyar lmagyar added the no-stale This issue or PR is exempted from the stable bot. label May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Inconsistencies or issues which will cause a problem for users or implementors. no-stale This issue or PR is exempted from the stable bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant