-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Obs AI Assistant] Distributed lock manager #216397
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
[Obs AI Assistant] Distributed lock manager #216397
Conversation
e380b47 to
a93e84b
Compare
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#8120[✅] x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts: 50/50 tests passed. |
...m/plugins/shared/observability_ai_assistant/server/service/distributed_lock_manager/index.ts
Outdated
Show resolved
Hide resolved
...m/plugins/shared/observability_ai_assistant/server/service/distributed_lock_manager/index.ts
Outdated
Show resolved
Hide resolved
...m/plugins/shared/observability_ai_assistant/server/service/distributed_lock_manager/index.ts
Outdated
Show resolved
Hide resolved
...m/plugins/shared/observability_ai_assistant/server/service/distributed_lock_manager/index.ts
Outdated
Show resolved
Hide resolved
...ic/apis/observability/ai_assistant/distributed_lock_manager/distributed_lock_manager.spec.ts
Outdated
Show resolved
Hide resolved
...m/plugins/shared/observability_ai_assistant/server/service/distributed_lock_manager/index.ts
Outdated
Show resolved
Hide resolved
...m/plugins/shared/observability_ai_assistant/server/service/distributed_lock_manager/index.ts
Outdated
Show resolved
Hide resolved
...m/plugins/shared/observability_ai_assistant/server/service/distributed_lock_manager/index.ts
Show resolved
Hide resolved
...m/plugins/shared/observability_ai_assistant/server/service/distributed_lock_manager/index.ts
Outdated
Show resolved
Hide resolved
...m/plugins/shared/observability_ai_assistant/server/service/distributed_lock_manager/index.ts
Outdated
Show resolved
Hide resolved
...m/plugins/shared/observability_ai_assistant/server/service/distributed_lock_manager/index.ts
Outdated
Show resolved
Hide resolved
...m/plugins/shared/observability_ai_assistant/server/service/distributed_lock_manager/index.ts
Outdated
Show resolved
Hide resolved
...m/plugins/shared/observability_ai_assistant/server/service/distributed_lock_manager/index.ts
Show resolved
Hide resolved
...m/plugins/shared/observability_ai_assistant/server/service/distributed_lock_manager/index.ts
Outdated
Show resolved
Hide resolved
...m/plugins/shared/observability_ai_assistant/server/service/distributed_lock_manager/index.ts
Show resolved
Hide resolved
...m/plugins/shared/observability_ai_assistant/server/service/distributed_lock_manager/index.ts
Outdated
Show resolved
Hide resolved
...ic/apis/observability/ai_assistant/distributed_lock_manager/distributed_lock_manager.spec.ts
Show resolved
Hide resolved
|
Pinging @elastic/obs-ai-assistant (Team:Obs AI Assistant) |
...ed/observability_ai_assistant/server/service/distributed_lock_manager/lock_manager_client.ts
Show resolved
Hide resolved
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
Flaky Test Runner Stats🟠 Some tests failed. - kibana-flaky-test-suite-runner#8128[❌] x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts: 0/50 tests passed. |
Flaky Test Runner Stats🟠 Some tests failed. - kibana-flaky-test-suite-runner#8139[❌] x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts: 71/100 tests passed. |
Tests added in #216397 are failing on MKI. Skipping temporarily in the affected environment ### Error ``` └- ✖ fail: Serverless Observability - Deployment-agnostic API integration tests observability AI Assistant LockManager Basic lock operations acquires the lock when not held │ ResponseError: security_exception │ Root causes: │ security_exception: action [indices:admin/create] is unauthorized for user [testing-internal] with effective roles [superuser] on restricted indices [.kibana_locks-000001], this action is granted by the index privileges [create_index,manage,all] ``` ### Root cause ```ts const es = getService('es'); es.deleteByQuery({ index: '.kibana_locks-000001', query: { match_all: {} }}); ```
# Backport This will backport the following commits from `main` to `8.x`: - [[Obs AI Assistant] Distributed lock manager (#216397)](#216397) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Søren Louv-Jansen","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-04-01T22:26:00Z","message":"[Obs AI Assistant] Distributed lock manager (#216397)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/238\n\n\nThis introduces a lightweight library for managing distributed locks\nusing Elasticsearch. It lets developers coordinate operations across\nmultiple Kibana instances by ensuring that only one client holds a given\nlock at a time. The library uses an Elasticsearch index with TTL-based\nlocks.\n\nUsage:\n\n```ts\nconst lockManagerService = new LockManagerService(coreSetup, logger);\nlockManagerService.withLock('my_lock', () => {\n // perform operation\n});\n```","sha":"f4980d0fa3f90e8f3fddf5b3eb50102158d9ef80","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Obs AI Assistant","backport:version","v9.1.0","v8.19.0"],"title":"[Obs AI Assistant] Distributed lock manager","number":216397,"url":"https://github.com/elastic/kibana/pull/216397","mergeCommit":{"message":"[Obs AI Assistant] Distributed lock manager (#216397)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/238\n\n\nThis introduces a lightweight library for managing distributed locks\nusing Elasticsearch. It lets developers coordinate operations across\nmultiple Kibana instances by ensuring that only one client holds a given\nlock at a time. The library uses an Elasticsearch index with TTL-based\nlocks.\n\nUsage:\n\n```ts\nconst lockManagerService = new LockManagerService(coreSetup, logger);\nlockManagerService.withLock('my_lock', () => {\n // perform operation\n});\n```","sha":"f4980d0fa3f90e8f3fddf5b3eb50102158d9ef80"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/216397","number":216397,"mergeCommit":{"message":"[Obs AI Assistant] Distributed lock manager (#216397)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/238\n\n\nThis introduces a lightweight library for managing distributed locks\nusing Elasticsearch. It lets developers coordinate operations across\nmultiple Kibana instances by ensuring that only one client holds a given\nlock at a time. The library uses an Elasticsearch index with TTL-based\nlocks.\n\nUsage:\n\n```ts\nconst lockManagerService = new LockManagerService(coreSetup, logger);\nlockManagerService.withLock('my_lock', () => {\n // perform operation\n});\n```","sha":"f4980d0fa3f90e8f3fddf5b3eb50102158d9ef80"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Søren Louv-Jansen <[email protected]>
Related to #216397 Closes #216763 This change ensures that we do not send the `release` request and `extendTtl` request simultaneously in `withLock`. This caused a conflict causing tests to fail: ``` └-> "before all" hook for "should return the result of the callback" │ERROR Failed to release lock "my_lock_with_ttl_extension": version_conflict_engine_exception │ Root causes: │ version_conflict_engine_exception: [my_lock_with_ttl_extension]: version conflict, required seqNo [43], primary term [1]. current document has seqNo [44] and primary term [1] ``` Flaky tests: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/8142
Related to elastic#216397 Closes elastic#216763 This change ensures that we do not send the `release` request and `extendTtl` request simultaneously in `withLock`. This caused a conflict causing tests to fail: ``` └-> "before all" hook for "should return the result of the callback" │ERROR Failed to release lock "my_lock_with_ttl_extension": version_conflict_engine_exception │ Root causes: │ version_conflict_engine_exception: [my_lock_with_ttl_extension]: version conflict, required seqNo [43], primary term [1]. current document has seqNo [44] and primary term [1] ``` Flaky tests: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/8142 (cherry picked from commit 7275d2e)
) This PR replaces usage of the Kibana Task Manager with the [LockManager utility](#216397) that ensures strict mutual exclusion when running operations such as re-indexing or data migrations. --------- Co-authored-by: Viduni Wickramarachchi <[email protected]> Co-authored-by: kibanamachine <[email protected]>
### Background This PR is a proposal for a different way to structure the Streams code flow based on some challenges faced while working on elastic/streams-program#26 and discussed [here](elastic/streams-program#147) and [here](elastic/streams-program#55), mainly around finding it difficult to decide where to place certain validations that need access to the state as a whole. It is also in response to some expressed difficulty about how to add new stream types into the code base. It aims to achieve 3 goals: 1. It is easy to add new stream types and there is a clear place where changes (new validation, new logic) for existing stream types happen, making the code easier to evolve over time 2. It is easier to improve the robustness of the system because there are clear phases where problems can be caught, fixed and rolled back 3. It lays some ground work for features such as [bulk changes](elastic/streams-program#125), [dry runs](elastic/streams-program#138) and a [health endpoint](elastic/streams-program#139) In the future, this will most likely be handled by Elasticsearch to a large degree, as imagined in elastic/streams-program#30 The solution takes inspiration from the reconciliation / controller pattern that Kubernetes uses, where users specify a desired state and the system takes action towards reaching that step. But it is also somewhat more similar to how React's Virtual DOM works in that it happens in a single iteration. Another key pattern is the [Active Record pattern](https://www.martinfowler.com/eaaCatalog/activeRecord.html), we let each stream class contain all the logic for how to validate and modify that stream in Elasticsearch. The client and `State` class simply orchestrate the flow but defer all actual work and decision making to the stream classes. **Note:** This PoC ignores the management of assets ### Summary The process takes the following steps: 1. A route accepts a request (upsert / delete) and translates it into one or more (for bulk) `StreamChange` objects before passing these to `State.applyChanges` method (which also takes a toggle for dry runs) 2. The current state of Streams is loaded by using the `State` class 3. The changes are then applied to the current state to derive the desired state [1] 4. The desired state is then validated, this is done by asking each individual stream if given the desired state and starting state, from the perspective of that individual stream, is it in a valid state (upserted or deleted correctly) 5. If the state is invalid, we return those errors and stop 6. Else we continue, if it's a dry run, we ask the desired state object for what has changed and report that in the shape of the Elasticsearch actions that would be attempted 7. Else we proceed to commit the changes to Elasticsearch by asking each changed stream to determine which Elasticsearch actions need to be performed to reach the desired state 8. These actions are then combined and sent to the `ExecutionPlan` class which does planning (mainly for actions around Unwired streams) and then handles executing the actions in the most parallel way but in the safe order 9. If any error happens, we attempt to revert back to the starting state by taking the changed streams and marking each stream as created based on the starting state and then getting the Elasticsearch actions for that and applying those This PR also changes our `resync` endpoint to make use of the same rough strategy (load current state, mark all as created, get Elasticsearch actions and apply). [1] Applying changes: 1. The current state is first cloned 2. Then for each change we see if it is a deletion or an upsert 3. Based on this we either mark existing streams for deletion or create/update existing streams 10. When creating a new stream instance we use the helper `streamFromDefinition` which is the only mapping between the definition documents and the Active Record-style stream type classes 11. As part of this, each stream that changes is marked in the desired state 12. The stream is passed the desired and current state and should update itself based on the change 13. The stream can return a set of cascading changes (taking the same format as the requested changes) which are executed directly after but we have a limit for how many rounds of cascading changes can happen to avoid infinite loops ### Adding new stream types Key in all of this is that the client and `State` classes don't know anything about any of the specific stream types, they know only of the `StreamActiveRecord` interface. When adding a new stream type you need to implement this interface and update `streamFromDefinition` to create the right class for your new definition. Streams of different types should only interact with each other by creating cascading changes. ### Possible follow up tasks - Introduce a lazy Elasticsearch cluster state cache because multiple places in the code access the same stuff over and over again - Make API endpoints the consume `attemptChanges` pass back the `DesiredState` and planned `ElasticsearchActions` as debug information based on a flag (maybe also all cascading changes) - Don't run cascading changes by default but run them if _some_ flag is submitted based on elastic/streams-program#230 - Wrap `attemptChanges` and `resync` with the new LockManager #216397 - Unit test WiredStream, UnwiredStream and GroupStream - Clean up old sync helpers - Wrap ES calls to get better stack traces for errors ### Out of scope - Asset linking and content pack installation (it's probably okay for these to continue to use the asset client directly since there is less domain logic and no cascading changes involved) --------- Co-authored-by: Joe Reuter <[email protected]> Co-authored-by: kibanamachine <[email protected]>
Closes: #218944 The index template for the Lock Manager was not created, causing index mappings and settings to be incorrect. Root cause: the function responsible for creating the index template (`ensureTemplatesAndIndexCreated`) was never invoked - only during automated testing 🤦 ## Manual testing steps The mappings for the lock manager index (`.kibana_locks-000001`) should match this: ```ts { mappings: { dynamic: false, properties: { token: { type: 'keyword' }, metadata: { enabled: false }, createdAt: { type: 'date' }, expiresAt: { type: 'date' }, }, }, } ``` ### Test 1 In this test we make sure that the LockManager library can recover and fix the mappings if the existing index has invalid mappings #### Delete existing assets if they already exist ``` DELETE .kibana_locks-000001 DELETE _index_template/.kibana_locks-index-template DELETE _component_template/.kibana_locks-component ``` #### Create lock index. This is invalid because it does not have the correct mappings ``` PUT .kibana_locks-000001 ``` (Restart Kibana) #### Check mappings are correct ``` GET .kibana_locks-000001/_mapping ``` ### Test 2 In this test we make sure that out of the box, the LockManager library creates an index with the correct mappings ``` DELETE .kibana_locks-000001 DELETE _index_template/.kibana_locks-index-template DELETE _component_template/.kibana_locks-component ``` (Restart Kibana) #### Check mappings are correct ``` GET .kibana_locks-000001/_mapping ``` Related: #216916 #216397 --------- Co-authored-by: Viduni Wickramarachchi <[email protected]>
Tests added in elastic#216397 are failing on MKI. Skipping temporarily in the affected environment ### Error ``` └- ✖ fail: Serverless Observability - Deployment-agnostic API integration tests observability AI Assistant LockManager Basic lock operations acquires the lock when not held │ ResponseError: security_exception │ Root causes: │ security_exception: action [indices:admin/create] is unauthorized for user [testing-internal] with effective roles [superuser] on restricted indices [.kibana_locks-000001], this action is granted by the index privileges [create_index,manage,all] ``` ### Root cause ```ts const es = getService('es'); es.deleteByQuery({ index: '.kibana_locks-000001', query: { match_all: {} }}); ``` (cherry picked from commit 8bcce2e)
Closes: elastic#218944 The index template for the Lock Manager was not created, causing index mappings and settings to be incorrect. Root cause: the function responsible for creating the index template (`ensureTemplatesAndIndexCreated`) was never invoked - only during automated testing 🤦 The mappings for the lock manager index (`.kibana_locks-000001`) should match this: ```ts { mappings: { dynamic: false, properties: { token: { type: 'keyword' }, metadata: { enabled: false }, createdAt: { type: 'date' }, expiresAt: { type: 'date' }, }, }, } ``` In this test we make sure that the LockManager library can recover and fix the mappings if the existing index has invalid mappings ``` DELETE .kibana_locks-000001 DELETE _index_template/.kibana_locks-index-template DELETE _component_template/.kibana_locks-component ``` correct mappings ``` PUT .kibana_locks-000001 ``` (Restart Kibana) ``` GET .kibana_locks-000001/_mapping ``` In this test we make sure that out of the box, the LockManager library creates an index with the correct mappings ``` DELETE .kibana_locks-000001 DELETE _index_template/.kibana_locks-index-template DELETE _component_template/.kibana_locks-component ``` (Restart Kibana) ``` GET .kibana_locks-000001/_mapping ``` Related: elastic#216916 elastic#216397 --------- Co-authored-by: Viduni Wickramarachchi <[email protected]> (cherry picked from commit f684ea4)
Closes: elastic#218944 The index template for the Lock Manager was not created, causing index mappings and settings to be incorrect. Root cause: the function responsible for creating the index template (`ensureTemplatesAndIndexCreated`) was never invoked - only during automated testing 🤦 The mappings for the lock manager index (`.kibana_locks-000001`) should match this: ```ts { mappings: { dynamic: false, properties: { token: { type: 'keyword' }, metadata: { enabled: false }, createdAt: { type: 'date' }, expiresAt: { type: 'date' }, }, }, } ``` In this test we make sure that the LockManager library can recover and fix the mappings if the existing index has invalid mappings ``` DELETE .kibana_locks-000001 DELETE _index_template/.kibana_locks-index-template DELETE _component_template/.kibana_locks-component ``` correct mappings ``` PUT .kibana_locks-000001 ``` (Restart Kibana) ``` GET .kibana_locks-000001/_mapping ``` In this test we make sure that out of the box, the LockManager library creates an index with the correct mappings ``` DELETE .kibana_locks-000001 DELETE _index_template/.kibana_locks-index-template DELETE _component_template/.kibana_locks-component ``` (Restart Kibana) ``` GET .kibana_locks-000001/_mapping ``` Related: elastic#216916 elastic#216397 --------- Co-authored-by: Viduni Wickramarachchi <[email protected]> (cherry picked from commit f684ea4)
# Backport This will backport the following commits from `main` to `8.19`: - [[Obs AI Assistant] Skip lock tests in MKI temporarily (#216753)](#216753) - [[Obs AI Assistant] Replace Task Manager usage with Lock Manager (#216916)](#216916) - [[LockManager] Ensure index template are created (#218901)](#218901) - [[LockManager] Expose as package (#219220)](#219220) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Søren Louv-Jansen","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-04-02T09:28:35Z","message":"[Obs AI Assistant] Skip lock tests in MKI temporarily (#216753)\n\nTests added in #216397 are failing\non MKI. Skipping temporarily in the affected environment\n\n### Error\n\n```\n └- ✖ fail: Serverless Observability - Deployment-agnostic API integration tests observability AI Assistant LockManager Basic lock operations acquires the lock when not held\n │ ResponseError: security_exception\n │ \tRoot causes:\n │ \t\tsecurity_exception: action [indices:admin/create] is unauthorized for user [testing-internal] with effective roles [superuser] on restricted indices [.kibana_locks-000001], this action is granted by the index privileges [create_index,manage,all]\n```\n\n### Root cause\n```ts\nconst es = getService('es');\nes.deleteByQuery({ index: '.kibana_locks-000001', query: { match_all: {} }});\n```","sha":"8bcce2e89b6be758d144b9b802eb9d2a09dd62cf","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:skip","v9.1.0","v8.19.0"],"title":"[Obs AI Assistant] Skip lock tests in MKI temporarily","number":216753,"url":"https://github.com/elastic/kibana/pull/216753","mergeCommit":{"message":"[Obs AI Assistant] Skip lock tests in MKI temporarily (#216753)\n\nTests added in #216397 are failing\non MKI. Skipping temporarily in the affected environment\n\n### Error\n\n```\n └- ✖ fail: Serverless Observability - Deployment-agnostic API integration tests observability AI Assistant LockManager Basic lock operations acquires the lock when not held\n │ ResponseError: security_exception\n │ \tRoot causes:\n │ \t\tsecurity_exception: action [indices:admin/create] is unauthorized for user [testing-internal] with effective roles [superuser] on restricted indices [.kibana_locks-000001], this action is granted by the index privileges [create_index,manage,all]\n```\n\n### Root cause\n```ts\nconst es = getService('es');\nes.deleteByQuery({ index: '.kibana_locks-000001', query: { match_all: {} }});\n```","sha":"8bcce2e89b6be758d144b9b802eb9d2a09dd62cf"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/216753","number":216753,"mergeCommit":{"message":"[Obs AI Assistant] Skip lock tests in MKI temporarily (#216753)\n\nTests added in #216397 are failing\non MKI. Skipping temporarily in the affected environment\n\n### Error\n\n```\n └- ✖ fail: Serverless Observability - Deployment-agnostic API integration tests observability AI Assistant LockManager Basic lock operations acquires the lock when not held\n │ ResponseError: security_exception\n │ \tRoot causes:\n │ \t\tsecurity_exception: action [indices:admin/create] is unauthorized for user [testing-internal] with effective roles [superuser] on restricted indices [.kibana_locks-000001], this action is granted by the index privileges [create_index,manage,all]\n```\n\n### Root cause\n```ts\nconst es = getService('es');\nes.deleteByQuery({ index: '.kibana_locks-000001', query: { match_all: {} }});\n```","sha":"8bcce2e89b6be758d144b9b802eb9d2a09dd62cf"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]},{"author":{"name":"Søren Louv-Jansen","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-04-08T08:13:00Z","message":"[Obs AI Assistant] Replace Task Manager usage with Lock Manager (#216916)\n\nThis PR replaces usage of the Kibana Task Manager with the [LockManager\nutility](#216397) that ensures\nstrict mutual exclusion when running operations such as re-indexing or\ndata migrations.\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <[email protected]>\nCo-authored-by: kibanamachine <[email protected]>","sha":"624410524f1a07dc72d92759464a3f4a85466c7a","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:skip","Team:Obs AI Assistant","v9.1.0"],"title":"[Obs AI Assistant] Replace Task Manager usage with Lock Manager","number":216916,"url":"https://github.com/elastic/kibana/pull/216916","mergeCommit":{"message":"[Obs AI Assistant] Replace Task Manager usage with Lock Manager (#216916)\n\nThis PR replaces usage of the Kibana Task Manager with the [LockManager\nutility](#216397) that ensures\nstrict mutual exclusion when running operations such as re-indexing or\ndata migrations.\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <[email protected]>\nCo-authored-by: kibanamachine <[email protected]>","sha":"624410524f1a07dc72d92759464a3f4a85466c7a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/216916","number":216916,"mergeCommit":{"message":"[Obs AI Assistant] Replace Task Manager usage with Lock Manager (#216916)\n\nThis PR replaces usage of the Kibana Task Manager with the [LockManager\nutility](#216397) that ensures\nstrict mutual exclusion when running operations such as re-indexing or\ndata migrations.\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <[email protected]>\nCo-authored-by: kibanamachine <[email protected]>","sha":"624410524f1a07dc72d92759464a3f4a85466c7a"}}]},{"author":{"name":"Søren Louv-Jansen","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-04-23T23:34:28Z","message":"[LockManager] Ensure index template are created (#218901)\n\nCloses: https://github.com/elastic/kibana/issues/218944\n\nThe index template for the Lock Manager was not created, causing index\nmappings and settings to be incorrect.\nRoot cause: the function responsible for creating the index template\n(`ensureTemplatesAndIndexCreated`) was never invoked - only during\nautomated testing 🤦\n\n## Manual testing steps\n\nThe mappings for the lock manager index (`.kibana_locks-000001`) should\nmatch this:\n```ts\n {\n mappings: {\n dynamic: false,\n properties: {\n token: { type: 'keyword' },\n metadata: { enabled: false },\n createdAt: { type: 'date' },\n expiresAt: { type: 'date' },\n },\n },\n}\n```\n\n### Test 1\n\nIn this test we make sure that the LockManager library can recover and\nfix the mappings if the existing index has invalid mappings\n\n#### Delete existing assets if they already exist\n```\nDELETE .kibana_locks-000001\nDELETE _index_template/.kibana_locks-index-template\nDELETE _component_template/.kibana_locks-component\n```\n\n#### Create lock index. This is invalid because it does not have the\ncorrect mappings\n```\nPUT .kibana_locks-000001\n```\n\n(Restart Kibana)\n\n#### Check mappings are correct\n```\nGET .kibana_locks-000001/_mapping\n```\n\n### Test 2\n\nIn this test we make sure that out of the box, the LockManager library\ncreates an index with the correct mappings\n\n```\nDELETE .kibana_locks-000001\nDELETE _index_template/.kibana_locks-index-template\nDELETE _component_template/.kibana_locks-component\n```\n\n(Restart Kibana)\n\n#### Check mappings are correct\n```\nGET .kibana_locks-000001/_mapping\n```\n\nRelated: https://github.com/elastic/kibana/pull/216916\nhttps://github.com/elastic/kibana/pull/216397\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <[email protected]>","sha":"f684ea4071dfb5e6acc4cb057b46acbf915943d7","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:skip","Team:Obs AI Assistant","ci:project-deploy-observability","v9.1.0"],"title":"[LockManager] Ensure index template are created","number":218901,"url":"https://github.com/elastic/kibana/pull/218901","mergeCommit":{"message":"[LockManager] Ensure index template are created (#218901)\n\nCloses: https://github.com/elastic/kibana/issues/218944\n\nThe index template for the Lock Manager was not created, causing index\nmappings and settings to be incorrect.\nRoot cause: the function responsible for creating the index template\n(`ensureTemplatesAndIndexCreated`) was never invoked - only during\nautomated testing 🤦\n\n## Manual testing steps\n\nThe mappings for the lock manager index (`.kibana_locks-000001`) should\nmatch this:\n```ts\n {\n mappings: {\n dynamic: false,\n properties: {\n token: { type: 'keyword' },\n metadata: { enabled: false },\n createdAt: { type: 'date' },\n expiresAt: { type: 'date' },\n },\n },\n}\n```\n\n### Test 1\n\nIn this test we make sure that the LockManager library can recover and\nfix the mappings if the existing index has invalid mappings\n\n#### Delete existing assets if they already exist\n```\nDELETE .kibana_locks-000001\nDELETE _index_template/.kibana_locks-index-template\nDELETE _component_template/.kibana_locks-component\n```\n\n#### Create lock index. This is invalid because it does not have the\ncorrect mappings\n```\nPUT .kibana_locks-000001\n```\n\n(Restart Kibana)\n\n#### Check mappings are correct\n```\nGET .kibana_locks-000001/_mapping\n```\n\n### Test 2\n\nIn this test we make sure that out of the box, the LockManager library\ncreates an index with the correct mappings\n\n```\nDELETE .kibana_locks-000001\nDELETE _index_template/.kibana_locks-index-template\nDELETE _component_template/.kibana_locks-component\n```\n\n(Restart Kibana)\n\n#### Check mappings are correct\n```\nGET .kibana_locks-000001/_mapping\n```\n\nRelated: https://github.com/elastic/kibana/pull/216916\nhttps://github.com/elastic/kibana/pull/216397\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <[email protected]>","sha":"f684ea4071dfb5e6acc4cb057b46acbf915943d7"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/218901","number":218901,"mergeCommit":{"message":"[LockManager] Ensure index template are created (#218901)\n\nCloses: https://github.com/elastic/kibana/issues/218944\n\nThe index template for the Lock Manager was not created, causing index\nmappings and settings to be incorrect.\nRoot cause: the function responsible for creating the index template\n(`ensureTemplatesAndIndexCreated`) was never invoked - only during\nautomated testing 🤦\n\n## Manual testing steps\n\nThe mappings for the lock manager index (`.kibana_locks-000001`) should\nmatch this:\n```ts\n {\n mappings: {\n dynamic: false,\n properties: {\n token: { type: 'keyword' },\n metadata: { enabled: false },\n createdAt: { type: 'date' },\n expiresAt: { type: 'date' },\n },\n },\n}\n```\n\n### Test 1\n\nIn this test we make sure that the LockManager library can recover and\nfix the mappings if the existing index has invalid mappings\n\n#### Delete existing assets if they already exist\n```\nDELETE .kibana_locks-000001\nDELETE _index_template/.kibana_locks-index-template\nDELETE _component_template/.kibana_locks-component\n```\n\n#### Create lock index. This is invalid because it does not have the\ncorrect mappings\n```\nPUT .kibana_locks-000001\n```\n\n(Restart Kibana)\n\n#### Check mappings are correct\n```\nGET .kibana_locks-000001/_mapping\n```\n\n### Test 2\n\nIn this test we make sure that out of the box, the LockManager library\ncreates an index with the correct mappings\n\n```\nDELETE .kibana_locks-000001\nDELETE _index_template/.kibana_locks-index-template\nDELETE _component_template/.kibana_locks-component\n```\n\n(Restart Kibana)\n\n#### Check mappings are correct\n```\nGET .kibana_locks-000001/_mapping\n```\n\nRelated: https://github.com/elastic/kibana/pull/216916\nhttps://github.com/elastic/kibana/pull/216397\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <[email protected]>","sha":"f684ea4071dfb5e6acc4cb057b46acbf915943d7"}}]},{"author":{"name":"Søren Louv-Jansen","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-04-29T16:42:45Z","message":"[LockManager] Expose as package (#219220)\n\nExpose LockManager as package to make it easier to consume from other\nplugins\n\ncc @nchaulet\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>\nCo-authored-by: Viduni Wickramarachchi <[email protected]>","sha":"8b8d569986f216185755aa7ac98a2a3bbeb84f76","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Obs AI Assistant","ci:project-deploy-observability","backport:version","v9.1.0","v8.19.0"],"title":"[LockManager] Expose as package","number":219220,"url":"https://github.com/elastic/kibana/pull/219220","mergeCommit":{"message":"[LockManager] Expose as package (#219220)\n\nExpose LockManager as package to make it easier to consume from other\nplugins\n\ncc @nchaulet\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>\nCo-authored-by: Viduni Wickramarachchi <[email protected]>","sha":"8b8d569986f216185755aa7ac98a2a3bbeb84f76"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219220","number":219220,"mergeCommit":{"message":"[LockManager] Expose as package (#219220)\n\nExpose LockManager as package to make it easier to consume from other\nplugins\n\ncc @nchaulet\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>\nCo-authored-by: Viduni Wickramarachchi <[email protected]>","sha":"8b8d569986f216185755aa7ac98a2a3bbeb84f76"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <[email protected]>
…tic#216916) This PR replaces usage of the Kibana Task Manager with the [LockManager utility](elastic#216397) that ensures strict mutual exclusion when running operations such as re-indexing or data migrations. --------- Co-authored-by: Viduni Wickramarachchi <[email protected]> Co-authored-by: kibanamachine <[email protected]> (cherry picked from commit 6244105)
… Assistant] Replace Task Manager usage with Lock Manager (#216916) | update knowledge base installation flow (#214133) | [Obs AI Assistant] Specify embedding model during onboarding for the Knowledge Base (#218448) (#220041) # Backport This will backport the following commits from `main` to `8.19`: - [[Obs AI Assistant] Minor cleanup api tests (#215181)](#215181) - [[Obs AI Assistant] Replace Task Manager usage with Lock Manager (#216916)](#216916) - [update knowledge base installation flow (#214133)](#214133) - [[Obs AI Assistant] Specify embedding model during onboarding for the Knowledge Base (#218448)](#218448) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Søren Louv-Jansen","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-03-20T09:59:59Z","message":"[Obs AI Assistant] Minor cleanup api tests (#215181)\n\n- Remove duplicated helpers\n- improve log messages\n- Clear intercepted requests after every test\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <[email protected]>","sha":"b9cd2c80404b0a0eb8ee51257ef01bdc1a71def6","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:skip","Team:Obs AI Assistant","ci:project-deploy-observability","v9.1.0"],"title":"[Obs AI Assistant] Minor cleanup api tests","number":215181,"url":"https://github.com/elastic/kibana/pull/215181","mergeCommit":{"message":"[Obs AI Assistant] Minor cleanup api tests (#215181)\n\n- Remove duplicated helpers\n- improve log messages\n- Clear intercepted requests after every test\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <[email protected]>","sha":"b9cd2c80404b0a0eb8ee51257ef01bdc1a71def6"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/215181","number":215181,"mergeCommit":{"message":"[Obs AI Assistant] Minor cleanup api tests (#215181)\n\n- Remove duplicated helpers\n- improve log messages\n- Clear intercepted requests after every test\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <[email protected]>","sha":"b9cd2c80404b0a0eb8ee51257ef01bdc1a71def6"}}]},{"author":{"name":"Søren Louv-Jansen","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-04-08T08:13:00Z","message":"[Obs AI Assistant] Replace Task Manager usage with Lock Manager (#216916)\n\nThis PR replaces usage of the Kibana Task Manager with the [LockManager\nutility](#216397) that ensures\nstrict mutual exclusion when running operations such as re-indexing or\ndata migrations.\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <[email protected]>\nCo-authored-by: kibanamachine <[email protected]>","sha":"624410524f1a07dc72d92759464a3f4a85466c7a","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:skip","Team:Obs AI Assistant","v9.1.0","v8.19.0"],"title":"[Obs AI Assistant] Replace Task Manager usage with Lock Manager","number":216916,"url":"https://github.com/elastic/kibana/pull/216916","mergeCommit":{"message":"[Obs AI Assistant] Replace Task Manager usage with Lock Manager (#216916)\n\nThis PR replaces usage of the Kibana Task Manager with the [LockManager\nutility](#216397) that ensures\nstrict mutual exclusion when running operations such as re-indexing or\ndata migrations.\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <[email protected]>\nCo-authored-by: kibanamachine <[email protected]>","sha":"624410524f1a07dc72d92759464a3f4a85466c7a"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/216916","number":216916,"mergeCommit":{"message":"[Obs AI Assistant] Replace Task Manager usage with Lock Manager (#216916)\n\nThis PR replaces usage of the Kibana Task Manager with the [LockManager\nutility](#216397) that ensures\nstrict mutual exclusion when running operations such as re-indexing or\ndata migrations.\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <[email protected]>\nCo-authored-by: kibanamachine <[email protected]>","sha":"624410524f1a07dc72d92759464a3f4a85466c7a"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]},{"author":{"name":"Arturo Lidueña","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-04-09T09:38:41Z","message":"update knowledge base installation flow (#214133)\n\n## Summary\nCloses [#209791](https://github.com/elastic/kibana/issues/209791)\nCloses [#204378](https://github.com/elastic/kibana/issues/204378)\n### Improve Knowledge Base Installation and Inference Endpoint\nManagement\n\n#### Enhancements \n- The **\"Install Knowledge Base\"** button is only shown when there is no\ninference endpoint. If the inference endpoint creation fails, an error\nnotification is displayed.\n- When an inference endpoint **exists and is ready**, no buttons or\nmessages are shown.\n- If the installation was in progress and **succeeded**, a success\nmessage is displayed.\n- If an inference endpoint is present, users can **inspect the state of\nthe model deployment** to diagnose issues.\n- When an inference endpoint exists but has an **error**, users can\nretry the installation.\n\n#### Inspection & Troubleshooting \nUsers can inspect the inference endpoint's deployment status, including:\n- **Model is deploying** \n- **No ML node available** \n- **Insufficient memory available** \n\n\nhttps://github.com/user-attachments/assets/03a91120-173c-4dc9-b6f2-59a8c8c8defb\n\n### Suggested Improvements \n- Display **autoscaling information** for better resource insights. \n- Show **ML node details** to help users understand the infrastructure.\n- Allow users to **install, deploy, and stop the model** directly from\nthe inspection popup.\n\nThese changes enhance visibility, troubleshooting, and control over\ninference endpoint deployment. 🚀\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- [ ] [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- [ ] 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\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- [ ] ...","sha":"4109420186d586f91fd999cea0087bb8e06bfc59","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport missing","Team:Obs AI Assistant","backport:version","v9.1.0","v8.19.0"],"title":"update knowledge base installation flow","number":214133,"url":"https://github.com/elastic/kibana/pull/214133","mergeCommit":{"message":"update knowledge base installation flow (#214133)\n\n## Summary\nCloses [#209791](https://github.com/elastic/kibana/issues/209791)\nCloses [#204378](https://github.com/elastic/kibana/issues/204378)\n### Improve Knowledge Base Installation and Inference Endpoint\nManagement\n\n#### Enhancements \n- The **\"Install Knowledge Base\"** button is only shown when there is no\ninference endpoint. If the inference endpoint creation fails, an error\nnotification is displayed.\n- When an inference endpoint **exists and is ready**, no buttons or\nmessages are shown.\n- If the installation was in progress and **succeeded**, a success\nmessage is displayed.\n- If an inference endpoint is present, users can **inspect the state of\nthe model deployment** to diagnose issues.\n- When an inference endpoint exists but has an **error**, users can\nretry the installation.\n\n#### Inspection & Troubleshooting \nUsers can inspect the inference endpoint's deployment status, including:\n- **Model is deploying** \n- **No ML node available** \n- **Insufficient memory available** \n\n\nhttps://github.com/user-attachments/assets/03a91120-173c-4dc9-b6f2-59a8c8c8defb\n\n### Suggested Improvements \n- Display **autoscaling information** for better resource insights. \n- Show **ML node details** to help users understand the infrastructure.\n- Allow users to **install, deploy, and stop the model** directly from\nthe inspection popup.\n\nThese changes enhance visibility, troubleshooting, and control over\ninference endpoint deployment. 🚀\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- [ ] [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- [ ] 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\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- [ ] ...","sha":"4109420186d586f91fd999cea0087bb8e06bfc59"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/214133","number":214133,"mergeCommit":{"message":"update knowledge base installation flow (#214133)\n\n## Summary\nCloses [#209791](https://github.com/elastic/kibana/issues/209791)\nCloses [#204378](https://github.com/elastic/kibana/issues/204378)\n### Improve Knowledge Base Installation and Inference Endpoint\nManagement\n\n#### Enhancements \n- The **\"Install Knowledge Base\"** button is only shown when there is no\ninference endpoint. If the inference endpoint creation fails, an error\nnotification is displayed.\n- When an inference endpoint **exists and is ready**, no buttons or\nmessages are shown.\n- If the installation was in progress and **succeeded**, a success\nmessage is displayed.\n- If an inference endpoint is present, users can **inspect the state of\nthe model deployment** to diagnose issues.\n- When an inference endpoint exists but has an **error**, users can\nretry the installation.\n\n#### Inspection & Troubleshooting \nUsers can inspect the inference endpoint's deployment status, including:\n- **Model is deploying** \n- **No ML node available** \n- **Insufficient memory available** \n\n\nhttps://github.com/user-attachments/assets/03a91120-173c-4dc9-b6f2-59a8c8c8defb\n\n### Suggested Improvements \n- Display **autoscaling information** for better resource insights. \n- Show **ML node details** to help users understand the infrastructure.\n- Allow users to **install, deploy, and stop the model** directly from\nthe inspection popup.\n\nThese changes enhance visibility, troubleshooting, and control over\ninference endpoint deployment. 🚀\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- [ ] [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- [ ] 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\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- [ ] ...","sha":"4109420186d586f91fd999cea0087bb8e06bfc59"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]},{"author":{"name":"Viduni Wickramarachchi","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-05-05T08:13:10Z","message":"[Obs AI Assistant] Specify embedding model during onboarding for the Knowledge Base (#218448)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/230\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/232\n\nRelated to https://github.com/elastic/kibana/pull/215591\n\n## Summary\n\nThis PR implements the changes related to the first phase of supporing\nmultilingual Knowledge Base. The users have the ability to pick the\n`e5-small` model for the Knowledge Base, if they want support for\nlanguages other than English.\n\n<img width=\"610\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/4c815aa4-aa97-4845-98c5-e079dd92f23a\"\n/>\n\n<img width=\"1281\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/7c1bcd82-5464-497f-a053-7fe271da1cdd\"\n/>\n\n<img width=\"1280\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/bc084e90-c291-44ea-8560-e033729bfcca\"\n/>\n\nWhen the KB model is not allocated due to nodes scaling down:\n\n\n\n\n\n### Checklist\n\n- [x] 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- [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- [ ] [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\n\n## Upgrade testing steps\n\n### 9.0 - 9.1 (main)\n\nCheckout `9.0` branch and start Kibana and ES. ES must be started with\n`path.data` to persist data:\n\n```\nyarn es snapshot --license trial --E path.data=/Users/sorenlouv/elastic/es_data/upgrade_test_9.0\n```\n\n---------\n\nCo-authored-by: Søren Louv-Jansen <[email protected]>\nCo-authored-by: kibanamachine <[email protected]>\nCo-authored-by: Søren Louv-Jansen <[email protected]>","sha":"dc019f85e19de28c1e2573108c47caa0080247c8","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:feature","Team:Obs AI Assistant","ci:project-deploy-observability","backport:version","v9.1.0","v8.19.0"],"title":"[Obs AI Assistant] Specify embedding model during onboarding for the Knowledge Base","number":218448,"url":"https://github.com/elastic/kibana/pull/218448","mergeCommit":{"message":"[Obs AI Assistant] Specify embedding model during onboarding for the Knowledge Base (#218448)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/230\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/232\n\nRelated to https://github.com/elastic/kibana/pull/215591\n\n## Summary\n\nThis PR implements the changes related to the first phase of supporing\nmultilingual Knowledge Base. The users have the ability to pick the\n`e5-small` model for the Knowledge Base, if they want support for\nlanguages other than English.\n\n<img width=\"610\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/4c815aa4-aa97-4845-98c5-e079dd92f23a\"\n/>\n\n<img width=\"1281\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/7c1bcd82-5464-497f-a053-7fe271da1cdd\"\n/>\n\n<img width=\"1280\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/bc084e90-c291-44ea-8560-e033729bfcca\"\n/>\n\nWhen the KB model is not allocated due to nodes scaling down:\n\n\n\n\n\n### Checklist\n\n- [x] 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- [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- [ ] [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\n\n## Upgrade testing steps\n\n### 9.0 - 9.1 (main)\n\nCheckout `9.0` branch and start Kibana and ES. ES must be started with\n`path.data` to persist data:\n\n```\nyarn es snapshot --license trial --E path.data=/Users/sorenlouv/elastic/es_data/upgrade_test_9.0\n```\n\n---------\n\nCo-authored-by: Søren Louv-Jansen <[email protected]>\nCo-authored-by: kibanamachine <[email protected]>\nCo-authored-by: Søren Louv-Jansen <[email protected]>","sha":"dc019f85e19de28c1e2573108c47caa0080247c8"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/218448","number":218448,"mergeCommit":{"message":"[Obs AI Assistant] Specify embedding model during onboarding for the Knowledge Base (#218448)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/230\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/232\n\nRelated to https://github.com/elastic/kibana/pull/215591\n\n## Summary\n\nThis PR implements the changes related to the first phase of supporing\nmultilingual Knowledge Base. The users have the ability to pick the\n`e5-small` model for the Knowledge Base, if they want support for\nlanguages other than English.\n\n<img width=\"610\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/4c815aa4-aa97-4845-98c5-e079dd92f23a\"\n/>\n\n<img width=\"1281\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/7c1bcd82-5464-497f-a053-7fe271da1cdd\"\n/>\n\n<img width=\"1280\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/bc084e90-c291-44ea-8560-e033729bfcca\"\n/>\n\nWhen the KB model is not allocated due to nodes scaling down:\n\n\n\n\n\n### Checklist\n\n- [x] 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- [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- [ ] [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\n\n## Upgrade testing steps\n\n### 9.0 - 9.1 (main)\n\nCheckout `9.0` branch and start Kibana and ES. ES must be started with\n`path.data` to persist data:\n\n```\nyarn es snapshot --license trial --E path.data=/Users/sorenlouv/elastic/es_data/upgrade_test_9.0\n```\n\n---------\n\nCo-authored-by: Søren Louv-Jansen <[email protected]>\nCo-authored-by: kibanamachine <[email protected]>\nCo-authored-by: Søren Louv-Jansen <[email protected]>","sha":"dc019f85e19de28c1e2573108c47caa0080247c8"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: Arturo Lidueña <[email protected]> Co-authored-by: Viduni Wickramarachchi <[email protected]> Co-authored-by: kibanamachine <[email protected]>
…quired (elastic#220476) Related: elastic#216397 This fixes a bug in the Lock Manager where an expired lock can be acquired, but the token and metadata is not updated. This means that the lock cannot be released. Instead it is automatically released when the TTL expires. (cherry picked from commit 74e876d)
…quired (elastic#220476) Related: elastic#216397 This fixes a bug in the Lock Manager where an expired lock can be acquired, but the token and metadata is not updated. This means that the lock cannot be released. Instead it is automatically released when the TTL expires.
Closes: elastic#218944 The index template for the Lock Manager was not created, causing index mappings and settings to be incorrect. Root cause: the function responsible for creating the index template (`ensureTemplatesAndIndexCreated`) was never invoked - only during automated testing 🤦 ## Manual testing steps The mappings for the lock manager index (`.kibana_locks-000001`) should match this: ```ts { mappings: { dynamic: false, properties: { token: { type: 'keyword' }, metadata: { enabled: false }, createdAt: { type: 'date' }, expiresAt: { type: 'date' }, }, }, } ``` ### Test 1 In this test we make sure that the LockManager library can recover and fix the mappings if the existing index has invalid mappings #### Delete existing assets if they already exist ``` DELETE .kibana_locks-000001 DELETE _index_template/.kibana_locks-index-template DELETE _component_template/.kibana_locks-component ``` #### Create lock index. This is invalid because it does not have the correct mappings ``` PUT .kibana_locks-000001 ``` (Restart Kibana) #### Check mappings are correct ``` GET .kibana_locks-000001/_mapping ``` ### Test 2 In this test we make sure that out of the box, the LockManager library creates an index with the correct mappings ``` DELETE .kibana_locks-000001 DELETE _index_template/.kibana_locks-index-template DELETE _component_template/.kibana_locks-component ``` (Restart Kibana) #### Check mappings are correct ``` GET .kibana_locks-000001/_mapping ``` Related: elastic#216916 elastic#216397 --------- Co-authored-by: Viduni Wickramarachchi <[email protected]>
…quired (elastic#220476) Related: elastic#216397 This fixes a bug in the Lock Manager where an expired lock can be acquired, but the token and metadata is not updated. This means that the lock cannot be released. Instead it is automatically released when the TTL expires.
…quired (elastic#220476) Related: elastic#216397 This fixes a bug in the Lock Manager where an expired lock can be acquired, but the token and metadata is not updated. This means that the lock cannot be released. Instead it is automatically released when the TTL expires.
Closes https://github.com/elastic/obs-ai-assistant-team/issues/238
LockManager is a lightweight, distributed locking solution. It ensures that critical operations, like re-indexing an index, are executed by only one node at a time, preventing race conditions and ensuring data consistency. By utilizing Elasticsearch's atomic updates, TTL-based expiration, and token-based safety checks, LockManager provides strong guarantees for safety and liveness without the complexity of full transactional systems, enabling reliable and efficient operations in distributed environments.
Usage: