Skip to content

[release-4.22] OCPBUGS-87022: fix concurrent map race in project authorization cache - #653

Merged
openshift-merge-bot[bot] merged 3 commits into
openshift:release-4.22from
openshift-cherrypick-robot:cherry-pick-642-to-release-4.22
Jun 10, 2026
Merged

[release-4.22] OCPBUGS-87022: fix concurrent map race in project authorization cache#653
openshift-merge-bot[bot] merged 3 commits into
openshift:release-4.22from
openshift-cherrypick-robot:cherry-pick-642-to-release-4.22

Conversation

@openshift-cherrypick-robot

Copy link
Copy Markdown

This is an automated cherry-pick of #642

/assign sanchezl

/cherrypick release-4.21 release-4.20 release-4.19 release-4.18

sanchezl and others added 3 commits June 4, 2026 00:32
addSubjectsToNamespace and deleteNamespaceFromSubjects mutate
subjectRecord.namespaces (a sets.String / map) in place while
List() iterates the same map from HTTP request goroutines. This
causes a fatal "concurrent map iteration and map write" panic
that crashes openshift-apiserver pods intermittently.

Use a dual-path strategy: during full cache invalidation, where
new stores are private to the writer goroutine, mutate in place
for zero-copy performance. During incremental updates, where
stores are shared with concurrent readers, use copy-on-write to
create new subjectRecord objects with copied namespaces sets.

Group all three cache stores behind an atomic.Pointer so they
swap as a single unit during full invalidation, ensuring readers
see a consistent view.

This avoids the lock contention that caused the previous mutex
fix (PR openshift#267) to be reverted (PR openshift#326), while also avoiding the
O(n²) allocation overhead of unconditional copy-on-write.
Benchmark synchronize() at varying namespace × user scales
(10/10 through 1000/1000) with the cache always expired,
forcing full invalidation on every iteration.
Benchmark the incremental COW path with varying levels of subject
duplication (D=1 for no duplicates, D=10 for 10x duplicates per
user). This exercises the scenario where broken upstream dedup in
AllowedSubjects causes redundant COW copies in
addSubjectsToNamespace during incremental cache updates.
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 00c5c6ad-1d12-402b-a237-afe5069442c1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci
openshift-ci Bot requested review from deads2k and derekwaynecarr June 4, 2026 00:33
@openshift-ci-robot

Copy link
Copy Markdown

@openshift-cherrypick-robot: Jira Issue OCPBUGS-84534 has been cloned as Jira Issue OCPBUGS-87022. Will retitle bug to link to clone.
/retitle [release-4.22] OCPBUGS-87022: fix concurrent map race in project authorization cache

Details

In response to this:

This is an automated cherry-pick of #642

/assign sanchezl

/cherrypick release-4.21 release-4.20 release-4.19 release-4.18

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot changed the title [release-4.22] OCPBUGS-84534: fix concurrent map race in project authorization cache [release-4.22] OCPBUGS-87022: fix concurrent map race in project authorization cache Jun 4, 2026
@openshift-ci-robot openshift-ci-robot added jira/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Jun 4, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@openshift-cherrypick-robot: This pull request references Jira Issue OCPBUGS-87022, which is valid. The bug has been moved to the POST state.

7 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)
  • release note text is set and does not match the template
  • dependent bug Jira Issue OCPBUGS-84534 is in the state MODIFIED, which is one of the valid states (MODIFIED, ON_QA, VERIFIED)
  • dependent Jira Issue OCPBUGS-84534 targets the "5.0.0" version, which is one of the valid target versions: 5.0.0
  • bug has dependents

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

This is an automated cherry-pick of #642

/assign sanchezl

/cherrypick release-4.21 release-4.20 release-4.19 release-4.18

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci

openshift-ci Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

@openshift-cherrypick-robot: all tests passed!

Full PR test history. Your PR dashboard.

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

@sanchezl

sanchezl commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

/verified by "TestAuthorizationCacheRace"

@sanchezl

sanchezl commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

/lgtm

@sanchezl

sanchezl commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

/approve

@openshift-ci-robot

Copy link
Copy Markdown

@sanchezl: This PR has been marked as verified by "TestAuthorizationCacheRace".

Details

In response to this:

/verified by "TestAuthorizationCacheRace"

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jun 4, 2026
@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jun 4, 2026
@openshift-ci

openshift-ci Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sanchezl

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

The pull request process is described 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

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 4, 2026
@everettraven

Copy link
Copy Markdown

/label backport-risk-assessed

@openshift-ci openshift-ci Bot added the backport-risk-assessed Indicates a PR to a release branch has been evaluated and considered safe to accept. label Jun 10, 2026
@openshift-merge-bot
openshift-merge-bot Bot merged commit 7fa546d into openshift:release-4.22 Jun 10, 2026
11 checks passed
@openshift-ci-robot

Copy link
Copy Markdown

@openshift-cherrypick-robot: Jira Issue Verification Checks: Jira Issue OCPBUGS-87022
✔️ This pull request was pre-merge verified.
✔️ All associated pull requests have merged.
✔️ All associated, merged pull requests were pre-merge verified.

Jira Issue OCPBUGS-87022 has been moved to the MODIFIED state and will move to the VERIFIED state when the change is available in an accepted nightly payload. 🕓

Details

In response to this:

This is an automated cherry-pick of #642

/assign sanchezl

/cherrypick release-4.21 release-4.20 release-4.19 release-4.18

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-cherrypick-robot

Copy link
Copy Markdown
Author

@openshift-cherrypick-robot: new pull request created: #660

Details

In response to this:

This is an automated cherry-pick of #642

/assign sanchezl

/cherrypick release-4.21 release-4.20 release-4.19 release-4.18

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.

@openshift-merge-robot

Copy link
Copy Markdown
Contributor

Fix included in release 4.22.0-0.nightly-2026-06-11-035725

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. backport-risk-assessed Indicates a PR to a release branch has been evaluated and considered safe to accept. jira/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants