Fix data races in built-in BundlePublisher plugins on dynamic reconfiguration#7082
Merged
sorindumitru merged 1 commit intoJun 19, 2026
Merged
Conversation
c259bb1 to
368812d
Compare
…guration Signed-off-by: Agustín Martínez Fayó <amartinezfayo@gmail.com>
368812d to
3b7a874
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes data races in built-in BundlePublisher plugins during dynamic reconfiguration by ensuring configuration/client are updated and read atomically, and by using the correct mutex for cached bundle access.
Changes:
- Atomically store and retrieve
(config, client)underconfigMtxinaws_s3,gcp_cloudstorage, andaws_rolesanywhere_trustanchor. - Fix
getBundleto read underbundleMtx(matchingsetBundle) in the affected plugins. - Add concurrent
ConfigurevsPublishBundleregression tests intended to fail under-racewithout the fix.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/server/plugin/bundlepublisher/gcpcloudstorage/gcpcloudstorage.go | Atomically pairs config+client under configMtx; fixes bundle locking; guards client read in Close. |
| pkg/server/plugin/bundlepublisher/gcpcloudstorage/gcpcloudstorage_test.go | Adds concurrent Configure/Publish regression test. |
| pkg/server/plugin/bundlepublisher/awss3/awss3.go | Atomically pairs config+client under configMtx; fixes bundle locking. |
| pkg/server/plugin/bundlepublisher/awss3/awss3_test.go | Adds concurrent Configure/Publish regression test. |
| pkg/server/plugin/bundlepublisher/awsrolesanywhere/awsrolesanywhere.go | Atomically pairs config+client under configMtx; fixes bundle locking; introduces setConfig. |
| pkg/server/plugin/bundlepublisher/awsrolesanywhere/awsrolesanywhere_test.go | Adds concurrent Configure/Publish regression test. |
sorindumitru
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The built-in BundlePublisher plugins assign their storage client in
Configureand read it inPublishBundlewithout any synchronization. Several of them also read the cached bundle ingetBundlewhile holdingconfigMtx, even thoughsetBundlewrites it under a separatebundleMtx, so the two never exclude each other.These were harmless while
Configureonly ran once during plugin initialization, but dynamic reconfiguration now callsConfigureagain at runtime, so it can run concurrently withPublishBundle. That produces data races on both the client field and the cached bundle, and a concurrent reconfiguration could also leavePublishBundleusing a client that no longer matches the active configuration.This PR fixes the
aws_s3,gcp_cloudstorage, andaws_rolesanywhere_trustanchorplugins by storing the configuration and its client together and updating them atomically underconfigMtx, withgetConfigreturning both so thatPublishBundlealways observes a matching pair. It also correctsgetBundlein those plugins to read underbundleMtx, matchingsetBundle. Thek8s_configmapplugin already stores its clients inside the configuration and reads the bundle under the correct lock, so it needs no change. Theazure_blobplugin under review in #7030 has the same structure and adopts this pattern there.Changes:
configMtxin theaws_s3,gcp_cloudstorage, andaws_rolesanywhere_trustanchorplugins, returned together fromgetConfig.bundleMtxingetBundleto matchsetBundlein those plugins.gcp_cloudstorageClosemethod.TestConcurrentConfigureAndPublishregression test to each fixed plugin that runsConfigureandPublishBundleconcurrently and fails under-racewithout the fix.