fix: make instance profile naming deterministic to prevent churn#9009
Open
fix: make instance profile naming deterministic to prevent churn#9009
Conversation
…#8838) Replace uuid.New() with in.Spec.Role in InstanceProfileName() hash input, making profile names deterministic per (nodeclass, role) pair. This prevents runaway instance profile creation caused by IAM eventual consistency triggering the creation branch with a new UUID-based name each time. Additionally, normalize role name comparison in the reconciler by stripping IAM path prefixes before comparing currentRole with spec.Role, preventing false mismatches when roles use IAM paths. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Fixes #8838
uuid.New()within.Spec.RoleinInstanceProfileName()hash input, making profile names deterministic per (nodeclass, role) pair. This prevents runaway instance profile creation caused by IAM eventual consistency triggering the creation branch with a new UUID-based name each time.currentRolewithspec.Role, preventing false mismatches when roles use IAM paths.Root Cause
Two reinforcing bugs caused a sawtooth pattern in instance profile counts after upgrading from v1.6 to v1.7+:
InstanceProfileName()useduuid.New(), so every call produced a different namecurrentRole: IAM eventual consistency (empty roles, NotFound), empty status, or controller restarts caused the reconciler to think no profile existedTogether: cache expires → IAM returns stale data → role mismatch → new UUID-named profile created → old profile orphaned → GC cleans up → repeat every ~15 min.
Fix
Making
InstanceProfileName()deterministic by includingspec.Rolein the hash means even when the reconciler falsely enters the creation branch, it generates the same name. The provider'sCreatefinds the existing profile, callsensureRole(idempotent), and returns — no orphan created.Role changes still produce different profile names (different role → different hash), preserving zero-downtime role switching.
Edge Cases