-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
orca: cleanup old code, and get grpc package to use new code #5627
Conversation
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.
Was there an end-to-end style test for this that creates a gRPC client with a custom LB policy that retrieves ORCA data from the server?
orca/orca.go
Outdated
// an import cycle. Hence this roundabout method is used. | ||
type loadParser struct{} | ||
|
||
func (*loadParser) Parse(md metadata.MD) interface{} { |
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: best practice AIUI is to define this on the value type and avoid pointers.
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.
go/go-style/decisions#receiver-type
I have read this a few times in the past, but only few things stuck in my head like:
- If the method needs to mutate the receiver, the receiver must be a pointer.
- If the receiver is a struct containing fields that cannot safely be copied, use a pointer receiver.
- When in doubt, use a pointer receiver.
But there seems to be case for this one:
- If the receiver is a "small" array or struct that is naturally a value type with no mutable fields and no pointers, a value receiver is usually the right choice.
orca/orca.go
Outdated
type loadParser struct{} | ||
|
||
func (*loadParser) Parse(md metadata.MD) interface{} { | ||
lr, _ := ToLoadReport(md) |
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.
Handle the error?
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.
Added an error log. As far as the caller of this function is concerned (transport), the error does not change anything. So, I did not bother changing the signature of the method to return an error for the caller to deal with it.
The e2e style test that we have for this does create a gRPC client, but simply reads the trailers off the stream instead of installing a custom LB policy. I thought it would be better/easier to add that test once we have client-side support as well. |
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.
One small cleanup item, otherwise LGTM
@@ -158,7 +159,7 @@ func (d *picker) Pick(info balancer.PickInfo) (balancer.PickResult, error) { | |||
} | |||
d.loadStore.CallFinished(lIDStr, info.Err) | |||
|
|||
load, ok := info.ServerLoad.(*orcapb.OrcaLoadReport) | |||
load, ok := info.ServerLoad.(*v3orcapb.OrcaLoadReport) |
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.
The comment on info.ServerLoad
says "The only supported type now is *orca_v1.LoadReport.
" Should this be updated?
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.
Done. Thanks.
Fixes #5542
This PR cleans up the old implementation in https://github.com/grpc/grpc-go/tree/master/xds/internal/balancer/orca and gets the
grpc
package to use the new one (by registering theParser
interface from the new code).RELEASE NOTES: n/a