-
Notifications
You must be signed in to change notification settings - Fork 4.6k
xdsclient: create LRSClient at time of initialisation #8483
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
Changes from 5 commits
e035e08
339ac57
8f53b14
56d3a58
2f6d3b4
90bc53c
40674fc
51309ec
c0ebd99
b8905c8
72427cb
c8c3ee4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import ( | |
| "encoding/json" | ||
| "fmt" | ||
| "net" | ||
| "sync" | ||
| "testing" | ||
|
|
||
| "github.com/google/go-cmp/cmp" | ||
|
|
@@ -437,3 +438,36 @@ func (s) TestReportLoad_StreamCreation(t *testing.T) { | |
| defer sCancel3() | ||
| cancel3(sCtx3) | ||
| } | ||
|
|
||
| // TestConcurrentReportLoad verifies that the client can safely handle concurrent | ||
| // requests to initiate load reporting streams. It launches multiple goroutines | ||
| // that all call client.ReportLoad simultaneously. | ||
| func (s) TestConcurrentReportLoad(t *testing.T) { | ||
arjan-bal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) | ||
| defer cancel() | ||
|
|
||
| // Create a management server that serves LRS. | ||
arjan-bal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| mgmtServer := e2e.StartManagementServer(t, e2e.ManagementServerOptions{SupportLoadReportingService: true}) | ||
|
|
||
| // Create an xDS client with bootstrap pointing to the above server. | ||
| nodeID := uuid.New().String() | ||
| bc := e2e.DefaultBootstrapContents(t, nodeID, mgmtServer.Address) | ||
| client := createXDSClient(t, bc) | ||
|
|
||
| serverConfig, err := bootstrap.ServerConfigForTesting(bootstrap.ServerConfigTestingOptions{URI: mgmtServer.Address}) | ||
| if err != nil { | ||
| t.Fatalf("Failed to create server config for testing: %v", err) | ||
| } | ||
| // Call ReportLoad() concurrently from multiple go routines. | ||
| var wg sync.WaitGroup | ||
| const numGoroutines = 10 | ||
| wg.Add(numGoroutines) | ||
| for i := 0; i < numGoroutines; i++ { | ||
arjan-bal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| go func() { | ||
arjan-bal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| defer wg.Done() | ||
| _, cancelStore := client.ReportLoad(serverConfig) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to have a loop here as well?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if I understand, loop for what?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A loop inside the goroutine to start reporting load and subsequently canceling it. What I'm asking for is: for i := 0; i < numGoroutines; i++ {
go func() {
defer wg.Done()
for j := 0; j < 100; j++ {
_, cancelStore := client.ReportLoad(serverConfig)
cancelStore(ctx)
}
}()
}
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean several ReportLoad() calls from one goroutine? Is this is better repro the real life case or to increase the chances of catching the race? |
||
| defer cancelStore(ctx) | ||
| }() | ||
| } | ||
| wg.Wait() | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
Now that we have moved it out of report load, we might have think a bit more here. Should error in lrs client creation be fatal? because not everyone is going to use internal xdsclient for load reporting.
Uh oh!
There was an error while loading. Please reload this page.
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.
In my opinion, we should keep the same behaviour as before the xDS client migration changes. If there are certain users who need to ignore LRS client creation failures, we can create a new issue to discuss if the bahviour changes makes sense.
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.
I think it makes sense to retain the behavior of making LRS client creation failures be fatal. But we might want to change one minor thing in
lrsclient.New. Currently it fails if node ID is empty in the configuration. We recently removed that check for the xDS client creation. I'm guessing other languages might not treat this as fatal for LRS creation.@eshitachandwani : Could you please check what the other languages do and if required remove the check for empty node ID in
lrsclient.New. Thanks.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 I understand correctly , Java is checking for not null here
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.
That check is for the whole
nodeproto or struct. Not just the node ID field.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.
Sorry , that was a mistake , I think this is where they check for node id not null in Java
https://github.com/grpc/grpc-java/blob/f50726d32e216746642513add28e086094ce5506/xds/src/main/java/io/grpc/xds/client/EnvoyProtoData.java#L79
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.
That is a private constructor. It's being called from the builder below which sets the id to an empty string by default. In Java empty and
nullstrings are different.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.
Ahh! Okay! Got it!