-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sqlproxyccl: Add codeUnavailable to the list of error codes #77442
sqlproxyccl: Add codeUnavailable to the list of error codes #77442
Conversation
pkg/ccl/sqlproxyccl/connector.go
Outdated
@@ -319,7 +319,11 @@ func (c *connector) lookupAddr(ctx context.Context) (string, error) { | |||
if c.Directory != nil { | |||
addr, err := c.Directory.EnsureTenantAddr(ctx, c.TenantID, c.ClusterName) | |||
if err != nil { | |||
if status.Code(err) != codes.NotFound { | |||
if status.Code(err) == codes.FailedPrecondition { | |||
if st, ok := status.FromError(err); ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are unable to retrieve the status, we should still return a codeUnavailable error and break from the loop. I'm worried this case could trigger an infinite loop.
pkg/ccl/sqlproxyccl/connector.go
Outdated
@@ -319,7 +319,11 @@ func (c *connector) lookupAddr(ctx context.Context) (string, error) { | |||
if c.Directory != nil { | |||
addr, err := c.Directory.EnsureTenantAddr(ctx, c.TenantID, c.ClusterName) | |||
if err != nil { | |||
if status.Code(err) != codes.NotFound { | |||
if status.Code(err) == codes.FailedPrecondition { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it would be nice to flatten this logic. I'm thinking something like
switch {
case err == nil:
return add, nil
case status.Code(err) == codes.FailedPrecondition:
message = "unavailable"
if st, ok := status.FromError(err); ok {
message = st.Message()
}
return "", newErrorf(codeUnavailable, st.Message()
case status.Code(err) != codes.NotFound:
return "", markAsRetriableConnectionError(err)
default:
/* fallback to old resolution rule */
}
14b8cf8
to
514e8da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know how I go about generating errorcode_string.go
it says it is generated by "stringer". Since i've added codeUnavailable
i need to re-generate this file.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @jeffswenson)
pkg/ccl/sqlproxyccl/connector.go, line 323 at r1 (raw file):
Previously, JeffSwenson (Jeff Swenson) wrote…
If we are unable to retrieve the status, we should still return a codeUnavailable error and break from the loop. I'm worried this case could trigger an infinite loop.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
You can use dev to regenerate errcode_string.go
./dev generate
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @jeffswenson)
8e83ae5
to
897df56
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without the release note. SQL proxy is internal only for now, so no release notes are needed.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @jeffswenson)
897df56
to
56994b2
Compare
Ack, amended the commit msg to remove release note. TFTR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would sill want Release note: None
😄 Same to PR message I think.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @jeffswenson)
Release justification: fixes for high-priority bug in existing functionality Previously, if a tenant cluster had maxPods set to 0 the error returned by directory.EnsureTenantAddr was not treated as a non-retryable error. The tenant directory implementation used in CockroachCloud now identifies this situation and returns a status error with codes.FailedPrecondition and a descriptive message. This patch adds a check for the FailedPrecondition error in connector.lookupAddr. Release note: None
56994b2
to
5bd1ae2
Compare
haha, thx for the quick response ;) |
bors r+ |
Build succeeded: |
Encountered an error creating backports. Some common things that can go wrong:
You might need to create your backport manually using the backport tool. error creating backport branch refs/heads/blathers/backport-release-21.2-77442: POST https://api.github.com/repos/cockroachlabs/cockroach/git/refs: 403 Resource not accessible by integration [] Backport to branch 21.2.x failed. See errors above. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
blathers backport 21.2 |
Encountered an error creating backports. Some common things that can go wrong:
You might need to create your backport manually using the backport tool. error creating backport branch refs/heads/blathers/backport-release-21.2-77442: POST https://api.github.com/repos/cockroachlabs/cockroach/git/refs: 403 Resource not accessible by integration [] Backport to branch 21.2 failed. See errors above. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
Release justification: fixes for high-priority bug in existing functionality
Previously, if a tenant cluster had maxPods set to 0 the error returned by
directory.EnsureTenantAddr was not treated as a non-retryable error.
The tenant directory implementation used in CockroachCloud now identifies
this situation and returns a status error with codes.FailedPrecondition and
a descriptive message.
This patch adds a check for the FailedPrecondition error in
connector.lookupAddr.
Release note: None