xds: Add support for Custom LB Policies#6224
Conversation
7decbac to
928d0ca
Compare
4f07f87 to
119986e
Compare
easwars
left a comment
There was a problem hiding this comment.
Small pass. Figured that I'm going to be able to get to everything in one pass. So, this is going to involve a bit of back and forth. Sorry about that.
|
Got to all the comments except trailing comma. I'll get to that after doing a pass on Doug's PR. Should be ready for another pass though :D. |
| "fmt" | ||
| "testing" | ||
|
|
||
| v3 "github.com/cncf/xds/go/xds/type/v3" |
There was a problem hiding this comment.
This needs to match the string used in other imports (and specified in the copybara config).
| // be passed 5 ports, and the first two ports will be put in the first locality, | ||
| // and the last three will be put in the second locality. It also configures the | ||
| // proto message passed in as the Locality + Endpoint picking policy in CDS. | ||
| func clientResourcesNewFieldSpecifiedAndPortsInMultipleLocalities2(params e2e.ResourceParams, ports []uint32, m proto.Message) e2e.UpdateOptions { |
There was a problem hiding this comment.
If we do enhance EndpointOptions to contain LocalityOptions, we wouldn't need this helper function. This can be written as part of the test, so that the reader will clearly be able to see which ports belong to which localities.
There was a problem hiding this comment.
Deleted this helper. Thanks.
There was a problem hiding this comment.
Actually, I think you can delete the endpoint flow/helpers to build the EDS configuration, but this overall flow is much cleaner with a documented function (about the 5 ports passed in, proto.Message that gets plumbed as the Locality + Endpoint picking policy in CDS).
There was a problem hiding this comment.
I still think getting rid of the helper would be cleaner since the reader of the test will know exactly what is happening by reading the body of the test instead of having to navigate to this helper, and read its comment and then figure out what is happening.
There was a problem hiding this comment.
Fine. I don't agree, but switched.
|
|
||
| managementServer, nodeID, _, r, cleanup := e2e.SetupManagementServer(t, e2e.ManagementServerOptions{}) | ||
| defer cleanup() | ||
| backend1 := stubserver.StartTestService(t, nil) |
There was a problem hiding this comment.
I prefer it this way to hold ref to backend to grab backend.Address, and also backend.Port which I pass to helper you commented about above. If you feel strongly about this I'm willing to change it.
There was a problem hiding this comment.
You can still hold the reference to the address and the port in a slice. But if you dont want to do it, then thats fine. But do add a new line after this block and before the test table starts.
There was a problem hiding this comment.
Yeah, forgot to mention would require creating two length 5 slices which I don't like.
| return nil, fmt.Errorf("xds: invalid LBConfig for wrrlocality: %s, error: %v", string(s), err) | ||
| } | ||
| if lbCfg == nil || lbCfg.ChildPolicy == nil { | ||
| return nil, errors.New("xds: invalidw LBConfig for wrrlocality: child policy field must be set") | ||
| return nil, errors.New("xds: invalid LBConfig for wrrlocality: child policy field must be set") |
There was a problem hiding this comment.
Do we want the xds prefix here?
There was a problem hiding this comment.
Changed to same prefix as the errors returned from UpdateClientConnState xds_wrr_locality:
| } | ||
| ai, ok := getAddrInfo(addr) | ||
| if !ok { | ||
| return fmt.Errorf("xds_wrr_locality: addr: %v is misisng locality weight information", addr) |
There was a problem hiding this comment.
Could this be instead?
return fmt.Errorf("xds_wrr_locality: misisng locality weight information in address %q", addr)
There was a problem hiding this comment.
You kept my missing typo in your suggestion :). Switched, without the typo :).
| wtCfgJSON, err := json.Marshal(wtCfg) | ||
| if err != nil { | ||
| // Shouldn't happen. | ||
| return fmt.Errorf("xds_wrr_locality: error marshalling prepared wtCfg: %v", wtCfg) |
There was a problem hiding this comment.
Please make this error message more readable:
return fmt.Errorf("xds_wrr_locality: error marshalling prepared config: %v", wtCfg)
There was a problem hiding this comment.
And I remember having a big discussion between marshalling vs marshaling with Doug :). Maybe you should rekindle it.
There was a problem hiding this comment.
Ummmmmmm yeah I thought it was marshaling. What's difference? Switched to what you had.
| } | ||
| var sc serviceconfig.LoadBalancingConfig | ||
| if sc, err = b.childParser.ParseConfig(wtCfgJSON); err != nil { | ||
| return fmt.Errorf("xds_wrr_locality: config generated %v by wrr_locality_experimental is invalid: %v", wtCfgJSON, err) |
There was a problem hiding this comment.
there is wrr_locality twice in this error string
There was a problem hiding this comment.
Deleted "by wrr_locality_experimental."
easwars
left a comment
There was a problem hiding this comment.
Some minor comments remaining. LGTM.
| "google.golang.org/grpc/xds/internal" | ||
| ) | ||
|
|
||
| var ( |
| // be passed 5 ports, and the first two ports will be put in the first locality, | ||
| // and the last three will be put in the second locality. It also configures the | ||
| // proto message passed in as the Locality + Endpoint picking policy in CDS. | ||
| func clientResourcesNewFieldSpecifiedAndPortsInMultipleLocalities2(params e2e.ResourceParams, ports []uint32, m proto.Message) e2e.UpdateOptions { |
There was a problem hiding this comment.
I still think getting rid of the helper would be cleaner since the reader of the test will know exactly what is happening by reading the body of the test instead of having to navigate to this helper, and read its comment and then figure out what is happening.
This PR adds support for Custom LB Policies, configured through xDS. This implements the full functionality defined in https://github.com/grpc/proposal/blob/master/A52-xds-custom-lb-policies.md.
Summary of changes:
RELEASE NOTES: