Skip to content

feat: implement retry mechanism for log processing#136

Merged
kacpersaw merged 6 commits into
mainfrom
kacpersaw/feat-log-queue
Sep 30, 2025
Merged

feat: implement retry mechanism for log processing#136
kacpersaw merged 6 commits into
mainfrom
kacpersaw/feat-log-queue

Conversation

@kacpersaw

Copy link
Copy Markdown
Contributor

Closes #119

This PR adds error handling and retry functionality to the log streaming by adding exponential backoff retry logic for failed log operations.

Changes

  • Added retry mechanism with exponential backoff - automatically retries failed log operations, starting at 1 second delay and doubling up to 30 seconds max
  • Retry logic for failed API operations - triggers retries for PostLogSource and Agent dRPC client failures to handle connection issues
  • Per-agent retry state tracking - built retry state struct for each agent with individual timer and delay management
  • Automatic retry cleanup - clears retry state on successful operations and proper cleanup on agent deletion
  • Tests

With this PR, users will see more reliable logs from pod startup in their Coder workspace, including pod events before container startup that were previously not visible.

image

@kacpersaw kacpersaw marked this pull request as ready for review September 22, 2025 10:02

@deansheather deansheather left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when the log never succeeds? Maybe because an agent token is no longer valid. Judging by the code, logstream will attempt to send it to coder Forever

Comment thread logger.go Outdated
Comment thread logger.go Outdated
Comment thread logger.go
Comment thread logger.go Outdated
Comment thread logger.go Outdated
Comment thread helm/values.yaml Outdated
Comment thread logger.go
l.logger.Error(ctx, "max retries exceeded",
slog.F("retryCount", rs.retryCount),
slog.F("maxRetries", l.maxRetries))
rs.exhausted = true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be kept in memory forever now right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…efault of 15 retries for log send failures.
@kacpersaw kacpersaw merged commit a5bd376 into main Sep 30, 2025
1 check passed
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.

Pod events before container startup are not visible in Coder UI

2 participants