Skip to content

Commit 342266a

Browse files
[9.3] [AI Connector][Inference endpoint] Creation: adaptive allocations not set correctly on serverless (#251357) (#254585)
# Backport This will backport the following commits from `main` to `9.3`: - [[AI Connector][Inference endpoint] Creation: adaptive allocations not set correctly on serverless (#251357)](#251357) <!--- Backport version: 10.2.0 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Saikat Sarkar","email":"132922331+saikatsarkar056@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-02-23T19:04:49Z","message":"[AI Connector][Inference endpoint] Creation: adaptive allocations not set correctly on serverless (#251357)\n\n## Summary\n\nFixes AI Connector inference endpoint creation failing on serverless\nwhen using the 'elasticsearch' provider with adaptive allocations\nenabled.\n\nThe issue was that `num_threads` and `num_allocations` were being sent\nin the `providerConfig` alongside `adaptive_allocations`, which causes a\nconflict since these properties cannot be set when adaptive allocations\nis enabled.\n\nThis PR updates the form serializer to exclude `num_threads` and\n`num_allocations` from the payload when adaptive allocations is\nconfigured.\n\n\n\nhttps://github.com/user-attachments/assets/5d4b42ff-db33-4f3a-ab70-b32fcccbc445\n\n\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.\n\n### Identify risks\n\nDoes this PR introduce any risks? For example, consider risks like hard\nto test bugs, performance regression, potential of data loss.\n\nDescribe the risk, its severity, and mitigation for each identified\nrisk. Invite stakeholders and evaluate how to proceed before merging.\n\n- [ ] [See some risk\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)\n- [ ] ...\n\n\n### Release note\nFixes AI Connector creation on serverless failing when adaptive\nallocations is enabled with the ElasticSearch provider.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Melissa <melissa.alvarez@elastic.co>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"82dc85e41b82908e61c9afc0f9ab18dc4a734172","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Search","backport:version","v9.3.0","v9.4.0"],"title":"[AI Connector][Inference endpoint] Creation: adaptive allocations not set correctly on serverless","number":251357,"url":"https://github.com/elastic/kibana/pull/251357","mergeCommit":{"message":"[AI Connector][Inference endpoint] Creation: adaptive allocations not set correctly on serverless (#251357)\n\n## Summary\n\nFixes AI Connector inference endpoint creation failing on serverless\nwhen using the 'elasticsearch' provider with adaptive allocations\nenabled.\n\nThe issue was that `num_threads` and `num_allocations` were being sent\nin the `providerConfig` alongside `adaptive_allocations`, which causes a\nconflict since these properties cannot be set when adaptive allocations\nis enabled.\n\nThis PR updates the form serializer to exclude `num_threads` and\n`num_allocations` from the payload when adaptive allocations is\nconfigured.\n\n\n\nhttps://github.com/user-attachments/assets/5d4b42ff-db33-4f3a-ab70-b32fcccbc445\n\n\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.\n\n### Identify risks\n\nDoes this PR introduce any risks? For example, consider risks like hard\nto test bugs, performance regression, potential of data loss.\n\nDescribe the risk, its severity, and mitigation for each identified\nrisk. Invite stakeholders and evaluate how to proceed before merging.\n\n- [ ] [See some risk\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)\n- [ ] ...\n\n\n### Release note\nFixes AI Connector creation on serverless failing when adaptive\nallocations is enabled with the ElasticSearch provider.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Melissa <melissa.alvarez@elastic.co>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"82dc85e41b82908e61c9afc0f9ab18dc4a734172"}},"sourceBranch":"main","suggestedTargetBranches":["9.3"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/251357","number":251357,"mergeCommit":{"message":"[AI Connector][Inference endpoint] Creation: adaptive allocations not set correctly on serverless (#251357)\n\n## Summary\n\nFixes AI Connector inference endpoint creation failing on serverless\nwhen using the 'elasticsearch' provider with adaptive allocations\nenabled.\n\nThe issue was that `num_threads` and `num_allocations` were being sent\nin the `providerConfig` alongside `adaptive_allocations`, which causes a\nconflict since these properties cannot be set when adaptive allocations\nis enabled.\n\nThis PR updates the form serializer to exclude `num_threads` and\n`num_allocations` from the payload when adaptive allocations is\nconfigured.\n\n\n\nhttps://github.com/user-attachments/assets/5d4b42ff-db33-4f3a-ab70-b32fcccbc445\n\n\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.\n\n### Identify risks\n\nDoes this PR introduce any risks? For example, consider risks like hard\nto test bugs, performance regression, potential of data loss.\n\nDescribe the risk, its severity, and mitigation for each identified\nrisk. Invite stakeholders and evaluate how to proceed before merging.\n\n- [ ] [See some risk\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)\n- [ ] ...\n\n\n### Release note\nFixes AI Connector creation on serverless failing when adaptive\nallocations is enabled with the ElasticSearch provider.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Melissa <melissa.alvarez@elastic.co>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"82dc85e41b82908e61c9afc0f9ab18dc4a734172"}}]}] BACKPORT-->
1 parent 4d7123a commit 342266a

File tree

3 files changed

+67
-12
lines changed

3 files changed

+67
-12
lines changed

x-pack/platform/packages/shared/kbn-inference-endpoint-ui-common/src/components/inference_flyout_wrapper.test.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,38 @@ describe('InferenceFlyout', () => {
198198
renderComponent({ isEdit: true, inferenceEndpoint: mockEndpoint });
199199
expect(screen.getByTestId('num_allocations-number')).toBeEnabled();
200200
});
201+
202+
it('excludes num_allocations from update payload when adaptive allocations is enabled', async () => {
203+
const mockEndpoint = {
204+
config: {
205+
inferenceId: 'test-id',
206+
provider: 'elasticsearch',
207+
taskType: 'text_embedding',
208+
providerConfig: {
209+
model_id: '.elser_model_2',
210+
num_allocations: 1,
211+
'adaptive_allocations.max_number_of_allocations': 5,
212+
},
213+
},
214+
secrets: {
215+
providerSecrets: {},
216+
},
217+
};
218+
219+
renderComponent({
220+
isEdit: true,
221+
enforceAdaptiveAllocations: true,
222+
inferenceEndpoint: mockEndpoint,
223+
});
224+
225+
await userEvent.click(screen.getByTestId('inference-endpoint-submit-button'));
226+
227+
const submittedData = mockMutationFn.mock.calls[0][0];
228+
expect(submittedData.config.providerConfig.adaptive_allocations).toEqual({
229+
enabled: true,
230+
min_number_of_allocations: 0,
231+
max_number_of_allocations: 5,
232+
});
233+
expect(submittedData.config.providerConfig).not.toHaveProperty('num_allocations');
234+
});
201235
});

x-pack/platform/packages/shared/kbn-inference-endpoint-ui-common/src/components/inference_flyout_wrapper.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
EuiTitle,
1919
useGeneratedHtmlId,
2020
} from '@elastic/eui';
21+
import { omit } from 'lodash';
2122
import React, { useCallback } from 'react';
2223
import type { HttpSetup, IToasts } from '@kbn/core/public';
2324
import { Form, useForm } from '@kbn/es-ui-shared-plugin/static/forms/hook_form_lib';
@@ -29,25 +30,37 @@ import { useInferenceEndpointMutation } from '../hooks/use_inference_endpoint_mu
2930
const MIN_ALLOCATIONS = 0;
3031
const DEFAULT_NUM_THREADS = 1;
3132

33+
const ADAPTIVE_ALLOCATIONS_FLAT_KEYS = [
34+
'adaptive_allocations.max_number_of_allocations',
35+
'adaptive_allocations.enabled',
36+
'adaptive_allocations.min_number_of_allocations',
37+
];
38+
3239
const formDeserializer = (data: InferenceEndpoint) => {
33-
if (
40+
const maxAllocations =
3441
data.config?.providerConfig?.adaptive_allocations?.max_number_of_allocations ||
35-
data.config?.headers
36-
) {
42+
data.config?.providerConfig?.['adaptive_allocations.max_number_of_allocations'];
43+
44+
if (maxAllocations || data.config?.headers) {
3745
const { headers, ...restConfig } = data.config;
38-
const maxAllocations =
39-
data.config.providerConfig?.adaptive_allocations?.max_number_of_allocations;
46+
const restProviderConfig = omit(
47+
data.config.providerConfig || {},
48+
ADAPTIVE_ALLOCATIONS_FLAT_KEYS
49+
);
4050

4151
return {
4252
...data,
4353
config: {
4454
...restConfig,
4555
providerConfig: {
46-
...(data.config.providerConfig as InferenceEndpoint['config']['providerConfig']),
56+
...restProviderConfig,
4757
...(headers ? { headers } : {}),
4858
...(maxAllocations
4959
? // remove the adaptive_allocations from the data config as form does not expect it
50-
{ max_number_of_allocations: maxAllocations, adaptive_allocations: undefined }
60+
{
61+
max_number_of_allocations: maxAllocations as number,
62+
adaptive_allocations: undefined,
63+
}
5164
: {}),
5265
},
5366
},
@@ -66,6 +79,7 @@ export const formSerializer = (formData: InferenceEndpoint) => {
6679
const {
6780
max_number_of_allocations: maxAllocations,
6881
headers,
82+
num_allocations: numAllocations,
6983
...restProviderConfig
7084
} = providerConfig || {};
7185

@@ -85,7 +99,7 @@ export const formSerializer = (formData: InferenceEndpoint) => {
8599
// Temporary solution until the endpoint is updated to no longer require it and to set its own default for this value
86100
num_threads: DEFAULT_NUM_THREADS,
87101
}
88-
: {}),
102+
: { ...(numAllocations != null && { num_allocations: numAllocations }) }),
89103
},
90104
...(headers ? { headers } : {}),
91105
},

x-pack/platform/plugins/shared/inference_endpoint/server/routes/index.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,22 @@ export const getInferenceServicesRoute = (
228228

229229
const taskSettings = config?.headers ? { headers: config.headers } : undefined;
230230

231-
// currently update api only allows api_key and num_allocations
231+
const adaptiveAllocations = config?.providerConfig?.adaptive_allocations;
232+
const numAllocations = config?.providerConfig?.num_allocations;
233+
234+
let allocationSettings = {};
235+
if (adaptiveAllocations) {
236+
allocationSettings = { adaptive_allocations: adaptiveAllocations };
237+
} else if (numAllocations) {
238+
allocationSettings = { num_allocations: numAllocations };
239+
}
240+
232241
const body = {
233242
service_settings: {
234243
...(secrets?.providerSecrets?.api_key && {
235244
api_key: secrets.providerSecrets.api_key,
236245
}),
237-
...(config?.providerConfig?.num_allocations !== undefined && {
238-
num_allocations: config.providerConfig.num_allocations,
239-
}),
246+
...allocationSettings,
240247
},
241248
...(taskSettings ? { task_settings: taskSettings } : {}),
242249
};

0 commit comments

Comments
 (0)