Skip to content

fix: take write lock in SetApiRouteConfig - #1981

Open
Krirox wants to merge 1 commit into
kmesh-net:mainfrom
Krirox:fix/1975-route-cache-writelock
Open

Krirox wants to merge 1 commit into
kmesh-net:mainfrom
Krirox:fix/1975-route-cache-writelock

Conversation

@Krirox

@Krirox Krirox commented Nov 4, 2026

Copy link
Copy Markdown

What type of PR is this?

/kind bug

What this PR does / why we need it:

SetApiRouteConfig wrote apiRouteConfigCache under RLock. Dump ranges that same map under RLock too. Two read locks do not exclude each other, so an RDS update can insert while a dump ranges the map, and Go fatals with concurrent map iteration and map write.

Take Lock instead, matching SetApiCluster.

Which issue(s) this PR fixes:
Fixes #1975

Special notes for your reviewer:

Added TestSetApiRouteConfigConcurrentWithDump (1000 concurrent Set + Dump pairs). Could not run go test ./pkg/cache/v2 in this tree because the embedded bpf2go .o files are not generated; expecting CI to cover it.

Does this PR introduce a user-facing change?:

Fix a kernel-native config dump race that could crash kmesh-daemon while routes update.

SetApiRouteConfig wrote apiRouteConfigCache under RLock, so a concurrent
Dump could fatal with concurrent map iteration and map write. Take Lock
instead, matching SetApiCluster.

Fixes kmesh-net#1975

Signed-off-by: Krirox <agarwalkrishiv06@gmail.com>
@kmesh-bot

Copy link
Copy Markdown
Collaborator

Keywords which can automatically close issues and at(@) or hashtag(#) mentions are not allowed in commit messages.

The list of commits with invalid commit messages:

  • 6bf040c fix: take write lock in SetApiRouteConfig
Details

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/test-infra repository. I understand the commands that are listed here.

@kmesh-bot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

The full list of commands accepted by this bot can be found here.

Details 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

@codecov

codecov Bot commented Nov 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.94%. Comparing base (c48f7f0) to head (6bf040c).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Coverage Δ
pkg/cache/v2/route.go 63.07% <100.00%> (+10.76%) ⬆️

Continue to review full report in Codecov by Harness.

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kernel-native config dump can crash the daemon while routes update

2 participants