Repository navigation
fix(auth): deduplicate ECR, ECR Public, and EKS integrations to once per process - #2564
Conversation
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
f35c6dc to
bf2f27c
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis change adds a process-wide deduplication cache for auto-provisioned integrations (ECR, EKS, ECR-Public). The cache uses ChangesIntegration Deduplication
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
pkg/auth/manager_integrations.go (1)
25-32: 💤 Low valueConsider using
sync.Map.Clear()directly.Go 1.23+ provides
Clear()on sync.Map, which simplifies this helper.Proposed simplification
func resetProcessIntegrationCache() { - processIntegrationCache.Range(func(key, _ any) bool { - processIntegrationCache.Delete(key) - return true - }) + processIntegrationCache.Clear() }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/auth/manager_integrations.go` around lines 25 - 32, The helper resetProcessIntegrationCache currently iterates and deletes entries manually; replace its body with a single call to processIntegrationCache.Clear() (requires Go 1.23+), i.e. update resetProcessIntegrationCache to invoke processIntegrationCache.Clear() to simplify and improve clarity while keeping the same function name and behavior.pkg/toolchain/checksum/parse.go (1)
49-55: 💤 Low valueConsider returning scanner errors even when partial entries exist.
The current implementation silently discards scanner errors when
len(entries) > 0, but the comment states callers should decide whether partial data is useful. By returningnilerror, callers have no signal that parsing was incomplete. For diagnostics and reproducible-builds guarantees, consider returning the scanner error wrapped with context (e.g.,fmt.Errorf("incomplete parse (%d entries): %w", len(entries), err)) so callers can log/handle partial success explicitly.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/toolchain/checksum/parse.go` around lines 49 - 55, The scanner error is currently swallowed when partial entries exist; change the logic so the function returns the parsed entries along with the scanner error (wrapped with context) instead of returning nil error. In the block that checks scanner.Err() use something like returning entries, fmt.Errorf("incomplete parse (%d entries): %w", len(entries), err) so callers can detect and handle partial results; ensure you import fmt if needed and keep the existing behavior of returning nil, err when no entries were parsed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/auth/manager_integrations_test.go`:
- Around line 207-279: Add a new test case to TestIntegrationTargetKey for the
aws/ecr-public kind to assert the integrationTargetKey returns the fixed key
"aws/ecr-public" when Kind is "aws/ecr-public"; update the tests slice (in the
TestIntegrationTargetKey function) with an entry named "ECR Public uses fixed
key" using intName "my-ecr-public", integration.Kind "aws/ecr-public", and want
"aws/ecr-public" so the behavior is validated once the KindAWSECRPublic branch
is implemented in integrationTargetKey.
In `@pkg/auth/manager_integrations.go`:
- Around line 39-51: The switch in integrationTargetKey currently lacks a branch
for integrations.KindAWSECRPublic, so ECR Public configs don't deduplicate; add
a case for integrations.KindAWSECRPublic in the integrationTargetKey function
that returns the fixed key "aws/ecr-public" (i.e., treat ECR Public as a single
global registry key) alongside the existing KindAWSECR and KindAWSEKS cases so
all ECR Public integrations map to the same cache key.
---
Nitpick comments:
In `@pkg/auth/manager_integrations.go`:
- Around line 25-32: The helper resetProcessIntegrationCache currently iterates
and deletes entries manually; replace its body with a single call to
processIntegrationCache.Clear() (requires Go 1.23+), i.e. update
resetProcessIntegrationCache to invoke processIntegrationCache.Clear() to
simplify and improve clarity while keeping the same function name and behavior.
In `@pkg/toolchain/checksum/parse.go`:
- Around line 49-55: The scanner error is currently swallowed when partial
entries exist; change the logic so the function returns the parsed entries along
with the scanner error (wrapped with context) instead of returning nil error. In
the block that checks scanner.Err() use something like returning entries,
fmt.Errorf("incomplete parse (%d entries): %w", len(entries), err) so callers
can detect and handle partial results; ensure you import fmt if needed and keep
the existing behavior of returning nil, err when no entries were parsed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 73e6e29d-ef30-4e1f-8c6b-4ad0939f2461
📒 Files selected for processing (6)
pkg/auth/manager_integrations.gopkg/auth/manager_integrations_test.gopkg/toolchain/checksum/checksum.gopkg/toolchain/checksum/checksum_test.gopkg/toolchain/checksum/parse.gopkg/toolchain/checksum/parse_test.go
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (72.22%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #2564 +/- ##
==========================================
+ Coverage 78.82% 78.83% +0.01%
==========================================
Files 1195 1195
Lines 114267 114285 +18
==========================================
+ Hits 90067 90093 +26
+ Misses 19248 19240 -8
Partials 4952 4952
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Andriy Knysh (aknysh)
left a comment
There was a problem hiding this comment.
thanks Miguel Zablah (@MrZablah)
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
These changes were released in v1.221.0-rc.4. |
What
Adds a process-level execution cache to
triggerIntegrationsso thatauto-provisioned integrations (
aws/ecr,aws/ecr-public,aws/eks)fire at most once per
atmosinvocation, regardless of how many timesAuthenticateis called or how manyAuthManagerinstances are created.The cache key is the integration's canonical target endpoint rather than
its config entry name:
aws/ecr→"aws/ecr:<account_id>:<region>"aws/ecr-public→"aws/ecr-public"(single global registry)aws/eks→"aws/eks:<cluster_name>:<region>"This means two config entries that point at the same registry — e.g. one
from global
atmos.yamland one from a component stack file — arecollapsed to a single execution.
Why
atmos terraform plancallsAuthenticatefrom at least three internalpaths:
setupTerraformAuth,TerraformPreHook, and one call per YAMLfunction (
!store.get,!terraform.state). With a 6-tool.tool-versionsthis produced 6 ECR logins per command. Switching to a name-keyed cache
reduced it to 2 because merged configs can carry two integration entries
with different names for the same registry. Keying by target endpoint
reduces this to exactly 1.
Changes
pkg/auth/manager_integrations.go— addsprocessIntegrationCache sync.Map,resetProcessIntegrationCache()(test helper),integrationTargetKey()(canonical key helper coveringaws/ecr,aws/ecr-public,aws/eks); updatestriggerIntegrationsto useLoadOrStoreon the target key.pkg/auth/manager_integrations_test.go— addsTestIntegrationTargetKey(table-driven tests for all key variantsincluding ECR Public) and
TestIntegrationTargetKey_Deduplication(verifies that two same-registry entries produce one cache hit).
Notes
aws/ecr-publicwas added toupstream/mainin #2231 after this branchdiverged; coverage for it was added here to keep deduplication consistent
across all three AWS integration kinds.
references
ECR / ECR Public Login Executes Multiple Times Per atmos terraform Invocation
#2562
Summary by CodeRabbit
New Features
Tests