Skip to content

[FEATURE] Detect AOSS generation from the control plane - #18

Open
noel-improv wants to merge 2 commits into
feat/local-opensearch-vector-storefrom
feat/aoss-generation-detection
Open

noel-improv wants to merge 2 commits into
feat/local-opensearch-vector-storefrom
feat/aoss-generation-detection

Conversation

@noel-improv

@noel-improv noel-improv commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Description

index_exists() picks the Classic or NextGen knn_vector mapping for an AOSS collection by trying Classic first and retrying with NextGen on a specific OpenSearch error string. This adds a deterministic check ahead of that retry: for AOSS endpoints with the generation unset, it reads the collection's generation from the control plane (BatchGetCollection then BatchGetCollectionGroup) and uses it directly. The reactive retry stays as the fallback whenever the control-plane check is unavailable.

Changes

  • Add _parse_aoss_collection() to extract the collection id and region from an AOSS endpoint host.
  • Add _resolve_aoss_generation() to read the generation field via batch_get_collection then batch_get_collection_group. Returns the generation, or None when it can't be determined.
  • Wire the resolver into index_exists() ahead of the reactive retry. It runs only when is_sigv4_auth is true and the generation is unset; the retry stays armed until NextGen is confirmed.
  • Grant aoss:BatchGetCollection and aoss:BatchGetCollectionGroup to the client role in the three AOSS example templates.

Problem

Detection was coupled to an AWS error string, which could shift if the message changes. Reading the generation from the control plane removes that coupling where the two new IAM actions are granted. Raised in review of awslabs#391.

Related issue (if any): awslabs#399

Testing

  • Unit tests added/updated
  • Integration tests added (as appropriate)
  • Existing tests pass (pytest)
  • Tested manually (describe below)

21 unit tests cover the resolver and host parsing: NEXTGEN and CLASSIC honoured, no group falls back, AccessDenied / generic ClientError / old boto3 fall back, non-AOSS endpoints skip the call, explicit override skips detection. The 26 existing NextGen tests are unchanged. 78 OpenSearch unit tests pass locally.

Checklist

  • Code follows existing style and conventions
  • License headers present on new files
  • Documentation updated (if applicable)
  • No breaking changes (or clearly documented)

Dependency note

The boto3 floor stays at 1.40.61. Bumping to 1.43.17 (which batch_get_collection_group needs) is a no-go: it reintroduces the aiobotocore conflict resolved recently (aiobotocore pins botocore <1.40.62), so raising the floor breaks install. The API is detected at runtime instead — deterministic detection runs where boto3 is already >=1.43.17, and falls back to the existing reactive path everywhere else. No behavior change.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@noel-improv
noel-improv force-pushed the feat/aoss-generation-detection branch from 5539af9 to c564a3d Compare July 17, 2026 20:31
@noel-improv noel-improv self-assigned this Jul 17, 2026
@noel-improv
noel-improv marked this pull request as ready for review July 17, 2026 20:37

@acarbonetto acarbonetto left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A couple of questions/comments.

"aoss:BatchGetCollection",
"aoss:BatchGetCollectionGroup"
],
"Resource": "*"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think we should be able to point to the necessary resource instead of using *
Security will probably flag this as is.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

...unless the Action doesn't work against specific resources. In which case, we will have to keep the "*"

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Checked the Service Authorization Reference, both aoss:BatchGetCollection and aoss:BatchGetCollectionGroup are management-plane actions with no resource type, they only work with Resource: "*". The collection group is also created implicitly by AOSS and isn't named in the template, so there's no ARN to target regardless.

@noel-improv
noel-improv force-pushed the feat/aoss-generation-detection branch 2 times, most recently from 419be40 to 2935582 Compare July 17, 2026 23:14

@acarbonetto acarbonetto left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

lgtm

@oussamahansal oussamahansal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

Resolve an AOSS collection's Classic/NextGen generation deterministically via
BatchGetCollection/BatchGetCollectionGroup in index_exists(), ahead of the
existing reactive error-string retry. Detection runs only for AOSS endpoints
(is_sigv4_auth) with the generation unset; any failure -- missing IAM, a boto3
too old for the API, a non-AOSS host, or an unexpected response -- falls back to
the reactive retry, which stays as the safety net.

The boto3 floor is left at 1.40.61 rather than bumped to 1.43.17: the aiobotocore
ceiling pulled in transitively still pins botocore below 1.40.62, so the API is
detected at runtime and the path activates once that constraint is lifted.

Grant aoss:BatchGetCollection and aoss:BatchGetCollectionGroup to the client role
in the AOSS example templates so the detection has the permissions it needs.
Bound the control-plane probe with a short-timeout botocore Config so a
deployment that reaches the AOSS data plane but not the opensearchserverless
control-plane API fails fast into the reactive fallback instead of blocking on
the default ~60s connect timeout for every index.

Memoize the detected generation per (collection_id, region) so N indexes
against the same collection cost two control-plane calls instead of 2N, which
also avoids tripping ThrottlingException. Only successful resolutions are
cached; a transient failure stays uncached so the next index retries.

Broaden the AOSS host regex to accept the .cn partition suffix.

Add tests for memoization, the uncached-transient-failure path, and .cn host
parsing; add an autouse fixture to clear the cache between tests.
@noel-improv
noel-improv force-pushed the feat/aoss-generation-detection branch from aeccb05 to 8762036 Compare August 12, 2026 19:35
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.

3 participants