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>2022-09-21 16:08:56 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-09-22 09:47:08 +0300
commitf169b5d94b061fc6e939b485706da969d6955d06 (patch)
tree3a4fb0b3cbdeb27f1435920bfd74c91271361f00
parentb4c1f29c487a41b2e69a31a99f6b0ac462c81ce4 (diff)
ref: Always use structured errors in FindTag RPC
With 453ac57fc (ref: Fix `Internal` errors in `FindTag()` when tag doesn't exist, 2022-08-01) we have adapted the FindTag RPC to return a `NotFound` error instead of an `Internal` one when the tag wasn't found in order to clearly label this error condition as expected. This code has been rolled out to production on August 2nd without any observed negative fallout. Remove the feature flag guarding it. Changelog: changed
-rw-r--r--internal/gitaly/service/ref/find_tag.go27
-rw-r--r--internal/gitaly/service/ref/find_tag_test.go34
-rw-r--r--internal/metadata/featureflag/ff_find_tag_structured_error.go10
3 files changed, 23 insertions, 48 deletions
diff --git a/internal/gitaly/service/ref/find_tag.go b/internal/gitaly/service/ref/find_tag.go
index b23b50b3e..a96e9db78 100644
--- a/internal/gitaly/service/ref/find_tag.go
+++ b/internal/gitaly/service/ref/find_tag.go
@@ -10,7 +10,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v15/internal/helper"
- "gitlab.com/gitlab-org/gitaly/v15/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
)
@@ -95,25 +94,21 @@ func (s *server) findTag(ctx context.Context, repo git.RepositoryExecutor, tagNa
return nil, err
}
} else {
- if featureflag.FindTagStructuredError.IsEnabled(ctx) {
- detailedErr, err := helper.ErrWithDetails(
- helper.ErrNotFoundf("tag does not exist"),
- &gitalypb.FindTagError{
- Error: &gitalypb.FindTagError_TagNotFound{
- TagNotFound: &gitalypb.ReferenceNotFoundError{
- ReferenceName: []byte(fmt.Sprintf("refs/tags/%s", tagName)),
- },
+ detailedErr, err := helper.ErrWithDetails(
+ helper.ErrNotFoundf("tag does not exist"),
+ &gitalypb.FindTagError{
+ Error: &gitalypb.FindTagError_TagNotFound{
+ TagNotFound: &gitalypb.ReferenceNotFoundError{
+ ReferenceName: []byte(fmt.Sprintf("refs/tags/%s", tagName)),
},
},
- )
- if err != nil {
- return nil, helper.ErrInternalf("generating detailed error: %w", err)
- }
-
- return nil, detailedErr
+ },
+ )
+ if err != nil {
+ return nil, helper.ErrInternalf("generating detailed error: %w", err)
}
- return nil, errors.New("no tag found")
+ return nil, detailedErr
}
if err = tagCmd.Wait(); err != nil {
diff --git a/internal/gitaly/service/ref/find_tag_test.go b/internal/gitaly/service/ref/find_tag_test.go
index aeeaf9c56..9baebb4e3 100644
--- a/internal/gitaly/service/ref/find_tag_test.go
+++ b/internal/gitaly/service/ref/find_tag_test.go
@@ -3,7 +3,6 @@
package ref
import (
- "context"
"fmt"
"strings"
"testing"
@@ -15,7 +14,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/updateref"
"gitlab.com/gitlab-org/gitaly/v15/internal/helper"
- "gitlab.com/gitlab-org/gitaly/v15/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
"google.golang.org/grpc/codes"
@@ -263,12 +261,8 @@ func TestFindTag_nestedTag(t *testing.T) {
func TestFindTag_notFound(t *testing.T) {
t.Parallel()
- testhelper.NewFeatureSets(featureflag.FindTagStructuredError).Run(t, testFindTagNotFound)
-}
-
-func testFindTagNotFound(t *testing.T, ctx context.Context) {
- t.Parallel()
+ ctx := testhelper.Context(t)
cfg, client := setupRefServiceWithoutRepo(t)
repoProto, _ := gittest.CreateRepository(ctx, t, cfg)
@@ -277,23 +271,19 @@ func testFindTagNotFound(t *testing.T, ctx context.Context) {
TagName: []byte("does-not-exist"),
})
require.Nil(t, response)
- if featureflag.FindTagStructuredError.IsEnabled(ctx) {
- expectedErr, errGeneratingDetails := helper.ErrWithDetails(
- helper.ErrNotFoundf("tag does not exist"),
- &gitalypb.FindTagError{
- Error: &gitalypb.FindTagError_TagNotFound{
- TagNotFound: &gitalypb.ReferenceNotFoundError{
- ReferenceName: []byte("refs/tags/does-not-exist"),
- },
+
+ expectedErr, errGeneratingDetails := helper.ErrWithDetails(
+ helper.ErrNotFoundf("tag does not exist"),
+ &gitalypb.FindTagError{
+ Error: &gitalypb.FindTagError_TagNotFound{
+ TagNotFound: &gitalypb.ReferenceNotFoundError{
+ ReferenceName: []byte("refs/tags/does-not-exist"),
},
},
- )
- require.NoError(t, errGeneratingDetails)
-
- testhelper.RequireGrpcError(t, expectedErr, err)
- } else {
- testhelper.RequireGrpcError(t, helper.ErrInternalf("no tag found"), err)
- }
+ },
+ )
+ require.NoError(t, errGeneratingDetails)
+ testhelper.RequireGrpcError(t, expectedErr, err)
}
func TestFindTag_invalidRequest(t *testing.T) {
diff --git a/internal/metadata/featureflag/ff_find_tag_structured_error.go b/internal/metadata/featureflag/ff_find_tag_structured_error.go
deleted file mode 100644
index 900f1eefc..000000000
--- a/internal/metadata/featureflag/ff_find_tag_structured_error.go
+++ /dev/null
@@ -1,10 +0,0 @@
-package featureflag
-
-// FindTagStructuredError enables the use of structured errors for the FindTag RPC in case the tag
-// could not be found.
-var FindTagStructuredError = NewFeatureFlag(
- "find_tag_structured_error",
- "v15.3.0",
- "https://gitlab.com/gitlab-org/gitaly/-/issues/4398",
- false,
-)