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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nwnt
Copy link
Member

@nwnt nwnt commented Jun 15, 2025

Fix #19893

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nwnt
Once this PR has been reviewed and has the lgtm label, please assign jmhbnz for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

Copy link

codecov bot commented Jun 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.68%. Comparing base (cc29bc0) to head (76c980e).
Report is 24 commits behind head on main.

Additional details and impacted files

see 52 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #20175      +/-   ##
==========================================
+ Coverage   69.27%   69.68%   +0.40%     
==========================================
  Files         413      398      -15     
  Lines       34364    33941     -423     
==========================================
- Hits        23805    23651     -154     
+ Misses       9160     8888     -272     
- Partials     1399     1402       +3     

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...76c980e. 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
if err != nil {
lg.Fatal("Failed empty database at start check", zap.Error(err))
}
trafficReports := []report.ClientReport{r}
// TODO use clientSet in all operations requiring c client creation
Copy link
Member

Choose a reason for hiding this comment

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

Can you implement this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had to introduce another struct called MultClientSet on top of ClientSet. The reason for that is because there's a cross-channel dependency between the traffic simulation and watch operation where the latter needs the max revision from the traffic simulation. Hope that's ok.

Signed-off-by: Nont <nont@duck.com>
@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?

@k8s-ci-robot
Copy link

@nwnt: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-etcd-coverage-report 76c980e link true /test pull-etcd-coverage-report

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@@ -93,12 +92,11 @@ func main() {

func runTraffic(ctx context.Context, lg *zap.Logger, tf traffic.Traffic, hosts []string, baseTime time.Time, duration time.Duration) ([]report.ClientReport, error) {
ids := identity.NewIDProvider()
r, err := traffic.CheckEmptyDatabaseAtStart(ctx, lg, hosts, ids, baseTime)
multiClientSet := client.NewMultiSet(ids, baseTime)
Copy link
Member

@serathius serathius Jun 20, 2025

Choose a reason for hiding this comment

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

Why multi set? I don't follow the reason we need a multiple sets, I should suffice.

Copy link
Member Author

@nwnt nwnt Jun 20, 2025

Choose a reason for hiding this comment

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

During traffic simulation, the reports have to be collected early to find the max revision, which will then be fed to the channel for the watch operation. If we have only one set, collecting the report would also close the set, correct?

		trafficReports = slices.Concat(trafficReports, simulateTraffic(ctx, tf, hosts, ids, baseTime, duration))
		maxRevision := report.OperationsMaxRevision(trafficReports)
		maxRevisionChan <- maxRevision
		lg.Info("Finished simulating Traffic", zap.Int64("max-revision", maxRevision))

Copy link
Member

Choose a reason for hiding this comment

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

Ok, that makes sense. The problem is that we want to first finish traffic generation and get the report, but still wait for watch requests. Using a single ClientSet would result in traffic generation closing the set and impacting watch.

Copy link
Member

@serathius serathius Jun 20, 2025

Choose a reason for hiding this comment

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

While MultiSet tackles the generic issue, I think we should avoid over-designing here.
Could you just have one Set for traffic + CheckEmptyDatabaseAtStart and have a separate set for watch?

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