-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
103856: cloud,grpcutil: avoid pretty-printing nil gRPC status r=knz a=stevendanna In some cases, errors from the GCP library would be printed as grpc: [code 0/OK] This was the result of a few interacting features and changes: - The GCP library added an Unwrap() method to the error type they returned. - Our errors library has code to manually unwrap errors. - The underlying GCP error attempts to abstract over gRPC and HTTP errors. It implements a GRPCStatus() method that returns nil if the underlying issue was an HTTP issue. - Our custom error printer in grpcutil would specially print anything that implements GRPCStatus(), regardless of the return value. Here, I've updated the custom printer to ignore cases where GRPCStatus() returns nil. Epic: CRDB-27642 Release note (bug fix): Fix a bug in which some GCP-related errors would be returned with an uninformative error. Co-authored-by: Steven Danna <[email protected]>
- Loading branch information
Showing
6 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2023 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package gcp | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cockroachdb/errors" | ||
"github.com/googleapis/gax-go/v2/apierror" | ||
"github.com/stretchr/testify/assert" | ||
"google.golang.org/api/googleapi" | ||
) | ||
|
||
func TestErrorBehaviour(t *testing.T) { | ||
orig := &googleapi.Error{ | ||
Code: 403, | ||
Message: "ACCESS DENIED. ALL YOUR BASE ARE BELONG TO US", | ||
} | ||
apiError, ok := apierror.ParseError(orig, false) | ||
if ok { | ||
orig.Wrap(apiError) | ||
} | ||
wrap1 := errors.Wrap(orig, "wrap1") | ||
wrap2 := errors.Wrap(wrap1, "wrap2") | ||
assert.Equal(t, "wrap1: googleapi: Error 403: ACCESS DENIED. ALL YOUR BASE ARE BELONG TO US", wrap1.Error()) | ||
assert.Equal(t, "wrap2: wrap1: googleapi: Error 403: ACCESS DENIED. ALL YOUR BASE ARE BELONG TO US", wrap2.Error()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters