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

Abstract region discovery #757

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

micahhausler
Copy link
Member

What this PR does / why we need it:

With the deprecation of AWS SDK Go v1, and the removal of the endpoints package, we need a new way to discover valid regions. This change preserves the previous behavior, while adding a new method that calls accounts:ListRegions, or looking up endpoints from a file.

See #736 (comment)

Which issue(s) this PR fixes

Further progress toward #736

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 4, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: micahhausler

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 4, 2024
@micahhausler micahhausler force-pushed the region-discovery branch 2 times, most recently from 45fbf23 to c73ba48 Compare September 4, 2024 22:31
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 7, 2024
With the deprecation of AWS SDK Go, and the removal of the endpoints
package, we need a new way to discover valid regions. This change
preserves the previous behavior, while adding a new method that calls
accounts:ListRegions, or looking up endpoints from a file.
@k8s-ci-robot
Copy link
Contributor

@micahhausler: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-aws-iam-authenticator-e2e-kind b2bba49 link true /test pull-aws-iam-authenticator-e2e-kind
pull-aws-iam-authenticator-e2e b2bba49 link true /test pull-aws-iam-authenticator-e2e

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 9, 2024

awscfg, err := aws_config.LoadDefaultConfig(context.TODO())
if err != nil {
logrus.WithError(err).Fatal("unable to create AWS config")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we return an error instead of calling Fatal? Seems like getConfig is expected to propagate errors

for {
select {
case <-stopCh:
logrus.Info("shut down mapper before return from Run")
close(c.internalHandler.backendMapper.mapperStopCh)
close(s.internalHandler.backendMapper.mapperStopCh)
c.endpointVerifier.Stop()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should this be

Suggested change
c.endpointVerifier.Stop()
s.endpointVerifier.Stop()

?

// API makes the server invoke the AWS API call `account:ListRegions` to find a list of valid regions.
//
// File has the server read a file containing a JSON list of strings with valid STS endpoints.
EndpointValidationMode string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Would it be worthwhile to define this using an enum/const generator, instead of string?

eg:

type ValidationMode int64

const (
	Legacy ValidationMode = iota
	API
	File
)

It would save us from requiring defensive checks in the switch/case statements, but I also understand if the overhead of dealing with enums in Go isn't worth the hassle.

return parsedURL.Hostname(), nil
}

func stsHostsForPartition(partitionID, region string) map[string]bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job refactoring this legacy logic into regions.sdkV1Discoverer 💯

{
name: "InvalidJSON",
fs: func() fs.FS {
tmpfs := afero.NewMemMapFs()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed afero in the last PR too - this looks pretty useful!

var tlds []string
serviceNames := []string{"sts", "sts-fips"}
switch d.partition {
case "aws":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my enums question above: is it worthwhile to use enums here?

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 10, 2024
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. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants