Commit a3c000b9 authored by Jacob Vosmaer's avatar Jacob Vosmaer Committed by Nick Thomas

Fix objectstore.uploader.uploadError race

parent aa34b2ac
---
title: Fix objectstore.uploader.uploadError race
merge_request: 583
author:
type: fixed
......@@ -100,9 +100,13 @@ func (u *uploader) Execute(ctx context.Context, deadline time.Time) {
if u.metrics {
go u.trackUploadTime()
}
go u.cleanup(ctx)
uploadDone := make(chan struct{})
go u.cleanup(ctx, uploadDone)
go func() {
defer cancelFn()
defer close(uploadDone)
if u.metrics {
defer objectStorageUploadsOpen.Dec()
}
......@@ -145,10 +149,11 @@ func (u *uploader) trackUploadTime() {
}
}
func (u *uploader) cleanup(ctx context.Context) {
func (u *uploader) cleanup(ctx context.Context, uploadDone chan struct{}) {
// wait for the upload to finish
<-u.ctx.Done()
<-uploadDone
if u.uploadError != nil {
if u.metrics {
objectStorageUploadRequestsRequestFailed.Inc()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment