From 73e9efa6d538c449814d8e7e7fa4ae9e2ee80154 Mon Sep 17 00:00:00 2001 From: Eric Ju Date: Mon, 27 Nov 2023 11:56:57 -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 | 13 ++------ internal/gitaly/service/repository/replicate.go | 34 -------------------- .../gitaly/service/repository/replicate_test.go | 37 ---------------------- 3 files changed, 3 insertions(+), 81 deletions(-) diff --git a/internal/gitaly/server/auth_test.go b/internal/gitaly/server/auth_test.go index 1c8ff4d0d..31c3e627c 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,20 +288,15 @@ 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) } diff --git a/internal/gitaly/service/repository/replicate.go b/internal/gitaly/service/repository/replicate.go index 38a90b271..65d390ca6 100644 --- a/internal/gitaly/service/repository/replicate.go +++ b/internal/gitaly/service/repository/replicate.go @@ -97,10 +97,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 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 @@ -360,36 +356,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 6b3d78910..168246f88 100644 --- a/internal/gitaly/service/repository/replicate_test.go +++ b/internal/gitaly/service/repository/replicate_test.go @@ -107,25 +107,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 { @@ -611,18 +592,6 @@ 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 custom hooks replicated. var targetHooks []string targetHooksPath := filepath.Join(targetPath, repoutil.CustomHooksDir) @@ -719,8 +688,6 @@ func TestReplicateRepository_transactional(t *testing.T) { require.NoError(t, err) - // There is no gitattributes file, so we vote on the empty contents of that file. - gitattributesVote := voting.VoteFromData([]byte{}) // There is a gitconfig though, so the vote should reflect its contents. gitconfigVote := voting.VoteFromData(testhelper.MustReadFile(t, filepath.Join(sourceRepoPath, "config"))) @@ -741,8 +708,6 @@ func TestReplicateRepository_transactional(t *testing.T) { votes[0], gitconfigVote, gitconfigVote, - gitattributesVote, - gitattributesVote, noHooksVote, noHooksVote, } @@ -769,8 +734,6 @@ func TestReplicateRepository_transactional(t *testing.T) { expectedVotes = []voting.Vote{ gitconfigVote, gitconfigVote, - gitattributesVote, - gitattributesVote, replicationVote, replicationVote, noHooksVote, -- cgit v1.2.3