Skip to content

Enable Request Level Excluded Locations to Metadata API calls #40905

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

Conversation

allenkim0129
Copy link
Contributor

@allenkim0129 allenkim0129 commented May 6, 2025

Description

Request level excluded locations were not available for nested metadata calls. This could cause potential latency issue with high demend locations. With this changes metadata calls will also be re-routed to non-excluded locations.

Changes

  • Metadata API calls will now include request level excluded locations
  • For metadata calls, all excluded locations in preferred locations will be re-ordered to the end of the available locations. This means, even thought some locations were excluded, if all non-excluded locations were not available, the excluded locations will be used during API calls
  • All tests were updated to work with the changes.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Sorry, something went wrong.

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-sdk
Copy link
Collaborator

azure-sdk commented May 6, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

azure-cosmos

@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

azure-cosmos

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

@allenkim0129 allenkim0129 marked this pull request as ready for review May 7, 2025 22:42
@Copilot Copilot AI review requested due to automatic review settings May 7, 2025 22:42
@allenkim0129 allenkim0129 requested a review from a team as a code owner May 7, 2025 22:42
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables request‐level excluded locations for metadata API calls in order to re‐route calls to non‐excluded locations and improve latency management. Key changes include updating live platform configuration, extending tests to validate metadata calls with excluded locations, and adjusting internal components (e.g. fault injection transport, location cache, routing providers) to handle excluded locations correctly.

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
sdk/cosmos/live-platform-matrix.json Updated Windows image version and Python version for metadata tests.
sdk/cosmos/azure-cosmos/tests/* Updated tests to include request‐level excluded locations and revised client initialization with prefix partition keys.
sdk/cosmos/azure-cosmos/tests/_fault_injection_transport_async.py Updated fault injection transport for async operations.
sdk/cosmos/azure-cosmos/tests/_fault_injection_transport.py Updated fault injection transport for synchronous operations.
sdk/cosmos/azure-cosmos/tests/test_config.py Added configuration for multi-partition container with prefix partition keys.
sdk/cosmos/azure-cosmos/azure/cosmos/* Refactored functions to support excluded locations through feed options and updated internal helper methods.
Comments suppressed due to low confidence (2)

sdk/cosmos/azure-cosmos/tests/_fault_injection_transport_async.py:50

  • It appears the lambda incorrectly passes f['predicate'] instead of the request object. Update the lambda to use 'request' as the argument (e.g. lambda f: f'predicate').
matching_request_transformations = filter(lambda f: f["predicate"](f["predicate"]), iter(self.requestTransformations))

sdk/cosmos/azure-cosmos/tests/_fault_injection_transport.py:40

  • The lambda for applying request transformations mistakenly passes f['predicate'] instead of the current request. It should be changed to pass 'request' (i.e. lambda f: f'predicate').
matching_request_transformations = filter(lambda f: f["predicate"](f["predicate"]), iter(self.requestTransformations))

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@kushagraThapar kushagraThapar left a comment

Choose a reason for hiding this comment

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

Thank you @allenkim0129 for the changes, they look good from overall point of view, however, I have couple of questions on the public surface APIs, let's discuss them before merging this in.

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@simorenoh simorenoh left a comment

Choose a reason for hiding this comment

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

Just a couple of comments, thanks Allen!

@allenkim0129 allenkim0129 merged commit a1946d4 into Azure:main May 27, 2025
18 checks passed
@allenkim0129 allenkim0129 deleted the users/allekim/feature/applyExcludedLocationToMetadataAPIs branch June 16, 2025 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants