Skip to content

fix(runtime): log service startup errors instead of printing them beside the log#3140

Open
dschmidt wants to merge 2 commits into
mainfrom
fix/service-startup-logging
Open

fix(runtime): log service startup errors instead of printing them beside the log#3140
dschmidt wants to merge 2 commits into
mainfrom
fix/service-startup-logging

Conversation

@dschmidt

@dschmidt dschmidt commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Service startup errors were printed as plain text into the log stream (SilenceErrors/SilenceUsage unset on the cobra app), and the one record about the failure carried "error":{} (suture's ev.Err is an interface{}, so it got marshaled instead of passed to Err()).

The example below is the schema mismatch error from #3098, but this is not specific to it: every startup error of every service has this shape.

before:

{"level":"warn","service":"proxy","time":"...","message":"No tls certificate provided, using a generated one"}
Error: manual action required: search index /var/lib/opencloud/search/bleve was built with a different schema:
  - field Deleted is explicitly mapped now, but the index already holds data that was indexed dynamically for it, of an unknown type
  [... 10 more ...]
There is no in-place migration: with the OpenCloud search service stopped, delete the index directory /var/lib/opencloud/search/bleve, then start it again ...
Usage:
  search server [flags]

Flags:
  -h, --help   help for server

{"level":"error","service":"opencloud","event":"opencloud: Failed service 'search' (1.000000 failures of 5.000000), restarting: true, error: manual action required: search index ...","service":"search","supervisor":"opencloud","restarting":true,"failures":1,"threshold":5,"error":{},"time":"...","message":"service terminated"}

after:

{"level":"error","service":"opencloud","event":"opencloud: Failed service 'search' (1.000000 failures of 5.000000), restarting: true, error: manual action required: search index ...","service":"search","supervisor":"opencloud","restarting":true,"failures":1,"threshold":5,"error":"manual action required: search index /var/lib/opencloud/search/bleve was built with a different schema:\n  - field Deleted is explicitly mapped now, but the index already holds data that was indexed dynamically for it, of an unknown type\n  [... 10 more ...]\nThere is no in-place migration: with the OpenCloud search service stopped, delete the index directory /var/lib/opencloud/search/bleve, then start it again ...","time":"...","message":"service terminated"}

@codacy-production

codacy-production Bot commented Jul 15, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

🟢 Coverage 0.00% diff coverage · -0.03% coverage variation

Metric Results
Coverage variation -0.03% coverage variation (-1.00%)
Diff coverage 0.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (85e63ca) 82473 19129 23.19%
Head commit (fec92d2) 82490 (+17) 19112 (-17) 23.17% (-0.03%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#3140) 21 0 0.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@dschmidt
dschmidt marked this pull request as ready for review July 15, 2026 17:11
@dschmidt
dschmidt requested a review from Copilot July 15, 2026 17:11

Copilot AI 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.

Pull request overview

This PR fixes how service startup failures surface in logs by preventing Cobra from printing raw error/usage text into the log stream and by ensuring supervised service termination events log the actual error message (instead of "error":{}).

Changes:

  • Configure Cobra commands via clihelper.DefaultApp to silence Cobra’s own error printing and to silence usage output once command execution begins.
  • Update the runtime suture event hook to log EventServiceTerminate.Err via the logger’s Err() path when it’s an error, producing a proper "error":"..." field.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/clihelper/app.go Silences Cobra error printing and suppresses usage output after hooks start running to avoid plain-text noise in logs.
opencloud/pkg/runtime/service/service.go Logs supervised service termination errors using Err() (when applicable) so JSON logs contain the real error string instead of an empty object.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants