fix(byoo-otel-collector): log otelcol-contrib exit error on shutdown#219
fix(byoo-otel-collector): log otelcol-contrib exit error on shutdown#219mesutoezdil wants to merge 4 commits into
Conversation
runSecretsCheckLoop discarded the error from Process.Wait() after both a graceful shutdown and a secrets-triggered restart, so a non-zero or signal exit from otelcol-contrib was silently dropped. Log it instead. Verified with go build, go vet, go test ./..., and golangci-lint --enable-only errcheck, all clean. NO-REF Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
…otel-collector-wait-error
📝 WalkthroughWalkthroughThe CLI now captures and logs errors returned by Changesotelcol-contrib lifecycle handling
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/compute-plane-services/byoo-otel-collector/internal/cli/cli.go`:
- Around line 75-77: Add regression tests for the otel collector wait-error
handling in both interrupt shutdown and secret-triggered restart, configuring
fakeProcess.waitErr and asserting the logger records the error from
otelCollectorProc.Wait. Cover both affected wait paths and preserve existing
behavior; only omit tests if the merge-request description documents the
specific reason.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: e1f70d70-bbc0-4932-8c8d-ae11fce4db5c
📒 Files selected for processing (1)
src/compute-plane-services/byoo-otel-collector/internal/cli/cli.go
Extract the duplicated wait-and-log logic behind otelCollectorProc.Wait() into waitAndLogProcessExit, taking a small interface instead of the concrete *os.Process so both the interrupt and secret-triggered restart paths can be exercised with a fake in a unit test. JIRA: NO-REF NVBug: none Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/compute-plane-services/byoo-otel-collector/internal/cli/cli_test.go`:
- Around line 46-48: Update the tests around the interrupt and secret-triggered
restart cases to exercise their real shutdown and restart control-flow branches,
including the corresponding runSecretsCheckLoop call sites, rather than invoking
waitAndLogProcessExit directly. Alternatively, explicitly rename them as
helper-level tests to reflect their limited coverage.
- Around line 53-54: Update the test setup around logger.Logger to capture its
original value before replacing it with the observer logger, then register
t.Cleanup to restore the original global logger after the test completes.
- Around line 58-64: Update the test’s log assertions after logs.TakeAll() to
inspect the captured entry for non-nil wait-error cases. In addition to
verifying the expected entry count, assert that its message or error field
contains tt.waitErr.Error(), while preserving the existing no-entry assertion
when tt.wantLog is false.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: e0f3122e-3480-4364-8603-51e034e155b5
📒 Files selected for processing (3)
src/compute-plane-services/byoo-otel-collector/internal/cli/BUILD.bazelsrc/compute-plane-services/byoo-otel-collector/internal/cli/cli.gosrc/compute-plane-services/byoo-otel-collector/internal/cli/cli_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
- src/compute-plane-services/byoo-otel-collector/internal/cli/cli.go
Clarify the test names as helper-level coverage, restore the global logger after each case, and assert the logged message contains the underlying wait error text instead of only counting log entries. JIRA: NO-REF NVBug: none Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
runSecretsCheckLoop discarded the error from Process.Wait() after signaling otelcol-contrib shutdown (interrupt and secret-triggered restart), silently dropping non-zero/signal exits. Now logs it. Added tests for the wait-error logging path.
Tested: go build, go vet, go test ./... pass. golangci-lint --enable-only errcheck clean.
Refs: NO-REF