Repository navigation
fix(objectcache): synchronize container status fields and add cloud metadata annotations - #1003
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change synchronizes container status access, prevents monitoring from replacing terminal statuses with Ready, and adds a function that maps nonempty cloud metadata fields to annotation keys. ChangesTerminal status protection
Cloud metadata annotations
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The terminal-status regression test exercises the monitoring update as intended. No identified issue needs resolution before merge. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change strengthens terminal-state protection without demonstrating a new access path or privilege increase. Remaining uncertainty concerns downstream persistence guarantees and consumers outside the reviewed code. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Performance Benchmark ResultsNode-Agent Resource Usage
Dedup EffectivenessNo data available. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
A concurrent ticker can still overwrite a terminal container status with Ready.
Review effort: Balanced
Findings: 1
What changed in this PR
Adds synchronized status access and a helper for cloud metadata annotations in pkg/objectcache.
Changes:
- Protects container status fields with an RW mutex.
- Adds cloud metadata annotation mapping.
- Adds concurrency and metadata unit tests.
| File | Description |
|---|---|
pkg/objectcache/shared_container_data.go |
Adds synchronization and metadata helper. |
pkg/objectcache/shared_container_data_test.go |
Tests concurrent status access. |
pkg/objectcache/cloud_metadata_test.go |
Tests annotation mapping. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
48f5f95 to
08c0795
Compare
…etadata annotations Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
…tatus (5399581993) - add IsTerminal and SetReadyUnlessTerminal to WatchedContainerStatus/WatchedContainerData - avoid overwriting terminal status with Ready on periodic monitoring ticks - add concurrency and regression tests for terminal status transitions Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
Performance Benchmark ResultsNode-Agent Resource Usage
Dedup EffectivenessNo data available. |
08c0795 to
bd948d0
Compare
Performance Benchmark ResultsNode-Agent Resource Usage
Dedup EffectivenessNo data available. |

Description
This PR addresses two improvements in
pkg/objectcache:Synchronize container status fields:
Fixes a data race on
WatchedContainerData.statusandcompletionStatus. Both are string-typed fields read and written concurrently by multiple goroutines (the monitoring loop on ticks/termination anddeleteContainerfrom the container callback). Without synchronization, concurrent writes can produce torn reads, yielding corrupted statuses when stamping container profiles. A dedicatedsync.RWMutex(statusMu) protects these fields acrossGetStatus(),SetStatus(),GetCompletionStatus(), andSetCompletionStatus().Cloud metadata annotations helper:
Adds
CloudMetadataAnnotations(cloudMetadata *armotypes.CloudMetadata) map[string]string, mapping host type, host ID, cluster name, cloud account ID, and region to standard annotations where storage reads them.Extracted from entlein's hardened batch work.
Testing
TestCloudMetadataAnnotationsand concurrent status accessTestWatchedContainerData_StatusConcurrencyrun clean withgo test -race ./pkg/objectcache/....Summary by CodeRabbit