Skip to content

Commit

Permalink
app/vmagent/remotewrite: create new request on failure to send a bloc…
Browse files Browse the repository at this point in the history
…k of data to remote storage

Previously the request body was already consumed before the retry, so this led to the following error:

    http: ContentLength=... with Body length 0
  • Loading branch information
valyala committed Jul 27, 2020
1 parent 894dcb7 commit cb8c690
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/vmagent/remotewrite/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ func (c *client) runWorker() {
}

func (c *client) sendBlock(block []byte) {
retryDuration := time.Second

again:
req, err := http.NewRequest("POST", c.remoteWriteURL, bytes.NewBuffer(block))
if err != nil {
logger.Panicf("BUG: unexected error from http.NewRequest(%q): %s", c.remoteWriteURL, err)
Expand All @@ -195,9 +198,6 @@ func (c *client) sendBlock(block []byte) {
req.Header.Set("Authorization", c.authHeader)
}

retryDuration := time.Second

again:
startTime := time.Now()
resp, err := c.hc.Do(req)
c.requestDuration.UpdateDuration(startTime)
Expand Down

0 comments on commit cb8c690

Please sign in to comment.