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

[Proposal] Standardize errors and Logs with Middlewares #214

Merged
merged 6 commits into from
Jul 19, 2017

Conversation

drgarcia1986
Copy link
Contributor

@drgarcia1986 drgarcia1986 commented Jul 17, 2017

Only applied for Deploy pkg.


This change is Reviewable

Copy link
Contributor

@aguerra aguerra left a comment

Choose a reason for hiding this comment

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

👏

if _, err := k.kc.CoreV1().Services(namespace).Create(srvSpec); err != nil {
return errors.Wrap(err, "create service failed")
}
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.

I guess you can write:

_, err := k.kc.CoreV1().Services(namespace).Create(srvSpec)
return errors.Wrap(err, "create service failed")

Copy link
Contributor Author

@drgarcia1986 drgarcia1986 Jul 17, 2017

Choose a reason for hiding this comment

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

Does errors.Wraps returns nil for non errors (i.e. nil) args ?

Copy link
Contributor

Choose a reason for hiding this comment

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

yep

Copy link
Contributor Author

Choose a reason for hiding this comment

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

awesome

@@ -54,7 +55,7 @@ func (s *Service) Make(stream dpb.Deploy_MakeServer) error {
rs := bytes.NewReader(content.Bytes())
rc, err := s.ops.Deploy(u, appName, rs, description, s.options.RevisionHistoryLimit)
if err != nil {
return err
return teresa_errors.Get(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought you could return err here because the log middleware does the unwrapping, am I right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right!

Copy link
Contributor

@aguerra aguerra left a comment

Choose a reason for hiding this comment

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

🔁

return teresa_errors.Get(err)
}
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.

Maybe Error -> WithError

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, I added the user of the request. Check some examples below and let know if you liked.

time="2017-07-18T14:32:31Z" level=error msg="Log Interceptor got an Error" error="namespaces \"hashpass2\" already exists" request=name:"hashpass2" team:"arquitetura" limits:<default:<quantity:"500m" resource:"cpu" > default:<quantity:"512Mi" resource:"memory" > default_request:<quantity:"200m" resource:"cpu" > default_request:<quantity:"512Mi" resource:"memory" > > auto_scale:<cpu_target_utilization:70 max:2 min:1 > route="/app.App/Create" user="diego.garcia@luizalabs.com"

time="2017-07-18T14:33:17Z" level=error msg="Log Interceptor got an Error" error="rpc error: code = NotFound desc = App not found: get annotation failed: namespaces \"hashpass3\" not found" route="/deploy.Deploy/Make" user="diego.garcia@luizalabs.com"

ps: In the unary interceptor, I'm logging request content.

@drgarcia1986 drgarcia1986 mentioned this pull request Jul 18, 2017
26 tasks
@drgarcia1986 drgarcia1986 merged commit 8e45537 into master Jul 19, 2017
@drgarcia1986 drgarcia1986 deleted the dg-error_handle branch July 19, 2017 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants