Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

services/horizon: Fix stream parsing error printing in captive core #4066

Merged
merged 1 commit into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ingest/ledgerbackend/captive_core_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,10 @@ func (c *CaptiveStellarCore) checkMetaPipeResult(result metaResult, ok bool) err
return err
}
if !ok || result.err != nil {
if exited, err := c.stellarCoreRunner.getProcessExitError(); exited {
if result.err != nil {
// Case 3 - Some error was encountered while consuming the ledger stream emitted by captive core.
return result.err
} else if exited, err := c.stellarCoreRunner.getProcessExitError(); exited {
// Case 2 - The stellar core process exited unexpectedly
if err == nil {
return errors.Errorf("stellar core exited unexpectedly")
Expand All @@ -570,9 +573,6 @@ func (c *CaptiveStellarCore) checkMetaPipeResult(result metaResult, ok bool) err
// if and only if the process exits or the context is cancelled.
// However, we add this check for the sake of completeness
return errors.Errorf("meta pipe closed unexpectedly")
} else {
// Case 3 - Some error was encountered while consuming the ledger stream emitted by captive core.
return result.err
}
}
return nil
Expand Down
5 changes: 2 additions & 3 deletions ingest/ledgerbackend/captive_core_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,6 @@ func TestCaptiveGetLedger_ErrReadingMetaResult(t *testing.T) {
mockRunner.On("getMetaPipe").Return((<-chan metaResult)(metaChan))
ctx, cancel := context.WithCancel(ctx)
mockRunner.On("context").Return(ctx)
mockRunner.On("getProcessExitError").Return(false, nil)
mockRunner.On("close").Return(nil).Run(func(args mock.Arguments) {
cancel()
}).Once()
Expand Down Expand Up @@ -1071,15 +1070,15 @@ func TestCaptiveGetLedgerTerminatedUnexpectedly(t *testing.T) {
{
"stellar core exited unexpectedly without error",
context.Background(),
[]metaResult{{LedgerCloseMeta: &ledger64}, {err: fmt.Errorf("transient error")}},
[]metaResult{{LedgerCloseMeta: &ledger64}},
true,
nil,
"stellar core exited unexpectedly",
},
{
"stellar core exited unexpectedly with an error",
context.Background(),
[]metaResult{{LedgerCloseMeta: &ledger64}, {err: fmt.Errorf("transient error")}},
[]metaResult{{LedgerCloseMeta: &ledger64}},
true,
fmt.Errorf("signal kill"),
"stellar core exited unexpectedly: signal kill",
Expand Down