Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2020-12-14 12:23:51 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-12-14 12:23:51 +0300
commit993f4ccd104882e0766bd1377f24642603bd558f (patch)
tree681f7f06dcb7eaef2d530f552bd0a207892cf670
parentfb388ea4f85f04dc88e657fbbf33dbe571e19bd8 (diff)
parent6f1ef4b49a87897668d40b7ba77e08973668162b (diff)
Merge branch 'sh-fix-issue-3305' into 'master'
Run housekeeping on pool repository See merge request gitlab-org/gitaly!2916
-rw-r--r--changelogs/unreleased/sh-fix-issue-3305.yml5
-rw-r--r--internal/git/objectpool/fetch.go7
-rw-r--r--internal/gitaly/service/objectpool/fetch_into_object_pool_test.go19
3 files changed, 30 insertions, 1 deletions
diff --git a/changelogs/unreleased/sh-fix-issue-3305.yml b/changelogs/unreleased/sh-fix-issue-3305.yml
new file mode 100644
index 000000000..a138574a2
--- /dev/null
+++ b/changelogs/unreleased/sh-fix-issue-3305.yml
@@ -0,0 +1,5 @@
+---
+title: Run housekeeping on pool repository
+merge_request: 2916
+author:
+type: fixed
diff --git a/internal/git/objectpool/fetch.go b/internal/git/objectpool/fetch.go
index 41967d029..d49b60043 100644
--- a/internal/git/objectpool/fetch.go
+++ b/internal/git/objectpool/fetch.go
@@ -38,7 +38,12 @@ func (o *ObjectPool) FetchFromOrigin(ctx context.Context, origin *gitalypb.Repos
return err
}
- if err := housekeeping.Perform(ctx, originPath); err != nil {
+ poolPath, err := o.locator.GetPath(o)
+ if err != nil {
+ return err
+ }
+
+ if err := housekeeping.Perform(ctx, poolPath); err != nil {
return err
}
diff --git a/internal/gitaly/service/objectpool/fetch_into_object_pool_test.go b/internal/gitaly/service/objectpool/fetch_into_object_pool_test.go
index 81c4a0d57..68e605001 100644
--- a/internal/gitaly/service/objectpool/fetch_into_object_pool_test.go
+++ b/internal/gitaly/service/objectpool/fetch_into_object_pool_test.go
@@ -3,9 +3,12 @@ package objectpool
import (
"bytes"
"encoding/json"
+ "io/ioutil"
+ "os"
"path/filepath"
"strings"
"testing"
+ "time"
"github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/sirupsen/logrus"
@@ -63,6 +66,22 @@ func TestFetchIntoObjectPool_Success(t *testing.T) {
_, err = client.FetchIntoObjectPool(ctx, req)
require.NoError(t, err, "calling FetchIntoObjectPool twice should be OK")
require.True(t, pool.IsValid(), "ensure that pool is valid")
+
+ // Simulate a broken ref
+ poolPath, err := locator.GetRepoPath(pool)
+ require.NoError(t, err)
+ brokenRef := filepath.Join(poolPath, "refs", "heads", "broken")
+ err = ioutil.WriteFile(brokenRef, []byte{}, 0777)
+ require.NoError(t, err)
+
+ oldTime := time.Now().Add(-25 * time.Hour)
+ require.NoError(t, os.Chtimes(brokenRef, oldTime, oldTime))
+
+ _, err = client.FetchIntoObjectPool(ctx, req)
+ require.NoError(t, err)
+
+ _, err = os.Stat(brokenRef)
+ require.Error(t, err, "Expected refs/heads/broken to be deleted")
}
func TestFetchIntoObjectPool_CollectLogStatistics(t *testing.T) {