Skip to content

[Inference API] Handle non-initialized shards in AuthorizationTaskExecutorIT#144736

Merged
dimitris-athanasiou merged 4 commits intoelastic:mainfrom
dimitris-athanasiou:handle-SPEE-in-AuthorizationTaskExecutorIT
Mar 26, 2026
Merged

[Inference API] Handle non-initialized shards in AuthorizationTaskExecutorIT#144736
dimitris-athanasiou merged 4 commits intoelastic:mainfrom
dimitris-athanasiou:handle-SPEE-in-AuthorizationTaskExecutorIT

Conversation

@dimitris-athanasiou
Copy link
Copy Markdown
Contributor

Previous attempts at fixing this issue did not work because I was wrongly assuming that assertBusy retried when any exception was thrown. However, it only retries when an AssertionError is thrown.

The key method in the test that needs to wait for internal inference indices to be created is getEisEndpoints(). This commit catches SearchPhaseExecutionException and throws an AssertionError giving us a chance to retry this when getEisEndpoints() is called from within an assertBusy().

Closes #144671
Closes #144691
Closes #144731

…cutorIT

Previous attempts at fixing this issue did not work because I was wrongly
assuming that `assertBusy` retried when any exception was thrown. However,
it only retries when an `AssertionError` is thrown.

The key method in the test that needs to wait for internal inference indices
to be created is `getEisEndpoints()`. This commit catches `SearchPhaseExecutionException`
and throws an `AssertionError` giving us a chance to retry this when `getEisEndpoints()`
is called from within an `assertBusy()`.

Closes elastic#144671
Closes elastic#144691
Closes elastic#144731
@dimitris-athanasiou dimitris-athanasiou added >test Issues or PRs that are addressing/adding tests :SearchOrg/Inference Label for the Search Inference team v9.4.0 labels Mar 23, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/search-inference-team (Team:Search - Inference)

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: c0b60c31-2e37-472f-b68a-fe3a22ba727b

📥 Commits

Reviewing files that changed from the base of the PR and between fbc2786 and a7f04e5.

📒 Files selected for processing (1)
  • muted-tests.yml
💤 Files with no reviewable changes (1)
  • muted-tests.yml

📝 Walkthrough

Walkthrough

The PR removes three muted-test entries for AuthorizationTaskExecutorIT from muted-tests.yml and updates AuthorizationTaskExecutorIT.getEisEndpoints(ModelRegistry) to catch SearchPhaseExecutionException: on that exception it calls fail() and returns an empty list instead of allowing the exception to propagate, preserving behavior when used inside retry logic such as assertBusy.

🚥 Pre-merge checks | ✅ 1 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive PR directly addresses #144671 and #144731 by catching SearchPhaseExecutionException in getEisEndpoints() and converting to AssertionError for assertBusy retry logic, enabling test stabilization. PR mentions #144691 in description but changes only affect AuthorizationTaskExecutorIT tests, not RootFlattenedFromKeyedFieldDataTests. Clarify if #144691 is in scope or if PR description has incorrect issue reference.
✅ Passed checks (1 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed All changes are scoped to AuthorizationTaskExecutorIT test stability: removed muted test entries and added exception handling for shard initialization timing.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment on lines +232 to +240
try {
var endpoints = listener.actionGet(TimeValue.THIRTY_SECONDS);
return endpoints.stream().filter(m -> m.service().equals(ElasticInferenceService.NAME)).toList();
} catch (SearchPhaseExecutionException e) {
// This can happen if the internal inference indices shards have not been initialized yet.
// We fail so that when this is called in assertBusy we can retry.
fail();
return List.of();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This really makes me wish we were using JUnit 5 so we could use assertDoesNotThrow() here.

Copy link
Copy Markdown
Contributor

@Jan-Kazlouski-elastic Jan-Kazlouski-elastic 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 to me!

@dimitris-athanasiou dimitris-athanasiou merged commit 8a80908 into elastic:main Mar 26, 2026
36 checks passed
@dimitris-athanasiou dimitris-athanasiou deleted the handle-SPEE-in-AuthorizationTaskExecutorIT branch March 26, 2026 12:39
seanzatzdev pushed a commit to seanzatzdev/elasticsearch that referenced this pull request Mar 26, 2026
…cutorIT (elastic#144736)

Previous attempts at fixing this issue did not work because I was wrongly
assuming that `assertBusy` retried when any exception was thrown. However,
it only retries when an `AssertionError` is thrown.

The key method in the test that needs to wait for internal inference indices
to be created is `getEisEndpoints()`. This commit catches `SearchPhaseExecutionException`
and throws an `AssertionError` giving us a chance to retry this when `getEisEndpoints()`
is called from within an `assertBusy()`.

Closes elastic#144671
Closes elastic#144691
Closes elastic#144731
seanzatzdev pushed a commit to seanzatzdev/elasticsearch that referenced this pull request Mar 27, 2026
…cutorIT (elastic#144736)

Previous attempts at fixing this issue did not work because I was wrongly
assuming that `assertBusy` retried when any exception was thrown. However,
it only retries when an `AssertionError` is thrown.

The key method in the test that needs to wait for internal inference indices
to be created is `getEisEndpoints()`. This commit catches `SearchPhaseExecutionException`
and throws an `AssertionError` giving us a chance to retry this when `getEisEndpoints()`
is called from within an `assertBusy()`.

Closes elastic#144671
Closes elastic#144691
Closes elastic#144731
dimitris-athanasiou added a commit to dimitris-athanasiou/elasticsearch that referenced this pull request Mar 30, 2026
dimitris-athanasiou added a commit that referenced this pull request Mar 30, 2026
mamazzol pushed a commit to mamazzol/elasticsearch that referenced this pull request Mar 30, 2026
…cutorIT (elastic#144736)

Previous attempts at fixing this issue did not work because I was wrongly
assuming that `assertBusy` retried when any exception was thrown. However,
it only retries when an `AssertionError` is thrown.

The key method in the test that needs to wait for internal inference indices
to be created is `getEisEndpoints()`. This commit catches `SearchPhaseExecutionException`
and throws an `AssertionError` giving us a chance to retry this when `getEisEndpoints()`
is called from within an `assertBusy()`.

Closes elastic#144671
Closes elastic#144691
Closes elastic#144731
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:SearchOrg/Inference Label for the Search Inference team Team:Search - Inference >test Issues or PRs that are addressing/adding tests v9.4.0

Projects

None yet

4 participants