Skip to content
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

[bugfix] non grpc style error parse result returns Unknown status, it should be re-parse to find inside status #1981

Merged
merged 1 commit into from
Mar 17, 2023

Conversation

kpango
Copy link
Collaborator

@kpango kpango commented Mar 16, 2023

Description:

In the case that gRPC Status Parser returns "Unknown", we should look at the internal Error to determine the status.

During the process of modifying gRPC Status Parser, I needed an Error Join that can save gRPC Error without making it a String, so I added a Join.

Changed part of errors.Wrap to Join for LB GW only.

Related Issue:

Versions:

  • Go Version: 1.20.2
  • Docker Version: 20.10.8
  • Kubernetes Version: 1.22.0
  • NGT Version: 2.0.9

Checklist:

Special notes for your reviewer:

@vdaas-ci
Copy link
Collaborator

[CHATOPS:HELP] ChatOps commands.

  • 🙆‍♀️ /approve - approve
  • 💌 /changelog - replace the PR body by changelog details
  • 🍱 /format - format codes and add licenses
  • /gen-test - generate test codes
  • 🏷️ /label - add labels
  • /rebase - rebase main
  • 🔚 2️⃣ 🔚 /label actions/e2e-deploy - run E2E deploy & integration test

@github-actions github-actions bot added area/internal size/S type/bug Something isn't working labels Mar 16, 2023
hlts2
hlts2 previously approved these changes Mar 16, 2023
Copy link
Collaborator

@hlts2 hlts2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions
Copy link
Contributor

@vdaas-ci
Copy link
Collaborator

Profile Report

typevald-agent-ngtvald-lb-gatewayvald-discoverervald-manager-index
cpu
heap
other images

@kpango kpango force-pushed the bugfix/internal-grpc/non-grpc-style-error-parsing branch from 5536ae9 to 5c027d8 Compare March 16, 2023 10:15
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 16, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: f2187b0
Status: ✅  Deploy successful!
Preview URL: https://30e89b7b.vald.pages.dev
Branch Preview URL: https://bugfix-internal-grpc-non-grp.vald.pages.dev

View logs

@github-actions github-actions bot added size/L and removed size/S labels Mar 16, 2023
@codecov
Copy link

codecov bot commented Mar 16, 2023

Codecov Report

Patch coverage: 20.73% and project coverage change: -0.08 ⚠️

Comparison is base (d6e419b) 29.68% compared to head (8f5c0c5) 29.60%.

❗ Current head 8f5c0c5 differs from pull request most recent head f2187b0. Consider uploading reports for the commit f2187b0 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1981      +/-   ##
==========================================
- Coverage   29.68%   29.60%   -0.08%     
==========================================
  Files         364      365       +1     
  Lines       34156    34236      +80     
==========================================
- Hits        10139    10137       -2     
- Misses      23602    23680      +78     
- Partials      415      419       +4     
Impacted Files Coverage Δ
pkg/gateway/lb/handler/grpc/handler.go 0.00% <0.00%> (ø)
internal/net/grpc/status/status.go 22.05% <7.46%> (-6.43%) ⬇️
internal/errors/errors.go 83.47% <59.18%> (-16.53%) ⬇️

... and 4 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -114,6 +114,9 @@ var (
return Errorf(format, args...)
}

// Join represents a function to generate multiple error when the input errors is not nil.
Join = errors.Join
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

24% of developers fix this issue

typecheck: Join not declared by package errors


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

// Is represents a function to check whether err and the target is the same or not.
func Is(err, target error) bool {
if target == nil || err == nil {
return err == target
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)

}
isComparable := reflect.TypeOf(target).Comparable()
for {
if isComparable && (err == target ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)

}); ok && x.Is(target) {
return true
}
switch x := err.(type) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
type switch on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)

@kpango kpango force-pushed the bugfix/internal-grpc/non-grpc-style-error-parsing branch 2 times, most recently from 6655f6f to c1a0645 Compare March 16, 2023 11:01
if err != nil {
return nil
}
switch x := err.(type) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
type switch on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)

internal/net/grpc/status/status.go Show resolved Hide resolved
return nil
case 1:
return errs[0]
case 2:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
mnd: Magic number: 2, in detected (gomnd)

// Unwrap represents errors.Unwrap.
func Unwrap(err error) error {
if err != nil {
return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
error is not nil (line 195) but it returns nil (nilerr)

@kpango kpango force-pushed the bugfix/internal-grpc/non-grpc-style-error-parsing branch 3 times, most recently from a79c577 to 8f5c0c5 Compare March 16, 2023 11:52
@github-actions
Copy link
Contributor

@vdaas-ci
Copy link
Collaborator

Profile Report

typevald-agent-ngtvald-lb-gatewayvald-discoverervald-manager-index
cpu
heap
other images

switch l := len(errs); l {
case 0:
return nil
case 1, 2:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
mnd: Magic number: 2, in detected (gomnd)

… should be re-parse to find inside status

Signed-off-by: kpango <kpango@vdaas.org>
@github-actions
Copy link
Contributor

@vdaas-ci
Copy link
Collaborator

Profile Report

typevald-agent-ngtvald-lb-gatewayvald-discoverervald-manager-index
cpu
heap
other images

case interface{ Unwrap() error }:
err = x.Unwrap()
if err == nil {
return isComparable && err == target ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)

@vankichi
Copy link
Contributor

vankichi commented Mar 16, 2023

Could you please show me the overview your changes ( especially, the approach for resolve ) at the PR description?

@kpango kpango requested a review from hlts2 March 17, 2023 01:41
Copy link
Collaborator

@hlts2 hlts2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, LGTM!

@kpango kpango merged commit 49ddfea into main Mar 17, 2023
@kpango kpango deleted the bugfix/internal-grpc/non-grpc-style-error-parsing branch March 17, 2023 02:00
@vankichi vankichi mentioned this pull request Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants