Skip to content

Commit

Permalink
Use exponential backoff when waiting for a journal entry
Browse files Browse the repository at this point in the history
When looking for a cursor that matches the first journal entry for a
given container, wait and try to find it using exponential backoff.

[NO NEW TESTS NEEDED]

Signed-off-by: Nalin Dahyabhai <[email protected]>
  • Loading branch information
nalind authored and mheon committed Nov 12, 2021
1 parent 3b67336 commit 465e27c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libpod/container_log_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ func (c *Container) readFromJournal(ctx context.Context, options *logs.LogOption
var cursorError error
for i := 1; i <= 3; i++ {
cursor, cursorError = journal.GetCursor()
hundreds := 1
for j := 1; j < i; j++ {
hundreds *= 2
}
if cursorError != nil {
time.Sleep(time.Duration(i*100) * time.Millisecond)
time.Sleep(time.Duration(hundreds*100) * time.Millisecond)
continue
}
break
Expand Down

0 comments on commit 465e27c

Please sign in to comment.