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

Add STS endpoint resolver #1332

Merged
merged 1 commit into from
Jan 20, 2021
Merged

Conversation

nithu0115
Copy link
Contributor

What type of PR is this?
Enhancement and Cleanup

Which issue does this PR fix: #647

What does this PR do / Why do we need it:
Add STS endpoint resolver

If an issue # is not available please add repro steps and logs from IPAMD/CNI showing the issue:

Testing done on this change:

Automation added to e2e:

Will this break upgrades or downgrades. Has updating a running cluster been tested?:

Does this change require updates to the CNI daemonset config files to work?:

Does this PR introduce any user-facing change?: No


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

log.Errorf("Failed to initialize AWS SDK session %v", err)
return nil, errors.Wrap(err, "instance metadata: failed to initialize AWS SDK session")
}
awsCfg := aws.NewConfig().WithRegion(region)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move the "region" when we initialize "sess" ? That could avoid a copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought of this. To move sess.copy to awssession and get region by querying ec2 metadata, get availability zone and then do some parsing did not seem efficient way, and more work.

Copy link
Contributor

@anguslees anguslees Jan 29, 2021

Choose a reason for hiding this comment

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

Can't afaics? We need to find the region somehow. Assuming we use IMDS to find the region, then we still need a 'regionless' session to initialise the IMDS client, so that we can find the region, so that we can configure a 'regionful' session to initialise the 'normal' AWS client. 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right :D @anguslees

Copy link
Contributor

@jayanthvn jayanthvn left a comment

Choose a reason for hiding this comment

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

Some minor nits, overall looks good to me.

Copy link
Contributor

@couralex6 couralex6 left a comment

Choose a reason for hiding this comment

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

Nice to have all the sessions in one file now. Looks good overall, but it would be nice to have a warning message for invalid custom HTTP timeout values.

pkg/awsutils/awssession/session.go Show resolved Hide resolved
pkg/awsutils/awssession/session.go Outdated Show resolved Hide resolved
sess, err := session.NewSession(
&aws.Config{
Region: aws.String(cache.region),
MaxRetries: aws.Int(15),
Copy link
Contributor

Choose a reason for hiding this comment

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

Max retry was 15 here and 10 above. Do we know why we used different values for those two sessions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure why this discrepancy. I went ahead and assumed that 10 retries should be a good number to meet most of the use-cases. Let me know if you want me to increase it.

pkg/awsutils/awssession/session.go Show resolved Hide resolved
@nithu0115
Copy link
Contributor Author

@couralex6 @achevuru @jayanthvn, thanks for the review. Addressed your comments :D

Copy link
Contributor

@jayanthvn jayanthvn left a comment

Choose a reason for hiding this comment

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

LGTM :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants