Skip to content

Commit

Permalink
Fix stream parsing error printing in captive core (#4066)
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio authored Nov 12, 2021
1 parent e9d8dbd commit 9271fc3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
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

0 comments on commit 9271fc3

Please sign in to comment.