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

replace hard coded aws region checks with aws sdk calls #11119

Merged
merged 1 commit into from
Mar 24, 2021

Conversation

guydog28
Copy link
Contributor

future proof AWS endpoint and IAM Prefix generation to handle new AWS Partitions and future new ones. Offload to AWS SDK

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Mar 23, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @guydog28. Thanks for your PR.

I'm waiting for a kubernetes 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/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 23, 2021
@guydog28
Copy link
Contributor Author

/check-cla

@guydog28
Copy link
Contributor Author

I signed it

@guydog28
Copy link
Contributor Author

/check-cla

1 similar comment
@guydog28
Copy link
Contributor Author

/check-cla

@guydog28
Copy link
Contributor Author

I signed it

@guydog28
Copy link
Contributor Author

I didn't want to muddy up this pull request, but additionally there are partitions whose regions are not represented in upup/pkg/fi/cloud.go (zonesToCloud). Why not generate this list from the aws-sdk-go? This way as new regions are reported, if the sdk continues to be updated, the new regions will be available to kops users.

@guydog28
Copy link
Contributor Author

/check-cla

2 similar comments
@guydog28
Copy link
Contributor Author

/check-cla

@guydog28
Copy link
Contributor Author

/check-cla

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 23, 2021
@hakman
Copy link
Member

hakman commented Mar 23, 2021

Thanks @guydog28.
/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 Mar 23, 2021
@guydog28
Copy link
Contributor Author

/test pull-kops-e2e-cni-cilium

@hakman
Copy link
Member

hakman commented Mar 23, 2021

@guydog28 Please squash and make the commit message shorter. Will make it easier to track in the future.

@rifelpet
Copy link
Member

Regarding zonesToCloud, I agree that using the SDK to fetch an AZ list would be preferable, my concern would be that at the time we use that function, we don't necessarily know which cloud provider the kops create cluster is for, so we'd have to invoke each one and deal with credential failures since the user likely doesn't have credentials setup for cloud providers they're not using.

If we can figure out a lightweight way to do that for any providers that support providing this info via API, I would support that effort 👍🏻

That mapping only exists because we support inferring the cloud provider from the provided --zones. I would strongly prefer that we just make --cloud required and drop this map entirely, but I'm not sure how others feel.

@hakman
Copy link
Member

hakman commented Mar 23, 2021

That mapping only exists because we support inferring the cloud provider from the provided --zones. I would strongly prefer that we just make --cloud required and drop this map entirely, but I'm not sure how others feel.

I agree with this.

@guydog28
Copy link
Contributor Author

guydog28 commented Mar 23, 2021

Regarding zonesToCloud...

If we can figure out a lightweight way to do that for any providers that support providing this info via API, I would support that effort 👍🏻

That mapping only exists because we support inferring the cloud provider from the provided --zones. I would strongly prefer that we just make --cloud required and drop this map entirely, but I'm not sure how others feel.

@hakman @rifelpet If it just to make a guess, why not remove the map altogether and use a few regexs in the GuessCloudForZone func?

Just test it against each regex to guess the provider instead of that big list?

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 23, 2021
@guydog28
Copy link
Contributor Author

I have added the changes to cloud.go to this PR as well, as they seem pertinent to the goal of it.

Additionally, I took the old hardcoded zones and used them to create a unit test to test the regex I created to be sure this method still returns the same results.

@hakman
Copy link
Member

hakman commented Mar 24, 2021

@guydog28 Let's keep the 2 things separate. Please create a separate PR for the zones thing and we can discuss there.
The partitions thing seems reasonable, the only thing missing would be some unit tests for the changed functions, if you don't mind. It also seems innocent enough to cherry-pick to 1.19, right @rifelpet?

@rifelpet
Copy link
Member

Yes I agree

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 24, 2021
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 24, 2021
@guydog28
Copy link
Contributor Author

@hakman ok I pulled out the cloud.go into its own PR, and added tests for the changes.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 24, 2021
@hakman
Copy link
Member

hakman commented Mar 24, 2021

Could you also update the commit message and PR title to match the content?

@guydog28 guydog28 changed the title replace hard coded aws partitions and zones with sdk calls and regex replace hard coded aws region checks with aws sdk calls Mar 24, 2021
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 24, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hakman

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 Mar 24, 2021
@k8s-ci-robot k8s-ci-robot merged commit 42fbb1c into kubernetes:master Mar 24, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Mar 24, 2021
k8s-ci-robot added a commit that referenced this pull request Mar 25, 2021
…-upstream-release-1.20

Automated cherry pick of #11119: replace hard coded aws region checks with aws sdk calls
k8s-ci-robot added a commit that referenced this pull request Mar 25, 2021
…-upstream-release-1.19

Automated cherry pick of #11119: replace hard coded aws region checks with aws sdk calls
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants