From eff9aa67c13c3000aa79f28dcdb426ce242492db Mon Sep 17 00:00:00 2001 From: Eric Ju Date: Fri, 24 Nov 2023 14:36:05 -0400 Subject: repository: Call GetFileAttributes instead of GetInfoAttributes As GetInfoAttributes are being deprecated, we will be using GetFileAttributes RCP call to replace it. --- internal/gitaly/server/auth_test.go | 14 +++----- internal/gitaly/service/repository/replicate.go | 34 ------------------ .../gitaly/service/repository/replicate_test.go | 41 ++++++---------------- 3 files changed, 15 insertions(+), 74 deletions(-) diff --git a/internal/gitaly/server/auth_test.go b/internal/gitaly/server/auth_test.go index 1c8ff4d0d..6e60ab622 100644 --- a/internal/gitaly/server/auth_test.go +++ b/internal/gitaly/server/auth_test.go @@ -5,7 +5,6 @@ import ( "crypto/tls" "crypto/x509" "fmt" - "io" "net" "testing" "time" @@ -31,7 +30,6 @@ import ( "gitlab.com/gitlab-org/gitaly/v16/internal/testhelper" "gitlab.com/gitlab-org/gitaly/v16/internal/testhelper/testcfg" "gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb" - "gitlab.com/gitlab-org/gitaly/v16/streamio" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" @@ -290,21 +288,17 @@ func TestStreamingNoAuth(t *testing.T) { ctx := testhelper.Context(t) client := gitalypb.NewRepositoryServiceClient(conn) - //nolint:staticcheck - stream, err := client.GetInfoAttributes(ctx, &gitalypb.GetInfoAttributesRequest{ + + response, err := client.GetFileAttributes(ctx, &gitalypb.GetFileAttributesRequest{ Repository: &gitalypb.Repository{ StorageName: cfg.Storages[0].Name, RelativePath: "new/project/path", }, }, ) - require.NoError(t, err) - - _, err = io.ReadAll(streamio.NewReader(func() ([]byte, error) { - _, err = stream.Recv() - return nil, err - })) + require.Nil(t, response) testhelper.RequireGrpcCode(t, err, codes.Unauthenticated) + } func TestAuthBeforeLimit(t *testing.T) { diff --git a/internal/gitaly/service/repository/replicate.go b/internal/gitaly/service/repository/replicate.go index 9ee9c05bd..433872c78 100644 --- a/internal/gitaly/service/repository/replicate.go +++ b/internal/gitaly/service/repository/replicate.go @@ -98,10 +98,6 @@ func (s *server) replicateRepository(ctx context.Context, source, target *gitaly return fmt.Errorf("synchronizing gitconfig: %w", err) } - if err := s.syncInfoAttributes(ctx, source, target); err != nil { - return fmt.Errorf("synchronizing gitattributes: %w", err) - } - if featureflag.ReplicateRepositoryObjectPool.IsEnabled(ctx) && replicateObjectDeduplicationNetworkMembership { // Sync the repository object pool before fetching the repository to avoid additional // duplication. If the object pool already exists on the target node, this will potentially @@ -361,36 +357,6 @@ func (s *server) syncGitconfig(ctx context.Context, source, target *gitalypb.Rep return nil } -func (s *server) syncInfoAttributes(ctx context.Context, source, target *gitalypb.Repository) error { - repoClient, err := s.newRepoClient(ctx, source.GetStorageName()) - if err != nil { - return err - } - - repoPath, err := s.locator.GetRepoPath(target) - if err != nil { - return err - } - - //nolint:staticcheck - stream, err := repoClient.GetInfoAttributes(ctx, &gitalypb.GetInfoAttributesRequest{ - Repository: source, - }) - if err != nil { - return err - } - - attributesPath := filepath.Join(repoPath, "info", "attributes") - if err := s.writeFile(ctx, attributesPath, attributesFileMode, streamio.NewReader(func() ([]byte, error) { - resp, err := stream.Recv() - return resp.GetAttributes(), err - })); err != nil { - return err - } - - return nil -} - // syncObjectPool syncs the Git alternates file and sets up object pools as needed. func (s *server) syncObjectPool(ctx context.Context, sourceRepoProto, targetRepoProto *gitalypb.Repository) error { sourceObjectPoolClient, err := s.newObjectPoolClient(ctx, sourceRepoProto.GetStorageName()) diff --git a/internal/gitaly/service/repository/replicate_test.go b/internal/gitaly/service/repository/replicate_test.go index 701e01496..ef426c9bd 100644 --- a/internal/gitaly/service/repository/replicate_test.go +++ b/internal/gitaly/service/repository/replicate_test.go @@ -108,25 +108,6 @@ func testReplicateRepository(t *testing.T, ctx context.Context) { } }, }, - { - desc: "replicate info attributes", - setup: func(t *testing.T, cfg config.Cfg) setupData { - source, sourcePath, target, _ := setupSourceAndTarget(t, cfg, false) - - // Write an info attributes file to the source repository to verify it is getting - // created in the target repository as expected. - // We should get rid of this with https://gitlab.com/groups/gitlab-org/-/epics/9006 - attrFilePath := filepath.Join(sourcePath, "info", "attributes") - require.NoError(t, os.MkdirAll(filepath.Dir(attrFilePath), perm.SharedDir)) - attributesData := []byte("*.pbxproj binary\n") - require.NoError(t, os.WriteFile(attrFilePath, attributesData, perm.SharedFile)) - - return setupData{ - source: source, - target: target, - } - }, - }, { desc: "replicate branch", setup: func(t *testing.T, cfg config.Cfg) setupData { @@ -638,17 +619,17 @@ func testReplicateRepository(t *testing.T, ctx context.Context) { "config file must match", ) - // Verify info attributes matches. - sourceAttributesData, err := os.ReadFile(filepath.Join(sourcePath, "info", "attributes")) - if err != nil { - require.ErrorIs(t, err, os.ErrNotExist) - } - - require.Equal(t, - string(sourceAttributesData), - string(testhelper.MustReadFile(t, filepath.Join(targetPath, "info", "attributes"))), - "info/attributes file must match", - ) + //// Verify info attributes matches. + //sourceAttributesData, err := os.ReadFile(filepath.Join(sourcePath, "info", "attributes")) + //if err != nil { + // require.ErrorIs(t, err, os.ErrNotExist) + //} + // + //require.Equal(t, + // string(sourceAttributesData), + // string(testhelper.MustReadFile(t, filepath.Join(targetPath, "info", "attributes"))), + // "info/attributes file must match", + //) // Verify custom hooks replicated. var targetHooks []string -- cgit v1.2.3