iamauth: fix aws-iam-authenticator reconcile for clusters using instance profiles from AWSMachinePool / AWSMachineTemplate#6076
Conversation
Fixes kubernetes-sigs#6075 Signed-off-by: Kesavaraj S <ksugumaran@newrelic.com>
|
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @Kesav531. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Invalid commit message issues detected Invalid commit messagesKeywords which can automatically close issues and hashtag(#) mentions are not allowed.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
Thanks @Kesav531 for submitting this change, this was one of the blocking issue for us. |
What this PR does / why we need it:
Fixes a bug in
pkg/cloud/services/iamauthwhere theaws-iam-authenticatorreconciler conflates IAM instance profile names (sourced fromAWSMachineTemplate.Spec.Template.Spec.IAMInstanceProfileandAWSMachinePool.Spec.AWSLaunchTemplate.IamInstanceProfile) with IAM role names (sourced fromAWSManagedMachinePool.Spec.RoleName). All three are collected into a singlemap[string]struct{}and then unconditionally resolved viaiam:GetRole, which is wrong for the first two cases.Result on EKS clusters whose workers come from
AWSMachinePoolorMachineDeployment+AWSMachineTemplate:GetRolereturnsNoSuchEntity(when no IAM role of the same name as the instance profile exists) — reconcile fails permanently, theaws-authConfigMap never gets the node role mapping, AMCP conditionIAMAuthenticatorConfiguredstaysFalse.GetRolereturns the ARN of an unrelated IAM role that happens to share the name —aws-authis silently populated with the wrong ARN.Fix:
asInstanceProfilevsasRole) at collection time via amap[string]nameKind.getARNForInstanceProfilecallingiam:GetInstanceProfileand returningRoles[0].Arn(AWS limits an instance profile to one attached role; emptyRolesis treated as an error).resolveRoleARN(ctx, name, kind)dispatcher; replace the singlegetARNForRolecall site inReconcileIAMAuthenticator.iam:GetInstanceProfilein the EKS controllers policy generated byclusterawsadm, so the controller can actually call the new API. Regenerated all 13 affected bootstrap fixtures.Which issue(s) this PR fixes:
Fixes #6075
Special notes for your reviewer:
pkg/cloud/services/iamauth/reconcile_test.gocover: instance-profile-name dispatch, role-name dispatch, error path for instance profile with no attached role, error path for unknown kind.GetInstanceProfilecall.cmd/clusterawsadm/cloudformation/bootstrap) passes — all 13 fixtures match the regenerated policy.AWSMachinePool; AMCPIAMAuthenticatorConfiguredflipped fromFalsetoTrueafter the fix landed alongside the IAM grant.Release note: