Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security AI Assistant] Fixed license issue for Knowledge Base resources initialization #198239

Merged

Conversation

YulNaumenko
Copy link
Contributor

@YulNaumenko YulNaumenko commented Oct 30, 2024

  1. Fixed assistant resources initialization by adding license check before retry to install.
    The problem was caused by fetching ELSER model from ML, which was license gated.
    e2

  2. Fixed unnecessary client call to get KB status when the license is not min enterprise.

  3. Unified license check and auth for all routes to use performChecks

performChecks cleanup

Makes changes around the performChecks function. Everywhere this was called was passing authenticatedUser: true and license: true, so we removed those parameters and updated the code so that those checks always happen. Previously, performChecks either returned an error response or undefined. We updated it to return either:

{
  isSuccess: true;
  currentUser: AuthenticatedUser;
} |
{
  isSuccess: false;
  response: IKibanaResponse;
};

That way when the check passes, it always returns our AuthenticatedUser and eliminates the need to re-run that check.

Finally, we found any spot that was checking license + user on its own to use the performChecks function.

@YulNaumenko YulNaumenko added bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes v9.0.0 backport:all-open Backport to all branches that could still receive a release v8.16.0 labels Oct 30, 2024
@YulNaumenko YulNaumenko self-assigned this Oct 30, 2024
@YulNaumenko YulNaumenko requested a review from a team as a code owner October 30, 2024 00:54
Copy link
Contributor

@stephmilovic stephmilovic left a comment

Choose a reason for hiding this comment

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

Thank you so much for this fix Yuliia! I tested locally and not only do we no longer receive the toaster errors, we no longer get our "expected" error log on start up. Hooray! LGTM

@stephmilovic stephmilovic enabled auto-merge (squash) October 30, 2024 21:13
@stephmilovic stephmilovic merged commit ed81e43 into elastic:main Oct 30, 2024
38 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 7.17, 8.15, 8.16, 8.x

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

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 21.0MB 21.0MB +221.0B

History

cc @YulNaumenko

@stephmilovic stephmilovic added backport:version Backport to applied version labels v8.17.0 and removed backport:all-open Backport to all branches that could still receive a release labels Oct 30, 2024
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.16

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

@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
7.17 Backport failed because of merge conflicts
8.15 Backport failed because of merge conflicts
8.16 Backport failed because of merge conflicts
8.x

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

Manual backport

To create the backport manually run:

node scripts/backport --pr 198239

Questions ?

Please refer to the Backport tool documentation

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.16 Backport failed because of merge conflicts

You might need to backport the following PRs to 8.16:
- [Security Assistant] Knowledge base switch to use semantic_text (#197007)

Manual backport

To create the backport manually run:

node scripts/backport --pr 198239

Questions ?

Please refer to the Backport tool documentation

@stephmilovic
Copy link
Contributor

I will backport to 8.16 once #198439 has merged

stephmilovic pushed a commit to stephmilovic/kibana that referenced this pull request Oct 30, 2024
…ces initialization (elastic#198239)

(cherry picked from commit ed81e43)

# Conflicts:
#	x-pack/packages/kbn-elastic-assistant/impl/assistant/chat_send/use_chat_send.tsx
#	x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings.tsx
#	x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/index.tsx
#	x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/setup_knowledge_base_button.tsx
#	x-pack/plugins/elastic_assistant/server/ai_assistant_service/index.test.ts
#	x-pack/plugins/elastic_assistant/server/ai_assistant_service/index.ts
#	x-pack/plugins/elastic_assistant/server/routes/knowledge_base/entries/bulk_actions_route.ts
#	x-pack/plugins/elastic_assistant/server/routes/knowledge_base/entries/find_route.ts
#	x-pack/plugins/elastic_assistant/server/routes/request_context_factory.ts
@stephmilovic
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.15

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

Questions ?

Please refer to the Backport tool documentation

@stephmilovic
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.16

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

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Oct 30, 2024
…resources initialization (#198239) (#198447)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Security AI Assistant] Fixed license issue for Knowledge Base
resources initialization
(#198239)](#198239)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Yuliia
Naumenko","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-30T21:13:33Z","message":"[Security
AI Assistant] Fixed license issue for Knowledge Base resources
initialization
(#198239)","sha":"ed81e4334f4d5608517dacdba28d46dfea966be0","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","v9.0.0","backport:all-open","v8.16.0"],"title":"[Security
AI Assistant] Fixed license issue for Knowledge Base resources
initialization","number":198239,"url":"https://github.com/elastic/kibana/pull/198239","mergeCommit":{"message":"[Security
AI Assistant] Fixed license issue for Knowledge Base resources
initialization
(#198239)","sha":"ed81e4334f4d5608517dacdba28d46dfea966be0"}},"sourceBranch":"main","suggestedTargetBranches":["8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198239","number":198239,"mergeCommit":{"message":"[Security
AI Assistant] Fixed license issue for Knowledge Base resources
initialization
(#198239)","sha":"ed81e4334f4d5608517dacdba28d46dfea966be0"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Yuliia Naumenko <[email protected]>
stephmilovic added a commit that referenced this pull request Oct 30, 2024
… resources initialization (#198239) (#198451)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[Security AI Assistant] Fixed license issue for Knowledge Base
resources initialization
(#198239)](#198239)

<!--- Backport version: 8.9.8 -->

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

<!--BACKPORT [{"author":{"name":"Yuliia
Naumenko","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-30T21:13:33Z","message":"[Security
AI Assistant] Fixed license issue for Knowledge Base resources
initialization
(#198239)","sha":"ed81e4334f4d5608517dacdba28d46dfea966be0","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","v9.0.0","v8.16.0","backport:version","v8.17.0","v8.15.4"],"number":198239,"url":"https://github.com/elastic/kibana/pull/198239","mergeCommit":{"message":"[Security
AI Assistant] Fixed license issue for Knowledge Base resources
initialization
(#198239)","sha":"ed81e4334f4d5608517dacdba28d46dfea966be0"}},"sourceBranch":"main","suggestedTargetBranches":["8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198239","number":198239,"mergeCommit":{"message":"[Security
AI Assistant] Fixed license issue for Knowledge Base resources
initialization
(#198239)","sha":"ed81e4334f4d5608517dacdba28d46dfea966be0"}},{"branch":"8.16","label":"v8.16.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","labelRegex":"^v8.17.0$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/198447","number":198447,"state":"OPEN"},{"branch":"8.15","label":"v8.15.4","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/198449","number":198449,"state":"OPEN"}]}]
BACKPORT-->

Co-authored-by: Yuliia Naumenko <[email protected]>
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 bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes v8.15.4 v8.16.0 v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants