-
Notifications
You must be signed in to change notification settings - Fork 4.5k
xds/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
base: master
Are you sure you want to change the base?
Changes from all commits
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) { | ||
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) | ||
defer cancel() | ||
|
||
// Create a management server that serves LRS. | ||
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++ { | ||
go func() { | ||
arjan-bal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
defer wg.Done() | ||
_, cancelStore := client.ReportLoad(serverConfig) | ||
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? 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? 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)
}
}()
} |
||
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
node
proto or struct. Not just the node ID field.