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:
authorToon Claes <toon@gitlab.com>2023-11-07 00:03:11 +0300
committerToon Claes <toon@gitlab.com>2023-11-20 12:45:29 +0300
commita987721bb40590b47ad122c30a2aea43a8f20100 (patch)
tree6ef1163d0269906be4eca5c8dbb71ae9e141464e
parent446b24a8771260751615ad51efeadfb1c166217d (diff)
ssh: Advertise server-side backups as bundle-URI
In previous commits, we've added server-side backups for bundle-URI in the smarthttp server. Now we can do the same in the ssh server and advertise server-side bundles to be used for bundle-URI. Inject all the git configuration into the git-upload-pack(1) command to advertise these when possible. Label: feature::addition
-rw-r--r--internal/gitaly/service/ssh/server.go5
-rw-r--r--internal/gitaly/service/ssh/upload_pack.go4
-rw-r--r--internal/gitaly/service/ssh/upload_pack_test.go25
3 files changed, 29 insertions, 5 deletions
diff --git a/internal/gitaly/service/ssh/server.go b/internal/gitaly/service/ssh/server.go
index 65ba2180c..8ad343834 100644
--- a/internal/gitaly/service/ssh/server.go
+++ b/internal/gitaly/service/ssh/server.go
@@ -2,6 +2,7 @@ package ssh
import (
"github.com/prometheus/client_golang/prometheus"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/backup"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/service"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
@@ -20,6 +21,8 @@ type server struct {
uploadPackRequestTimeoutTickerFactory func() helper.Ticker
uploadArchiveRequestTimeoutTickerFactory func() helper.Ticker
packfileNegotiationMetrics *prometheus.CounterVec
+ backupLocator backup.Locator
+ backupSink backup.Sink
}
// NewServer creates a new instance of a grpc SSHServer
@@ -39,6 +42,8 @@ func NewServer(deps *service.Dependencies, serverOpts ...ServerOpt) gitalypb.SSH
prometheus.CounterOpts{},
[]string{"git_negotiation_feature"},
),
+ backupLocator: deps.GetBackupLocator(),
+ backupSink: deps.GetBackupSink(),
}
for _, serverOpt := range serverOpts {
diff --git a/internal/gitaly/service/ssh/upload_pack.go b/internal/gitaly/service/ssh/upload_pack.go
index 0652d2c1f..1036d8f52 100644
--- a/internal/gitaly/service/ssh/upload_pack.go
+++ b/internal/gitaly/service/ssh/upload_pack.go
@@ -7,6 +7,7 @@ import (
"io"
"sync"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/bundleuri"
"gitlab.com/gitlab-org/gitaly/v16/internal/command"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/pktline"
@@ -111,6 +112,9 @@ func (s *server) sshUploadPack(ctx context.Context, req sshUploadPackRequest, st
stats.UpdateMetrics(s.packfileNegotiationMetrics)
}()
+ config = append(config,
+ bundleuri.UploadPackGitConfig(ctx, s.backupLocator, s.backupSink, req.GetRepository())...)
+
commandOpts := []git.CmdOpt{
git.WithGitProtocol(s.logger, req),
git.WithConfig(config...),
diff --git a/internal/gitaly/service/ssh/upload_pack_test.go b/internal/gitaly/service/ssh/upload_pack_test.go
index 580755615..88271f121 100644
--- a/internal/gitaly/service/ssh/upload_pack_test.go
+++ b/internal/gitaly/service/ssh/upload_pack_test.go
@@ -36,7 +36,10 @@ import (
)
func runTestWithAndWithoutConfigOptions(t *testing.T, tf func(t *testing.T, ctx context.Context, opts ...testcfg.Option), opts ...testcfg.Option) {
- testhelper.NewFeatureSets(featureflag.UploadPackBoundaryBitmapTraversal).Run(t, func(t *testing.T, ctx context.Context) {
+ testhelper.NewFeatureSets(
+ featureflag.UploadPackBoundaryBitmapTraversal,
+ featureflag.BundleURI,
+ ).Run(t, func(t *testing.T, ctx context.Context) {
t.Run("no config options", func(t *testing.T) { tf(t, ctx) })
if len(opts) > 0 {
@@ -160,7 +163,10 @@ func testUploadPackTimeout(t *testing.T, ctx context.Context, opts ...testcfg.Op
func TestUploadPackWithSidechannel_client(t *testing.T) {
t.Parallel()
- testhelper.NewFeatureSets(featureflag.UploadPackBoundaryBitmapTraversal).Run(t, testUploadPackWithSidechannelClient)
+ testhelper.NewFeatureSets(
+ featureflag.UploadPackBoundaryBitmapTraversal,
+ featureflag.BundleURI,
+ ).Run(t, testUploadPackWithSidechannelClient)
}
func testUploadPackWithSidechannelClient(t *testing.T, ctx context.Context) {
@@ -475,7 +481,10 @@ func requireFailedSSHStream(t *testing.T, expectedErr error, recv func() (int32,
func TestUploadPack_validation(t *testing.T) {
t.Parallel()
- testhelper.NewFeatureSets(featureflag.UploadPackBoundaryBitmapTraversal).Run(t, testUploadPackValidation)
+ testhelper.NewFeatureSets(
+ featureflag.UploadPackBoundaryBitmapTraversal,
+ featureflag.BundleURI,
+ ).Run(t, testUploadPackValidation)
}
func testUploadPackValidation(t *testing.T, ctx context.Context) {
@@ -777,7 +786,10 @@ func testUploadPackWithoutSideband(t *testing.T, ctx context.Context, opts ...te
func TestUploadPack_invalidStorage(t *testing.T) {
t.Parallel()
- testhelper.NewFeatureSets(featureflag.UploadPackBoundaryBitmapTraversal).Run(t, testUploadPackInvalidStorage)
+ testhelper.NewFeatureSets(
+ featureflag.UploadPackBoundaryBitmapTraversal,
+ featureflag.BundleURI,
+ ).Run(t, testUploadPackInvalidStorage)
}
func testUploadPackInvalidStorage(t *testing.T, ctx context.Context) {
@@ -806,7 +818,10 @@ func testUploadPackInvalidStorage(t *testing.T, ctx context.Context) {
func TestUploadPack_gitFailure(t *testing.T) {
t.Parallel()
- testhelper.NewFeatureSets(featureflag.UploadPackBoundaryBitmapTraversal).Run(t, testUploadPackGitFailure)
+ testhelper.NewFeatureSets(
+ featureflag.UploadPackBoundaryBitmapTraversal,
+ featureflag.BundleURI,
+ ).Run(t, testUploadPackGitFailure)
}
func testUploadPackGitFailure(t *testing.T, ctx context.Context) {