Skip to content
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

fix: don't generate nodegroup role name starting with hyphen #4463

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

davidspek
Copy link
Contributor

@davidspek davidspek commented Aug 25, 2023

What type of PR is this?
/kind bug

What this PR does / why we need it:

Currently if EnableIAM is set to true and no role is specified for a node group the controller auto generates a role. However, the name formatting seems to be backwards from what it is intended to be, causing the role name to start with a -. What's surprising to me is that this doesn't seem to cause problems, other than that it looks weird. The name for the role that is currently generated looks like: -nodegroup-iam-service-role_<cluster-name>-<nodegroup-name>. This PR swaps the generated role name so it will be: <cluster-name>-<nodegroup-name>_nodegroup-iam-service-role. This is follows the same format as the name generated for Fargate.

Special notes for your reviewer:

Checklist:

  • squashed commits
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

Release note:

Change generated nodegroup IAM role name from `-nodegroup-iam-service-role_<cluster-name>-<nodegroup-name>` to `<cluster-name>-<nodegroup-name>_nodegroup-iam-service-role`

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority labels Aug 25, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @davidspek!

It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-aws 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-provider-aws has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @davidspek. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 25, 2023
@richardcase
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 31, 2023
@davidspek
Copy link
Contributor Author

@richardcase Have you had the chance to take a look at this PR?

@Ankitasw
Copy link
Member

Ankitasw commented Sep 6, 2023

/test pull-cluster-api-provider-aws-e2e-eks

@Ankitasw
Copy link
Member

Ankitasw commented Sep 6, 2023

/lgtm

cc @richardcase for approval

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 6, 2023
@Skarlso
Copy link
Contributor

Skarlso commented Sep 7, 2023

This will definitely cause existing clusters to break right? Since it will look for a specific role format?

@Ankitasw
Copy link
Member

Ankitasw commented Sep 7, 2023

@Skarlso that's a good point, shall we hold it for next release?

@Skarlso
Copy link
Contributor

Skarlso commented Sep 7, 2023

Yep, sounds good.

@davidspek
Copy link
Contributor Author

I'm not sure if it would break existing clusters, since this code is only used to create a new role if none were specified in the node group, which then get placed into the node group CR. Existing node group CRs would have the name of the role already in them.

@Skarlso
Copy link
Contributor

Skarlso commented Sep 7, 2023

It sets up the role name and then looks for it:

	s.scope.ManagedMachinePool.Spec.RoleName = roleName
	}
	role, err := s.GetIAMRole(s.scope.RoleName())

When reconciling normally, this would also happen and since it wouldn't find it, because it's looking for the set name it would try creating one again.

@Skarlso
Copy link
Contributor

Skarlso commented Sep 7, 2023

Ah but it only does that if the role is empty. Which would only happen if the role hasn't been created yet.

@Skarlso
Copy link
Contributor

Skarlso commented Sep 7, 2023

Okay, thinking about this some more, it should be fine. It should only happen for new clusters and old clusters should work. UNLESS, for whatever reason, the role name is wiped and it needs to look for it again.

@Ankitasw Ankitasw added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 7, 2023
@davidspek
Copy link
Contributor Author

Is there even logic to handle having the role name being wiped properly? The field should be immutable and if it gets removed I don't think there's a way to be able to recover what it should be (since it could also be a non-generated name).

@Ankitasw Ankitasw removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 13, 2023
@Ankitasw
Copy link
Member

cc @richardcase for final approval

@Ankitasw
Copy link
Member

/cherry-pick release-2.2

@k8s-infra-cherrypick-robot

@Ankitasw: once the present PR merges, I will cherry-pick it on top of release-2.2 in a new PR and assign it to you.

In response to this:

/cherry-pick release-2.2

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/test-infra repository.

@davidspek
Copy link
Contributor Author

@AndiDog Maybe you can have a look at this as well.

@davidspek
Copy link
Contributor Author

@Ankitasw @Skarlso What needs to be done before this PR can get merged?

@Skarlso
Copy link
Contributor

Skarlso commented Sep 25, 2023

I'll take a look later today. Been busy with work.

@davidspek
Copy link
Contributor Author

Awesome, thanks!

@Skarlso
Copy link
Contributor

Skarlso commented Sep 25, 2023

Okay, we did run tests, I thought this through, and I think it shouldn't break anything. "Famous last words".

Here we go:
/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Skarlso

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 25, 2023
@k8s-ci-robot k8s-ci-robot merged commit 526cedf into kubernetes-sigs:main Sep 25, 2023
1 check passed
@k8s-infra-cherrypick-robot

@Ankitasw: new pull request created: #4516

In response to this:

/cherry-pick release-2.2

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/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants