-
Notifications
You must be signed in to change notification settings - Fork 570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Standardize cluster name in Fargate role names to avoid errors on mismatch between Cluster CR and EKS cluster name #5111
🐛 Standardize cluster name in Fargate role names to avoid errors on mismatch between Cluster CR and EKS cluster name #5111
Conversation
Welcome @alam0rt! |
Hi @alam0rt. 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 Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
pkg/cloud/services/eks/roles.go
Outdated
@@ -183,7 +183,7 @@ func (s *NodegroupService) reconcileNodegroupIAMRole() error { | |||
s.scope.Info("no EKS nodegroup role specified, using role based on nodegroup name") | |||
roleName, err = eks.GenerateEKSName( | |||
"nodegroup-iam-service-role", | |||
fmt.Sprintf("%s-%s", s.scope.KubernetesClusterName(), s.scope.NodegroupName()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will confirm if this issue exists in the webhook for ng iam roles shortly.
@@ -304,7 +304,7 @@ func (s *FargateService) reconcileFargateIAMRole() (requeue bool, err error) { | |||
s.scope.Info("no EKS fargate role specified, using role based on fargate profile name") | |||
roleName, err = eks.GenerateEKSName( | |||
"fargate", | |||
fmt.Sprintf("%s-%s", s.scope.KubernetesClusterName(), s.scope.FargateProfile.Spec.ProfileName), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we should use s.scope.FargateProfile.Spec.ClusterName
instead - unsure of the conventions at play.
/retitle 🐛 Standardize cluster name in Fargate role names to avoid errors on mismatch between Cluster CR and EKS cluster name |
I shortly looked into this. Following the two
so these functions are inconsistent. If I do the same go-to-code without your PR changes, I get |
i'll write up a test tomorrow to hopefully cover the issue we are facing. the issue is not the consistency between Fargate / ManagedMachinePool scopes, rather in how the awsfargateprofile webhook generates the role name. The validating webhook has roleName, err := eks.GenerateEKSName(
"fargate",
fmt.Sprintf("%s-%s", r.Spec.ClusterName, r.Spec.ProfileName),
maxIAMRoleNameLength,
) The EKS role service has roleName, err = eks.GenerateEKSName(
"fargate",
fmt.Sprintf("%s-%s", s.scope.KubernetesClusterName(), s.scope.FargateProfile.Spec.ProfileName),
maxIAMRoleNameLength,
) In the scope of Fargate, // KubernetesClusterName is the name of the EKS cluster name.
func (s *FargateProfileScope) KubernetesClusterName() string {
return s.ControlPlane.Spec.EKSClusterName
} In my case, this would return |
Alright, I ran this code and confirm that it fixes the issue. So given
The resource is successfully mutated by the fargate controller and passes the validation webhook update check.
Whereas before it was failing since the As evidenced by the log line
Let me try writing up a test to capture this. |
So I've noticed that there aren't any tests covering (at least obviously) the |
Indeed, no tests. I guess Fargate is too rarely used for such contributions, so I'm fine to go ahead without since the fix is small and well-scoped. /ok-to-test |
Thanks for this @alam0rt . The Fargate functionality needs some love, its still experimental and could do with e2e tests and otehr such things. /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: richardcase The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/cherrypick release-2.6 |
@richardcase: once the present PR merges, I will cherry-pick it on top of release-2.6 in a new PR and assign it to you. In response to this:
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. |
@richardcase I updated the release notes for this PR as it didn't have them. |
@richardcase: new pull request created: #5158 In response to this:
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. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
The validating webhook
cluster-api-provider-aws/exp/api/v1beta2/awsfargateprofile_webhook.go
Lines 83 to 90 in abe918c
spec.clusterName
in order to generate the role name.This differs from the EKS role service which instead uses the
scope.KubernetesClusterName()
.cluster-api-provider-aws/pkg/cloud/services/eks/roles.go
Lines 304 to 309 in abe918c
The problem comes from the scenario where the cluster resource is named one thing (i.e.
foo
) but was created in EKS using some prefixes (i.e.default_foo-control-plane
). If this is the case, the CAPA controller will fail to validate its own change.Also, changing the fargate profile's
.spec.clusterName
to match thescope.KubernetesClusterName()
will fail if this does not match the custom resource'smetadata.name
.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Checklist:
Release note: