-
Notifications
You must be signed in to change notification settings - Fork 4.5k
xdsclient: fix unexpectedly large LoadReportInterval in initial load report request #8348
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
xdsclient: fix unexpectedly large LoadReportInterval in initial load report request #8348
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8348 +/- ##
==========================================
+ Coverage 82.16% 82.29% +0.13%
==========================================
Files 419 419
Lines 42034 42052 +18
==========================================
+ Hits 34537 34607 +70
+ Misses 6023 5987 -36
+ Partials 1474 1458 -16
🚀 New features to boost your workflow:
|
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.
Can you please add a test for this to prevent regressions?
we can only check if LoadReportInterval is positive but not excessively large. We can't compare exactly since calculation involves time.Now(). I have added test verifications in the existing e2e tests with some tolerance to ensure reportInterval of the first report and subsequent reports is a small, positive duration but greater than configured server LoadReportingInterval. |
Without looking at the details here... Can we hook |
012a5bc
to
6a3ebaf
Compare
Added the hook. Thought that limits us to only verify with predictable report interval in the unit test of the load store and not in the e2e tests i.e. verifying the report interval that got reported to LRS server but that's probably fine. |
6a3ebaf
to
65fd12d
Compare
65fd12d
to
b7c391d
Compare
If needed, you can hop through an internal package to be able to set from e2e tests. |
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.
LGTM, just a couple very minor things.
wantInterval := 5 * time.Second | ||
if stats1.reportInterval != wantInterval { |
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.
Optional:
I think the best way I've been recommended of writing this kind of test comparison is:
if got, want := stats1.reportInterval, 5 * time.Second; got != want {
t.Fatalf("blah blah = %v; want %v", got, want)
}
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
@@ -25,6 +25,9 @@ import ( | |||
"time" | |||
) | |||
|
|||
// clockNow is used to get the current time. It can be overridden in tests. | |||
var clockNow = time.Now |
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 for the nit, but would you mind renaming this to timeNow
to match packagename.SymbolName
but without the dot? That's the convention we generally use.
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
xds/internal/xdsclient/load/store.go
Outdated
@@ -25,6 +25,9 @@ import ( | |||
|
|||
const negativeOneUInt64 = ^uint64(0) | |||
|
|||
// clockNow is used to get the current time. It can be overridden in tests. | |||
var clockNow = time.Now |
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.
As above.
currentTime = currentTime.Add(5 * time.Second) | ||
stats1 := store.Stats(nil) | ||
|
||
if stats1 == nil { |
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.
It seems like you want even more from this check, since it's a slice that you dereference element 0 of immediately below.
if len(stats1) == 0 { // or != 1 ?
t.Fatalf("store.Stats(nil) = %v; want len() >= 1", stats1) // or == 1?
}
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
I did it for the generic lrs client tests but left it for the internal one since that will be external soon. |
ef2a9f6
to
6bdf940
Compare
Internal bug: b/416260484
The
lastReportedAt
field is uninitialized during reporter construction, defaulting to theZero
timestamp. This results in an excessively largeLoadReportInterval
(calculated as Now() - lastReportedAt) for the initial load report. InitializinglastReportedAt
to Now() during construction will ensure theLoadReportInterval
is accurately approximated for the first report.RELEASE NOTES: