Skip to content

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

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

nwnt
Copy link
Member

@nwnt nwnt commented Jun 15, 2025

Fix #19893

Copy link

codecov bot commented Jun 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.20%. Comparing base (cc29bc0) to head (ae8a57f).
Report is 32 commits behind head on main.

Additional details and impacted files

see 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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d37ff81...ae8a57f. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nwnt nwnt force-pushed the nwnt/refactor-recording-client-mgmt branch from 06331aa to a9821d2 Compare June 16, 2025 02:19
@nwnt nwnt force-pushed the nwnt/refactor-recording-client-mgmt branch from a9821d2 to df159e9 Compare June 16, 2025 14:39
@nwnt nwnt force-pushed the nwnt/refactor-recording-client-mgmt branch from df159e9 to f0731f2 Compare June 16, 2025 14:43
@nwnt nwnt force-pushed the nwnt/refactor-recording-client-mgmt branch from f0731f2 to 76c980e Compare June 20, 2025 03:25
@nwnt
Copy link
Member Author

nwnt commented Jun 20, 2025

@serathius sorry was away for a few days. How does the latest commit look?

@nwnt nwnt force-pushed the nwnt/refactor-recording-client-mgmt branch from 76c980e to e2dba97 Compare June 21, 2025 02:37
Comment on lines 376 to 384
type ClientSet struct {
mux sync.Mutex
idProvider identity.Provider
baseTime time.Time

closed bool
clients []*RecordingClient
reports []report.ClientReport
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 {
Copy link
Member

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.

}

func (cs *ClientSet) Reports() []report.ClientReport {
if !cs.closed {
Copy link
Member

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.

Copy link
Member Author

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() {
Copy link
Member

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 {
Copy link
Member

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.

@nwnt nwnt force-pushed the nwnt/refactor-recording-client-mgmt branch 3 times, most recently from 4b73c1f to 0d81538 Compare June 22, 2025 03:30
@nwnt
Copy link
Member Author

nwnt commented Jun 22, 2025

/retest

@nwnt nwnt force-pushed the nwnt/refactor-recording-client-mgmt branch from 0d81538 to 1be5691 Compare June 22, 2025 03:41
Signed-off-by: Nont <nont@duck.com>
@nwnt nwnt force-pushed the nwnt/refactor-recording-client-mgmt branch from 1be5691 to ae8a57f Compare June 22, 2025 15:20
@nwnt
Copy link
Member Author

nwnt commented Jun 22, 2025

This should fix all of them. Can I bother you to review again @serathius?

@k8s-ci-robot
Copy link

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@serathius
Copy link
Member

/retest

@serathius serathius merged commit 32eeee6 into etcd-io:main Jun 23, 2025
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

[Antithesis] Refactor recording client management
3 participants