You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add runSystemctl, runServiceAction, and systemctlErr helpers in pkg/daemon/agent/daemon.go; runSystemctl is the only exec.Command("systemctl", ...) call.
Migrate all six sites: is-active, daemon-reload (x2), enable, restart, start, stop/disable via systemctlIgnoringNotLoaded.
Extract isMissingUnitOutput (pure "not loaded" / "does not exist" check) and cover it with TestIsMissingUnitOutput.
Error text, log messages, fallback-to-startFallbackDaemon behaviour and the active trim check are unchanged.
Why
Six call sites repeated exec.Command(...).CombinedOutput(), the same systemctl X: %s: %w error format and a per-site //nolint:gosec. One helper makes the command boundary and its error format a single place, and the not-loaded classification becomes testable without real systemctl.
Validation
mise run cli:format (ran; no changes)
mise run cli:lint:ci (ran; only executes golangci-lint config verify, 0 issues)
golangci-lint run --new-from-rev=origin/main ./pkg/daemon/... (0 issues)
golangci-lint run ./pkg/daemon/... (4 issues, all in pkg/daemon/platform, untouched by this PR)
go test ./pkg/daemon/... (pass)
go test ./pkg/daemon/agent/ -run TestIsMissingUnitOutput -v (pass)
GOOS=linux go build ./... and GOOS=windows go build ./pkg/daemon/... (pass)
Added-comment scan of git diff origin/main -U0
CodeRabbit CLI
coderabbit review --agent --committed failed twice with Connection failed: WebSocket closed (server-side). No findings were produced. The GitHub CodeRabbit review still gates.
Auto-merge
Eligible: no (strict reading). Behaviour-preserving, size cap met: 63 changed non-test lines in 1 file (34 added, 29 removed). The one blocker is the policy's "no //nolint added": runSystemctl carries one new //nolint:gosec, replacing five existing systemctl nolints (file total 7 to 3).
Next
None.
Summary by CodeRabbit
Bug Fixes
Improved error reporting for service management operations, including clearer details when commands fail.
Service removal now handles already-missing services without reporting them as errors.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: cffe3108-4c31-45ed-a0f8-f406d7be93c8
📥 Commits
Reviewing files that changed from the base of the PR and between d710ebb and 19fc88a.
📒 Files selected for processing: 2
pkg/daemon/agent/daemon.go
pkg/daemon/agent/daemon_test.go
📝 Walkthrough
Systemd commands now use shared helpers that return command output and include it in errors. Service-running checks and unit lifecycle operations use these helpers. Removal treats output indicating a missing unit as a no-op, with tests covering missing-unit and other output.
Changes: Systemd command handling
Layer / File(s)
Summary
Shared command helpers pkg/daemon/agent/daemon.go
Added helpers to run systemd commands, run service actions, and format errors with command output. The service-running check uses the shared helpers and trims output before checking for active.
Install and service lifecycle pkg/daemon/agent/daemon.go
Unit installation and service enable, restart, and start operations use the shared helpers. Existing restart and start conditions remain unchanged.
Removal and missing-unit handling pkg/daemon/agent/daemon.go, pkg/daemon/agent/daemon_test.go
Removal uses the shared helpers for stop, disable, and daemon reload. Missing-unit output remains a no-op; tests cover missing-unit, access-denied, and empty output.
The shared systemd helpers preserve the existing command and lifecycle behavior. No actionable merge-blocking risk is established by the reviewed changes.
Pre-merge checks: 3 · 2
Failed checks: 2 warnings
Check name
Status
Explanation
Resolution
Description check
The description explains the implementation, rationale, validation results, and known lint limitation, but it does not follow the required template. It omits the required Type of change, AI assistance…
Rewrite the description using the repository template. Include the What and why section with an issue reference or 'none', select the Refactor type, complete the AI assistance disclosure and required attestations, complete the Testing secti…
Docstring Coverage
Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 2 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main change: sharing the systemctl command helper in the daemon.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description explains the implementation, rationale, validation results, and known lint limitation, but it does not follow the required template. It omits the required Type of change, AI assistance, Testing, Checklist, and Notes for reviewers sections, plus the required issue reference and checklist confirmations.
Resolution
Rewrite the description using the repository template. Include the What and why section with an issue reference or 'none', select the Refactor type, complete the AI assistance disclosure and required attestations, complete the Testing section with integration-test applicability and manual verification, and complete the Checklist. Preserve the existing implementation and validation details in the appropriate sections.
Fix all pre-merge checks with AI
✨ Finishing Touches
✨ Simplify code
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
runSystemctl,runServiceAction, andsystemctlErrhelpers inpkg/daemon/agent/daemon.go;runSystemctlis the onlyexec.Command("systemctl", ...)call.is-active,daemon-reload(x2),enable,restart,start,stop/disableviasystemctlIgnoringNotLoaded.isMissingUnitOutput(pure "not loaded" / "does not exist" check) and cover it withTestIsMissingUnitOutput.startFallbackDaemonbehaviour and theactivetrim check are unchanged.Why
Six call sites repeated
exec.Command(...).CombinedOutput(), the samesystemctl X: %s: %werror format and a per-site//nolint:gosec. One helper makes the command boundary and its error format a single place, and the not-loaded classification becomes testable without real systemctl.Validation
mise run cli:format(ran; no changes)mise run cli:lint:ci(ran; only executesgolangci-lint config verify, 0 issues)golangci-lint run --new-from-rev=origin/main ./pkg/daemon/...(0 issues)golangci-lint run ./pkg/daemon/...(4 issues, all inpkg/daemon/platform, untouched by this PR)go test ./pkg/daemon/...(pass)go test ./pkg/daemon/agent/ -run TestIsMissingUnitOutput -v(pass)GOOS=linux go build ./...andGOOS=windows go build ./pkg/daemon/...(pass)git diff origin/main -U0CodeRabbit CLI
coderabbit review --agent --committedfailed twice withConnection failed: WebSocket closed(server-side). No findings were produced. The GitHub CodeRabbit review still gates.Auto-merge
Eligible: no (strict reading). Behaviour-preserving, size cap met: 63 changed non-test lines in 1 file (34 added, 29 removed). The one blocker is the policy's "no //nolint added":
runSystemctlcarries one new//nolint:gosec, replacing five existing systemctl nolints (file total 7 to 3).Next
None.
Summary by CodeRabbit