Skip to content

[Fleet] Make save_knowledge_base async in streaming state machine#252328

Merged
nchaulet merged 3 commits intomainfrom
copilot/make-install-knowledge-base-async
Feb 10, 2026
Merged

[Fleet] Make save_knowledge_base async in streaming state machine#252328
nchaulet merged 3 commits intomainfrom
copilot/make-install-knowledge-base-async

Conversation

Copy link
Contributor

Copilot AI commented Feb 9, 2026

Summary

The save_knowledge_base step in the streaming state machine blocks package installation until knowledge base indexing completes, causing timeouts for large packages like security_detection_engine.

Changes

Added isAsync: true to the save_knowledge_base step in streamingStatesDefinition:

save_knowledge_base: {
  onPreTransition: cleanupKnowledgeBaseStep,
  onTransition: stepSaveKnowledgeBase,
  nextState: INSTALL_STATES.UPDATE_SO,
  onPostTransition: updateLatestExecutedState,
  isAsync: true, // Knowledge base indexing runs in background
},

This matches the existing behavior in regularStatesDefinition where the flag was already present. Knowledge base indexing now runs asynchronously without blocking state machine progression.

Added parity test: To ensure consistency between the two state machine definitions, added a unit test that verifies common states have matching isAsync flags between regularStatesDefinition and streamingStatesDefinition. This prevents future drift between the two implementations.

Testing

POST kbn:/api/fleet/epm/packages/security_detection_engine/9.3.2
{
  "force": true
}
Original prompt

This section details on the original issue you should resolve

<issue_title>[Fleet] Make install knowledge base step async for install security detection prebuilt rules</issue_title>
<issue_description>## Description

The step to install knowledge base is not async in the state machine use to install security_detection_engine it should be to avoid timeouts.

Workaround

While this is fixed, if you encounter that issue you could disabled knowledge base from the integration page
#245080

How to test

POST kbn:/api/fleet/epm/packages/security_detection_engine/9.3.2
{
    "force": true
}
 ```</issue_description>

<agent_instructions>In fleet state machine there is a save_knowledge_base that should be async (isAsync) true could you fix that</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@elasticmachine</author><body>
Pinging @elastic/fleet (Team:Fleet)</body></comment_new>
</comments>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…to prevent timeouts

Co-authored-by: nchaulet <1336873+nchaulet@users.noreply.github.com>
Copilot AI changed the title [WIP] Make install knowledge base step async for security detection engine Feb 9, 2026
Copilot AI requested a review from nchaulet February 9, 2026 14:56
@nchaulet nchaulet marked this pull request as ready for review February 9, 2026 15:24
@nchaulet nchaulet requested a review from a team as a code owner February 9, 2026 15:24
@nchaulet nchaulet added release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team backport:version Backport to applied version labels v9.3.1 labels Feb 9, 2026
@nchaulet
Copy link
Member

nchaulet commented Feb 9, 2026

@copilot Could you add a test for that, I think adding a unit test that check parity between the two state machine will be great

Export regularStatesDefinition and streamingStatesDefinition to make them testable, and add a unit test that verifies common states have matching isAsync flags between both state machines.

Co-authored-by: nchaulet <1336873+nchaulet@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 9, 2026

@copilot Could you add a test for that, I think adding a unit test that check parity between the two state machine will be great

Added a parity test in commit 8068376. The test verifies that common states (create_restart_installation, install_kibana_assets, save_archive_entries_from_assets_map, save_knowledge_base, update_so) have matching isAsync flags between regularStatesDefinition and streamingStatesDefinition.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • iojs.org
    • Triggering command: /usr/bin/curl curl -q --fail --compressed -L -s REDACTED -o - (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Copy link
Contributor

@Supplementing Supplementing left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@nchaulet
Copy link
Member

/ci

@nchaulet nchaulet enabled auto-merge (squash) February 10, 2026 13:50
@nchaulet
Copy link
Member

@elasticmachine run docs-build

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #113 / discover/esql discover esql controls when adding an ES|QL panel with controls in dashboards and exploring it in discover should retain the controls and their state
  • [job] [logs] FTR Configs #137 / serverless observability UI - telemetry discover/observabilitySolution/context_awareness/telemetry telemetry context should set EBT context for telemetry events when logs data source profile and reset

Metrics [docs]

✅ unchanged

cc @nchaulet @Copilot

@nchaulet nchaulet merged commit 34ea966 into main Feb 10, 2026
15 checks passed
@nchaulet nchaulet deleted the copilot/make-install-knowledge-base-async branch February 10, 2026 15:19
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 9.3

https://github.com/elastic/kibana/actions/runs/21870774132

@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
9.3

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

mbondyra added a commit to mbondyra/kibana that referenced this pull request Feb 10, 2026
* commit '7dcc1fe3c205d2de0c3ca3f65804f21de09013c3': (285 commits)
  Enrich kbn-check-saved-objects-cli README with CI and manual usage docs (elastic#252557)
  [Discover] Add feature flag to make ESQL the default query mode (elastic#252268)
  Add maskProps.headerZindexLocation above to inspect component flyout (elastic#252543)
  [Security Solution][Atack/Alerts] Flyout header: Assignees  (elastic#252190)
  Upgrade EUI to v112.3.0 (elastic#252315)
  [Fleet] Make save_knowledge_base async in streaming state machine (elastic#252328)
  Upgrade @smithy/config-resolver 4.3.0 → 4.4.6 (elastic#252457)
  [Lens as API] Add colorMapping support for XY charts (ES|QL data layers) (elastic#252051)
  [WorkplaceAI] Add Google Drive data source and connector (elastic#250677)
  [Scout] Move GlobalSearch FTR tests to Scout (elastic#252201)
  [EDR Workflows] Fix osquery pack results display when agent clock is skewed (elastic#251417)
  [Observability Onboarding] Apply integrations limit after dedup in parseIntegrationsTSV (elastic#252486)
  [Entity Analytics] Update `host.ip` aggregation to remove painless script (elastic#252426)
  Address `@elastic/eui/require-table-caption` lint violations across `@elastic/obs-presentation-team` files (elastic#251050)
  Consolidate JSON stringify dependencies (elastic#251890)
  [index mgmt] Use esql instead of query dsl to get the index count (elastic#252422)
  Add Usage API Plugin (elastic#252434)
  Cases All Templates page (elastic#250372)
  [Agent Builder] Default value for optional params in ESQL tools (elastic#238472)
  [Fleet] Add upgrade_details.metadata.reason to AgentResponseSchema (elastic#252485)
  ...
kibanamachine added a commit that referenced this pull request Feb 10, 2026
…ne (#252328) (#252561)

# Backport

This will backport the following commits from `main` to `9.3`:
- [[Fleet] Make save_knowledge_base async in streaming state machine
(#252328)](#252328)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT
[{"author":{"name":"Copilot","email":"198982749+Copilot@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-02-10T15:19:22Z","message":"[Fleet]
Make save_knowledge_base async in streaming state machine
(#252328)","sha":"34ea9669a58ae968c3d0ce3f5e5c2bb546de15ba","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","💝community","Team:Fleet","backport:version","v9.4.0","v9.3.1"],"title":"[Fleet]
Make save_knowledge_base async in streaming state
machine","number":252328,"url":"https://github.com/elastic/kibana/pull/252328","mergeCommit":{"message":"[Fleet]
Make save_knowledge_base async in streaming state machine
(#252328)","sha":"34ea9669a58ae968c3d0ce3f5e5c2bb546de15ba"}},"sourceBranch":"main","suggestedTargetBranches":["9.3"],"targetPullRequestStates":[{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/252328","number":252328,"mergeCommit":{"message":"[Fleet]
Make save_knowledge_base async in streaming state machine
(#252328)","sha":"34ea9669a58ae968c3d0ce3f5e5c2bb546de15ba"}},{"branch":"9.3","label":"v9.3.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels 💝community release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v9.3.0 v9.3.1 v9.4.0

5 participants