Skip to content

fix(byoo-otel-collector): log otelcol-contrib exit error on shutdown#219

Open
mesutoezdil wants to merge 4 commits into
NVIDIA:mainfrom
mesutoezdil:mesutoezdil/fix/byoo-otel-collector-wait-error
Open

fix(byoo-otel-collector): log otelcol-contrib exit error on shutdown#219
mesutoezdil wants to merge 4 commits into
NVIDIA:mainfrom
mesutoezdil:mesutoezdil/fix/byoo-otel-collector-wait-error

Conversation

@mesutoezdil

@mesutoezdil mesutoezdil commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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

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>
@mesutoezdil
mesutoezdil requested a review from a team as a code owner July 16, 2026 21:52
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The CLI now captures and logs errors returned by otelCollectorProc.Wait() during termination-signal shutdown and secret-file-change restarts. A Bazel test target and table-driven tests validate the behavior.

Changes

otelcol-contrib lifecycle handling

Layer / File(s) Summary
Capture process wait errors
src/compute-plane-services/byoo-otel-collector/internal/cli/cli.go
A process-waiting helper logs non-nil wait errors during interrupt shutdown and secret-change restart paths.
Validate wait error logging
src/compute-plane-services/byoo-otel-collector/internal/cli/BUILD.bazel, src/compute-plane-services/byoo-otel-collector/internal/cli/cli_test.go
A Bazel test target and table-driven tests cover error-producing and clean process exits.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 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 clearly matches the main change: logging otelcol-contrib exit errors during shutdown.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@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

🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between ed2f0bd and 01dc720.

📒 Files selected for processing (1)
  • src/compute-plane-services/byoo-otel-collector/internal/cli/cli.go

Comment thread src/compute-plane-services/byoo-otel-collector/internal/cli/cli.go Outdated
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>

@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

🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between 01dc720 and c3f24fb.

📒 Files selected for processing (3)
  • src/compute-plane-services/byoo-otel-collector/internal/cli/BUILD.bazel
  • src/compute-plane-services/byoo-otel-collector/internal/cli/cli.go
  • src/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

Comment thread src/compute-plane-services/byoo-otel-collector/internal/cli/cli_test.go Outdated
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>
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.

1 participant