Skip to content

Fix get all inference endponts not returning multiple endpoints sharing model deployment #121821

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

dan-rubinstein
Copy link
Member

@dan-rubinstein dan-rubinstein commented Feb 5, 2025

Description

Issue - https://github.com/elastic/ml-team/issues/1470?reload=1?reload=1

We currently have a bug when calling the get all inference endpoints API that only returns a single endpoint for each model deployment. This is happening because after we retrieve all the endpoints from the inference index, we call the deployment stats API to accurately return the current num_allocations but in doing so, we accidentally filter out all but the last retrieve inference endpoint for each model deployment. This change updates the logic to properly handle multiple endpoints for a single model deployment.

Testing

  • Unit tests
  • Locally tested by creating multiple endpoints for a single model deployment and ensuring that both endpoints are returned. Also confirmed that updating a single endpoints num_allocations will reflect in all endpoints sharing the same model deployment when calling to get all inference endpoints.

@dan-rubinstein dan-rubinstein added >bug :ml Machine learning Team:ML Meta label for the ML team v9.0.0 v8.19.0 v9.1.0 labels Feb 5, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @dan-rubinstein, I've created a changelog YAML for you.

@dan-rubinstein dan-rubinstein marked this pull request as ready for review February 6, 2025 15:46
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)

@jonathan-buttner
Copy link
Contributor

Hey Dan 👋 do you want this change to go to 8.18.0? I see it's labeled for 9.0.0. 8.18 and 9.0 are being released together so if we're targeting one we should probably do both.

for (var model : models) {
assert model instanceof ElasticsearchInternalModel;

if (model instanceof ElasticsearchInternalModel esModel) {
modelsByDeploymentIds.put(esModel.mlNodeDeploymentId(), esModel);
if (modelsByDeploymentIds.containsKey(esModel.mlNodeDeploymentId()) == false) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think the if-else can be distilled to something like this:

modelsByDeploymentIds.merge(
  esModel.mlNodeDeploymentId(),
  new ArrayList<String>(List.of(esModel)), (a, b) -> {
    a.addAll(b);
    return a;
});

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice, I like this method much better! I'll go ahead and make that change.

@dan-rubinstein dan-rubinstein added v8.18.0 auto-backport Automatically create backport pull requests when merged labels Feb 6, 2025
@dan-rubinstein
Copy link
Member Author

@elasticmachine merge upstream

@dan-rubinstein dan-rubinstein merged commit 3810864 into elastic:main Feb 10, 2025
17 checks passed
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

The backport operation could not be completed due to the following error:

An unexpected error occurred when attempting to backport this PR.

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 121821

dan-rubinstein added a commit to dan-rubinstein/elasticsearch that referenced this pull request Feb 10, 2025
…ng model deployment (elastic#121821)

* Fix get all inference endponts not returning multiple endpoints sharing model deployment

* Update docs/changelog/121821.yaml

* Clean up modelsByDeploymentId generation code

---------

Co-authored-by: Elastic Machine <[email protected]>
dan-rubinstein added a commit to dan-rubinstein/elasticsearch that referenced this pull request Feb 10, 2025
…ng model deployment (elastic#121821)

* Fix get all inference endponts not returning multiple endpoints sharing model deployment

* Update docs/changelog/121821.yaml

* Clean up modelsByDeploymentId generation code

---------

Co-authored-by: Elastic Machine <[email protected]>
dan-rubinstein added a commit to dan-rubinstein/elasticsearch that referenced this pull request Feb 10, 2025
…ng model deployment (elastic#121821)

* Fix get all inference endponts not returning multiple endpoints sharing model deployment

* Update docs/changelog/121821.yaml

* Clean up modelsByDeploymentId generation code

---------

Co-authored-by: Elastic Machine <[email protected]>
elasticsearchmachine pushed a commit that referenced this pull request Feb 10, 2025
…ng model deployment (#121821) (#122206)

* Fix get all inference endponts not returning multiple endpoints sharing model deployment

* Update docs/changelog/121821.yaml

* Clean up modelsByDeploymentId generation code

---------

Co-authored-by: Elastic Machine <[email protected]>
elasticsearchmachine pushed a commit that referenced this pull request Feb 10, 2025
…ng model deployment (#121821) (#122210)

* Fix get all inference endponts not returning multiple endpoints sharing model deployment

* Update docs/changelog/121821.yaml

* Clean up modelsByDeploymentId generation code

---------

Co-authored-by: Elastic Machine <[email protected]>
elasticsearchmachine pushed a commit that referenced this pull request Feb 11, 2025
…ng model deployment (#121821) (#122208)

* Fix get all inference endponts not returning multiple endpoints sharing model deployment

* Update docs/changelog/121821.yaml

* Clean up modelsByDeploymentId generation code

---------

Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Joe Gallo <[email protected]>
@dan-rubinstein dan-rubinstein deleted the inference-multiple-endpoints-for-deployment branch February 11, 2025 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged backport pending >bug :ml Machine learning Team:ML Meta label for the ML team v8.18.0 v8.18.1 v8.19.0 v9.0.0 v9.0.1 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants