Skip to content

app/vlagent: move backoff timer logic to a separate package#1194

Open
vadimalekseev wants to merge 1 commit intomasterfrom
backoff-timer
Open

app/vlagent: move backoff timer logic to a separate package#1194
vadimalekseev wants to merge 1 commit intomasterfrom
backoff-timer

Conversation

@vadimalekseev
Copy link
Member

@vadimalekseev vadimalekseev commented Mar 18, 2026

Describe Your Changes

I'm working on moving the file-reading logic into a separate package. This change is needed to support not only Kubernetes Pods but also reading from arbitrary files via glob patterns and reading Docker containers. See #1195 for details.

During the migration, I noticed that the backoffTimer struct is being used across several different packages. It could also be utilized in the remotewrite package (see the usage example in this PR). The same approach can be applied to these locations in the VictoriaMetrics repository:

I believe this logic should be moved to the timeutil package within the VictoriaMetrics repository.

Checklist

The following checks are mandatory:

@vadimalekseev vadimalekseev requested a review from valyala March 18, 2026 21:13
select {
case <-c.stopCh:
timerpool.Put(t)
remoteWriteRetryLogger.Warnf("couldn't send a block with size %d bytes to %q: %s; re-sending the block in %s",
Copy link
Member Author

Choose a reason for hiding this comment

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

%.3f was replaced with %s because backoffTimer returns multiples of minInterval without jitter. For example: 100ms, 200ms, 400ms, 800ms, 1.6s, etc.


defer func() {
v := retryAfterDuration.Seconds()
logger.Infof("'Retry-After: %s' parsed into %.2f second(s)", retryAfterString, v)
Copy link
Member Author

Choose a reason for hiding this comment

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

Can someone confirm or deny if this log was added by accident?

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 6 files

)

// BackoffTimer implements an exponential backoff timer with jitter.
type BackoffTimer struct {
Copy link
Member Author

Choose a reason for hiding this comment

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

I think it would be useful to add a noCopy struct here to prevent accidental copying of the BackoffTimer. See this issue for details:
golang/go#8005 (comment)

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

Labels

None yet

1 participant