Commit 22736570 authored by Stan Hu's avatar Stan Hu

Silence errors when Azure objects have aleady been deleted

In an normal upload flow, GitLab Rails will move a file to its final
destination and remove the temporary file. Workhorse issues a DELETE a
request to ensure this is cleaned up. Previously this was generating log
noise with every upload. Now only log an error message if there were
some error other than a 404.
parent aa34b2ac
---
title: Silence errors when Azure objects have aleady been deleted
merge_request: 585
author:
type: fixed
......@@ -7,6 +7,7 @@ import (
"gitlab.com/gitlab-org/labkit/log"
"gocloud.dev/blob"
"gocloud.dev/gcerrors"
)
type GoCloudObject struct {
......@@ -95,6 +96,8 @@ func (o *GoCloudObject) Delete() {
}
if err := bucket.Delete(deleteCtx, o.objectName); err != nil {
log.WithError(err).Error("error deleting object", err)
if gcerrors.Code(err) != gcerrors.NotFound {
log.WithError(err).Error("error deleting object")
}
}
}
......@@ -12,9 +12,12 @@ import (
"gitlab.com/gitlab-org/gitlab-workhorse/internal/objectstore"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/objectstore/test"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
)
func TestGoCloudObjectUpload(t *testing.T) {
logHook := testhelper.SetupLogger()
mux, _, cleanup := test.SetupGoCloudFileBucket(t, "azuretest")
defer cleanup()
......@@ -61,4 +64,9 @@ func TestGoCloudObjectUpload(t *testing.T) {
})
require.True(t, deleted)
// Verify no log noise when deleting a file that already is gone
object.Delete()
entries := logHook.AllEntries()
require.Equal(t, 0, len(entries))
}
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