-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Refactor recording client management #20175
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
Refactor recording client management #20175
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted filessee 22 files with indirect coverage changes @@ Coverage Diff @@
## main #20175 +/- ##
==========================================
- Coverage 69.27% 69.20% -0.08%
==========================================
Files 413 413
Lines 34364 34367 +3
==========================================
- Hits 23805 23783 -22
- Misses 9160 9180 +20
- Partials 1399 1404 +5 Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
06331aa
to
a9821d2
Compare
a9821d2
to
df159e9
Compare
df159e9
to
f0731f2
Compare
f0731f2
to
76c980e
Compare
@serathius sorry was away for a few days. How does the latest commit look? |
76c980e
to
e2dba97
Compare
tests/robustness/client/client.go
Outdated
type ClientSet struct { | ||
mux sync.Mutex | ||
idProvider identity.Provider | ||
baseTime time.Time | ||
|
||
closed bool | ||
clients []*RecordingClient | ||
reports []report.ClientReport | ||
} |
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.
type ClientSet struct { | |
mux sync.Mutex | |
idProvider identity.Provider | |
baseTime time.Time | |
closed bool | |
clients []*RecordingClient | |
reports []report.ClientReport | |
} | |
type ClientSet struct { | |
idProvider identity.Provider | |
baseTime time.Time | |
mux sync.Mutex | |
closed bool | |
clients []*RecordingClient | |
reports []report.ClientReport | |
} |
It good to have mutex over the variables it's meant to protect. We don't need to protect idProvider or baseTime as they are never changed.
} | ||
|
||
func (cs *ClientSet) NewClient(endpoints []string) (*RecordingClient, error) { | ||
if cs.closed { |
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.
Checking cs.closed
should be under mutex.
tests/robustness/client/client.go
Outdated
} | ||
|
||
func (cs *ClientSet) Reports() []report.ClientReport { | ||
if !cs.closed { |
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.
Checking closed and and closing should be under mutex.
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.
Instead of this check, I made the method always call Close
. The same check is done there. If we leave the function here and cover it with mutex, it will run into a deadlock from acquiring lock at Reports
and acquiring lock again at Close
.
return cs.reports | ||
} | ||
|
||
func (cs *ClientSet) Close() { |
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.
Should be under mutex
@@ -210,8 +195,8 @@ func runDefragLoop(ctx context.Context, c *client.RecordingClient, period time.D | |||
} | |||
} | |||
|
|||
func connect(endpoints []string, ids identity.Provider, baseTime time.Time) *client.RecordingClient { |
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.
For followup, we should remove this function.
4b73c1f
to
0d81538
Compare
/retest |
0d81538
to
1be5691
Compare
Signed-off-by: Nont <nont@duck.com>
1be5691
to
ae8a57f
Compare
This should fix all of them. Can I bother you to review again @serathius? |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: nwnt, serathius The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
Fix #19893