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

Polling mechanism, getBuildStatus #1

Closed
wants to merge 3 commits into from

Conversation

owenhalpert
Copy link
Owner

Description

This PR is a followup to 2560. This PR adds the polling mechanism for the client to poll the server.

This PR does not include:

  • Metric collection

which will go in the next PR.

Related Issues

opensearch-project#2560
opensearch-project#2391

Check List

  • New functionality includes testing.
    - [ ] New functionality has been documented.
    - [ ] API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
    - [ ] Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Comment on lines 142 to 163
while (System.currentTimeMillis() - startTime < timeout) {
RemoteBuildStatusResponse remoteBuildStatusResponse = getBuildStatus(remoteBuildResponse.getJobId());
String taskStatus = remoteBuildStatusResponse.getTaskStatus();
switch (taskStatus) {
case COMPLETED_INDEX_BUILD:
return remoteBuildStatusResponse;
case FAILED_INDEX_BUILD:
String errorMessage = remoteBuildStatusResponse.getErrorMessage();
if (errorMessage != null) {
throw new InterruptedException("Index build failed: " + errorMessage);
}
throw new InterruptedException("Index build failed without an error message.");
case RUNNING_INDEX_BUILD:
Thread.sleep(pollInterval);
}
}

Choose a reason for hiding this comment

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

this logic should be outside of the RemoteIndexHTTPClient.

Copy link

Choose a reason for hiding this comment

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

+1, I think the polling implementation should be done in either RemoteIndexBuildStrategy or even as a separate poller class implementation.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Should the client interface method be getStatus then?

String taskStatus = remoteBuildStatusResponse.getTaskStatus();
switch (taskStatus) {
case COMPLETED_INDEX_BUILD:
return remoteBuildStatusResponse;
Copy link

Choose a reason for hiding this comment

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

I think we should do some basic path validation somewhere

Copy link
Owner Author

@owenhalpert owenhalpert Mar 3, 2025

Choose a reason for hiding this comment

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

Maybe this should happen in readFromRepository? Since this may be different per repo?

Copy link

Choose a reason for hiding this comment

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

From the repository perspective this is already well-defined. The Repository takes a BlobPath object to return a BlobContainer, and then the BlobContainer takes a file name in readBlob, and none of this is repository specific. I'm more worried about this path being different per remote index build service.

Currently readFromRepository assumes that the input path is a / delimited filepath, but that would ultimately depend on whatever this status response is returning. I think ideally readFromRepository is not even responsible for converting from a String path to a BlobPath + String fileName.

I don't think it would be a bad idea to perform some basic output validation from within the client itself (this would be sort of analogous to how the S3 SDK can be configured to do all the checksum validations for you)

@owenhalpert owenhalpert force-pushed the vector-client-polling branch from 41852e4 to 6a8b40b Compare March 3, 2025 21:51
@owenhalpert owenhalpert force-pushed the vector-client-skeleton branch 5 times, most recently from 53d8b7a to 1dc54cd Compare March 4, 2025 05:46
@owenhalpert owenhalpert force-pushed the vector-client-polling branch 3 times, most recently from c651104 to fd3002f Compare March 4, 2025 06:04
@owenhalpert owenhalpert force-pushed the vector-client-skeleton branch 2 times, most recently from 6db364c to 75b1afa Compare March 4, 2025 06:42
Add RemoteIndexClient initial implementation, its accompanying dependencies, and Build Request, Retry Strategy, and test files

Signed-off-by: owenhalpert <ohalpert@gmail.com>

# Conflicts:
#	CHANGELOG.md
#	src/main/java/org/opensearch/knn/index/KNNSettings.java
#	src/main/java/org/opensearch/knn/index/codec/nativeindex/NativeIndexBuildStrategyFactory.java
#	src/main/java/org/opensearch/knn/index/codec/nativeindex/remote/RemoteIndexBuildStrategy.java
#	src/test/java/org/opensearch/knn/index/codec/nativeindex/remote/RemoteIndexBuildStrategyTests.java

# Conflicts:
#	CHANGELOG.md
#	src/main/java/org/opensearch/knn/index/codec/nativeindex/remote/RemoteIndexBuildStrategy.java

# Conflicts:
#	CHANGELOG.md
#	build.gradle
#	src/main/java/org/opensearch/knn/index/KNNSettings.java
#	src/main/java/org/opensearch/knn/index/codec/nativeindex/remote/RemoteIndexBuildStrategy.java
#	src/main/java/org/opensearch/knn/index/remote/RemoteBuildRequest.java
#	src/main/java/org/opensearch/knn/index/remote/RemoteIndexClient.java
Signed-off-by: owenhalpert <ohalpert@gmail.com>
@owenhalpert owenhalpert force-pushed the vector-client-polling branch 3 times, most recently from 16df7e9 to ece9f7b Compare March 4, 2025 07:29
Pull polling logic out to generic RemoteIndexPoller class (that can use any client), add tests

Signed-off-by: owenhalpert <ohalpert@gmail.com>
@owenhalpert owenhalpert force-pushed the vector-client-polling branch from ece9f7b to 75ae2bd Compare March 4, 2025 07:41
@owenhalpert owenhalpert changed the base branch from vector-client-skeleton to main March 4, 2025 16:31
@owenhalpert owenhalpert changed the base branch from main to vector-client-skeleton March 4, 2025 16:31
@owenhalpert owenhalpert closed this Mar 5, 2025
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