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

Implement configured endpoint url resolver #2958

Conversation

kdaily
Copy link
Member

@kdaily kdaily commented May 26, 2023

Adds a config provider to resolve the endpoint URL provided in an environment variable or shared configuration file. It resolves the endpoint in the following manner:

  1. The value provided through the endpoint_url parameter provided to the client constructor.
  2. The value provided by a service-specific environment variable.
  3. The value provided by the global endpoint environment variable (AWS_ENDPOINT_URL).
  4. The value provided by a service-specific parameter from a services definition section in the shared configuration file.
  5. The value provided by the global parameter from a services definition section in the shared configuration file.
  6. The value resolved when no configured endpoint URL is provided.

@kdaily kdaily requested a review from kyleknap May 26, 2023 17:38
@kdaily kdaily force-pushed the implement-configured-endpoint-url-resolver branch 2 times, most recently from 906b678 to d597716 Compare May 30, 2023 17:42
Copy link
Member

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

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

Implementation looks fine. Just had some comments. It would be nice if we can get the unit tests included as part of this PR and we can add the functional tests in a subsequent PR. Mainly it is going to be easier to review the unit tests while looking over all of the classes/interfaces that we are adding.

botocore/session.py Outdated Show resolved Hide resolved
botocore/session.py Outdated Show resolved Hide resolved
botocore/args.py Show resolved Hide resolved
botocore/args.py Outdated Show resolved Hide resolved
botocore/configloader.py Show resolved Hide resolved
botocore/configprovider.py Outdated Show resolved Hide resolved
botocore/session.py Outdated Show resolved Hide resolved
@@ -510,6 +517,116 @@ def set_config_provider(self, logical_name, provider):
self._mapping[logical_name] = provider


class ConfiguredEndpointProviderChain:
Copy link
Member

Choose a reason for hiding this comment

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

In using the approach of making the logic a provider let's:

  1. Rename this class to ConfiguredEndpointProvider. Ending it in Provider makes it clear this is a provider class. Also the word Chain now conflates with the ChainProvider and makes sense to get rid of its usage since it does not subclass from ChainProvider.
  2. Make sure this class subclasses from the BaseProvider class and implements any of the shared methods as (e.g. __deepcopy__ and __repr__)
  3. Consider documenting that users should not be instantiating this class directly and that it is not supported in case we ever want to refactor the initializer arguments for the class.
  4. Add unit tests for this class

Copy link
Member Author

@kdaily kdaily May 30, 2023

Choose a reason for hiding this comment

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

Added __deepcopy__ method, but __repr__ is tricky. Other config providers have succinct string-based parameters because they also take a session object, so can initialize other objects internally. The init params for ConfiguredEndpointProvider are all potentially large dictionaries.

@kdaily kdaily force-pushed the implement-configured-endpoint-url-resolver branch 3 times, most recently from e0ff128 to 3b55e1d Compare June 1, 2023 22:53
@codecov-commenter
Copy link

codecov-commenter commented Jun 2, 2023

Codecov Report

Patch coverage: 94.87% and project coverage change: -0.01 ⚠️

Comparison is base (619a317) 93.32% compared to head (ba4264f) 93.32%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@                     Coverage Diff                      @@
##           configured-endpoint-urls    #2958      +/-   ##
============================================================
- Coverage                     93.32%   93.32%   -0.01%     
============================================================
  Files                            64       64              
  Lines                         13597    13662      +65     
============================================================
+ Hits                          12690    12750      +60     
- Misses                          907      912       +5     
Impacted Files Coverage Δ
botocore/config.py 100.00% <ø> (ø)
botocore/args.py 99.56% <90.00%> (-0.44%) ⬇️
botocore/configprovider.py 94.49% <93.47%> (-0.17%) ⬇️
botocore/configloader.py 100.00% <100.00%> (+2.08%) ⬆️
botocore/handlers.py 95.18% <100.00%> (ø)
botocore/session.py 96.91% <100.00%> (+0.02%) ⬆️
botocore/utils.py 79.37% <100.00%> (+0.02%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

botocore/args.py Outdated Show resolved Hide resolved
@kdaily kdaily force-pushed the implement-configured-endpoint-url-resolver branch 2 times, most recently from bbc2d5e to 610ce31 Compare June 9, 2023 17:03
Copy link
Contributor

@dlm6693 dlm6693 left a comment

Choose a reason for hiding this comment

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

This is looking pretty good so far. I'd like to see some organizational changes and have some questions about the underlying logic in a couple of places, but we're definitely on the right track here.

botocore/args.py Outdated Show resolved Hide resolved
botocore/configprovider.py Outdated Show resolved Hide resolved
botocore/configprovider.py Outdated Show resolved Hide resolved
botocore/configprovider.py Show resolved Hide resolved
botocore/configprovider.py Outdated Show resolved Hide resolved
botocore/utils.py Outdated Show resolved Hide resolved
tests/unit/cfg/aws_services_config Show resolved Hide resolved
tests/unit/test_config_provider.py Outdated Show resolved Hide resolved
tests/unit/test_config_provider.py Outdated Show resolved Hide resolved
tests/unit/test_session_legacy.py Outdated Show resolved Hide resolved
@kdaily kdaily force-pushed the implement-configured-endpoint-url-resolver branch from 93df202 to 0aebebf Compare June 9, 2023 22:12
@A-Levin
Copy link

A-Levin commented Jun 12, 2023

any news, guys?)

botocore/args.py Outdated Show resolved Hide resolved
botocore/configprovider.py Show resolved Hide resolved
botocore/configprovider.py Outdated Show resolved Hide resolved
Copy link
Member

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

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

Looks good. I just had feedback around organizations and some of the refactors that were done. I do think we are close though to get this one merged so that we can move on to the functional test PR.

botocore/configprovider.py Outdated Show resolved Hide resolved
botocore/configprovider.py Outdated Show resolved Hide resolved
botocore/session.py Outdated Show resolved Hide resolved
botocore/utils.py Outdated Show resolved Hide resolved
botocore/handlers.py Outdated Show resolved Hide resolved
tests/unit/docs/__init__.py Outdated Show resolved Hide resolved
tests/unit/test_config_provider.py Outdated Show resolved Hide resolved
tests/unit/test_session.py Outdated Show resolved Hide resolved
tests/unit/test_session_legacy.py Outdated Show resolved Hide resolved
@kdaily kdaily force-pushed the implement-configured-endpoint-url-resolver branch 3 times, most recently from 9b82ed3 to 659df5e Compare June 13, 2023 19:11
Copy link
Member

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

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

Looks good. I just had some small comments, but we should be set after.

botocore/configprovider.py Outdated Show resolved Hide resolved
botocore/configprovider.py Show resolved Hide resolved
botocore/utils.py Outdated Show resolved Hide resolved
tests/unit/test_config_provider.py Outdated Show resolved Hide resolved
tests/unit/test_config_provider.py Show resolved Hide resolved
Copy link
Member

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

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

Looks good. Just one last comment that I missed from the last review.

tests/unit/test_config_provider.py Show resolved Hide resolved
Copy link
Member

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

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

Looks good! 🚢 Feel free to squash the commits and merge.

Adds a config provider to resolve the endpoint URL provided in an
environment variable or shared configuration file. It resolves the
endpoint in the following manner:

1. The value provided through the `endpoint_url` parameter provided to
   the client constructor.
2. The value provided by a service-specific environment variable.
3. The value provided by the global endpoint environment variable
   (`AWS_ENDPOINT_URL`).
4. The value provided by a service-specific parameter from a services
   definition section in the shared configuration file.
5. The value provided by the global parameter from a services definition
   section in the shared configuration file.
6. The value resolved when no configured endpoint URL is provided.

The endpoint config provider uses the client name (name used to
instantiate a client object) for construction and add to the config
value store. This uses multiple lookups to handle service name changes
for backwards compatibility.
@kdaily kdaily force-pushed the implement-configured-endpoint-url-resolver branch from 3a58267 to ba4264f Compare June 14, 2023 21:38
@kdaily kdaily merged commit d0969d4 into boto:configured-endpoint-urls Jun 14, 2023
31 checks passed
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.

None yet

5 participants