-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
Description
Component(s)
cmd/opampsupervisor
What happened?
The Supervisor struct's remoteConfig field is accessed concurrently without synchronization, causing a data race.
What happens:
-
The
remoteConfigfield (*protobufs.AgentRemoteConfig) is read and written from multiple goroutines:- Written in
processRemoteConfigMessage()when receiving config from the OpAMP server - Written in
loadRemoteConfig()during initialization - Read in
composeMergedConfig()calls from multiple places (loadAndWriteInitialMergedConfig(),setupOwnTelemetry(),processRemoteConfigMessage(),processAgentIdentificationMessage()) - Read in
saveAndReportConfigStatus()to get the config hash
- Written in
-
Concurrent access can occur when:
- A new remote config arrives while the supervisor is composing a merged config
- The supervisor is reading
remoteConfigwhile another goroutine updates it - Multiple goroutines access
remoteConfigsimultaneously
-
This leads to:
- Data races detected by the race detector
- Potential nil pointer dereferences if a read happens during a write
- Undefined behavior from reading partially written values
Additional context:
The saveAndReportConfigStatus() method accesses s.remoteConfig.GetConfigHash() without checking if remoteConfig is nil, which can cause a panic if accessed before any remote config is received.
Collector version
Environment information
No response
OpenTelemetry Collector configuration
Log output
Additional context
No response
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.