Commit 23b6b841 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'sh-silence-gocloud-404-deletions' into 'master'

Silence errors when Azure objects have aleady been deleted

See merge request gitlab-org/gitlab-workhorse!585
parents 692f1705 22736570
---
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