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

[Search] Integrate "Send to background" UI with session service #83073

Merged
merged 31 commits into from
Dec 1, 2020

Conversation

Dosant
Copy link
Contributor

@Dosant Dosant commented Nov 10, 2020

Summary

Part of #83640

This pr connects #81004 + #81099 making send to background indicator/popover more-or-less functional and we can see how the feature is shaping up.

Screenshot 2020-11-19 at 16 51 55

Notes

  • Integrates only with discover and dashboard
  • Only absolute time ranges
  • Background session management is not implemented yet, so link goes to nowhere
  • There are already some known/existing bugs and follow-up enhancements, I am keeping a list here [Search] Send to background #83640.
    • A notable bug: on a dashboard on some state changes (e.g. switching view/edit mode) background session indicator disappears until refresh is hit. I want to fix it separately as it is more of a dashboard change, then search layer change.
  • There is some TODOs in functional tests. Some units tests are missing. I will continue while it is being reviewed. DONE
  • Client side session service split into two services. One is pure CRUD mostly for management screen. Another is tracking state of current session.

How to test

xpack.data_enhanced.search.sendToBackground.enabled: true
data.search.aggs.shardDelay.enabled: true # helpful to create "slow" visualizations

To try a restore flow you can build a restore session URL, by getting sessionId from inspector and appending to the URL: &searchSessionId=${your-id-from-inspector}. (See tests)

Checklist

For maintainers

@apmmachine
Copy link
Contributor

💚 Build Succeeded

@kibanamachine
Copy link
Contributor

⏳ Build in-progress, with failures

Failed CI Steps

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

⏳ Build in-progress, with failures

Failed CI Steps

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@Dosant Dosant mentioned this pull request Nov 18, 2020
38 tasks
wip

docs
@Dosant Dosant force-pushed the dev/search-server-session-wip branch from b037743 to 3e102cd Compare November 19, 2020 13:59
@Dosant Dosant changed the title [very wip] send to background UI + server session service [Search] Integrate "Send to background" UI with session service Nov 19, 2020
@Dosant Dosant added Feature:Search Querying infrastructure in Kibana Team:AppServices v7.11.0 v8.0.0 release_note:skip Skip the PR/issue when compiling release notes labels Nov 19, 2020
@Dosant Dosant marked this pull request as ready for review November 20, 2020 12:50
@Dosant Dosant requested a review from a team as a code owner November 20, 2020 12:50
@Dosant Dosant requested a review from a team November 20, 2020 12:50
@Dosant Dosant requested review from a team as code owners November 20, 2020 12:50
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServices)

@Dosant Dosant requested a review from lizozom November 20, 2020 13:37
@kertal
Copy link
Member

kertal commented Nov 26, 2020

@kertal, that setting indeed is not helpful for discover :(

  1. you can at least test restore flow where you saved to background AFTER search is finished.

So when I saved the session, use the id in inspect in the URL, I'm getting an error message:

Bildschirmfoto 2020-11-26 um 13 15 47

How can I see all the sessions that are available? thx!

@Dosant
Copy link
Contributor Author

Dosant commented Nov 26, 2020

@kertal, Do you search with relative time range? It doesn't work for relative time range just yet (I noted that in pr description). This will be handled separately.
The error means that session service can't match older search request with your current search request (in this case because of difference in time due to relative time range)

How can I see all the sessions that are available? thx!

Management UI is not implemented yet, but if needed you could use API (session service) or look for saved objects of type background-session

Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

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

Code LGTM, tested locally in Chrome, Firefox, works 👍 . Tested "restore flow where you saved to background AFTER search is finished". Thx for the refactoring

@Dosant
Copy link
Contributor Author

Dosant commented Nov 26, 2020

@elasticmachine merge upstream

@Dosant
Copy link
Contributor Author

Dosant commented Nov 30, 2020

@elasticmachine merge upstream

public find(
options: SearchSessionFindOptions
): Promise<SavedObjectsFindResponse<BackgroundSessionSavedObjectAttributes>> {
return this.http!.post(`/internal/session`, {
Copy link
Contributor

@lizozom lizozom Nov 25, 2020

Choose a reason for hiding this comment

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

//nit
Shouldn't find use http.get?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree get makes more sense, especially since core.savedObjectClient also uses get
But this wasn't aded in this pr so out of scope here. cc @lukasolson

src/plugins/dashboard/public/url_generator.ts Show resolved Hide resolved
src/plugins/data/public/search/search_interceptor.ts Outdated Show resolved Hide resolved
src/plugins/data/public/search/session/session_service.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

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

I just realized that when a session is saved, we still cancel it upon navigating away.
Saved sessions should be allowed to run upon refresh / navigating away / etc.

In terms of the UI, I think we have too many spinners running
image

I also think the tooltip of the indicator needs a slight delay, and generally has some weird behavior about it

Discover - Elastic (6)

@Dosant
Copy link
Contributor Author

Dosant commented Nov 30, 2020

@lizozom, thanks for the review:

I just realized that when a session is saved, we still cancel it upon navigating away.
Saved sessions should be allowed to run upon refresh / navigating away / etc.

Great catch ❤️ I added logic to not delete async search in case this search was saved with background session. Unfortunately code to support this doesn't look slick, but it is the most reliable way I could think of.

In terms of the UI, I think we have too many spinners running

Something to think about... I'll add it here: #83640

I also think the tooltip of the indicator needs a slight delay, and generally has some weird behavior about it

Thanks! I caught it once and was thinking I went crazy. I didn't find a way to reliably reproduce it nor a way to fix it.
I am putting a note here and will follow up. #83640
Worst case will remove that tooltip all together.

src/plugins/data/public/search/session/session_service.ts Outdated Show resolved Hide resolved
this.deps.session.state$
.pipe(
skip(1), // ignore any state, we are only interested in transition x -> BackgroundLoading
filter((state) => isCurrentSession() && state === SessionState.BackgroundLoading),
Copy link
Contributor

Choose a reason for hiding this comment

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

Same should apply if the session has finished loading.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use sessionService.isStored instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why not use sessionService.isStored instead?

This is what I initially thought of, but it didn't work for me:
sessionService tracks state of the CURRENT session and at the point when we cancel the search it might be already tracking different session.

Let's assume we have a search that will be aborted because of navigating away.
Consider this scenario:

  1. Session is created, search is fired
  2. before we start search, isStored is still false
  3. Session is saved, isStored becomes true
  4. User navigates away. session is cleared.
  5. Search gets canceled, we are in catchError, sessionService.isStored is false, because session was cleared. So we don't know if the search that was cancelled was stored or not.

To support this use case using session service we should keep state of older sessions.
Other simpler alternative for this specific use case was to subscribe to state change into backgroundLoading state and keep that bool flag in closure.

Same should apply if the session has finished loading.

Don't think so, it seems that transition to BackgroundLoading is what we really interested in, if I am not missing something.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
dashboard 185 186 +1
data 599 602 +3
dataEnhanced 38 37 -1
total +3

Async chunks

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

id before after diff
dashboard 193.2KB 197.2KB +4.0KB
dataEnhanced 26.3KB 27.6KB +1.3KB
discover 430.2KB 432.2KB +2.0KB
total +7.2KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
dashboard 321.3KB 322.2KB +951.0B
data 974.2KB 983.3KB +9.1KB
dataEnhanced 35.2KB 35.1KB -121.0B
discover 81.8KB 82.1KB +213.0B
total +10.1KB

Saved Objects .kibana field count

Every field in each saved object type adds overhead to Elasticsearch. Kibana needs to keep the total field count below Elasticsearch's default limit of 1000 fields. Only specify field mappings for the fields you wish to search on or query. See https://www.elastic.co/guide/en/kibana/master/development-plugin-saved-objects.html#_mappings

id before after diff
background-session 5 7 +2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

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

LGTM

@Dosant Dosant merged commit 4cb44d9 into elastic:master Dec 1, 2020
Dosant added a commit to Dosant/kibana that referenced this pull request Dec 1, 2020
gmmorris added a commit to gmmorris/kibana that referenced this pull request Dec 1, 2020
* master: (63 commits)
  Revert the Revert of "[Alerting] renames Resolved action group to Recovered (elastic#84123)"  (elastic#84662)
  declare kbn/monaco dependency on kbn/i18n explicitly (elastic#84660)
  Remove unscripted fields from sample data index-pattern saved objects (elastic#84659)
  [ML] Fix unnecessary trigger of wildcard field type search for ML plugin routes. (elastic#84605)
  Update create.asciidoc (elastic#84046)
  [Security Solution][Detections] Fix labels and issue with mandatory fields (elastic#84525)
  Fix flaky test suite (elastic#84602)
  [Security Solution] [Detections] Create a 'partial failure' status for rules (elastic#84293)
  Revert "[Alerting] renames Resolved action group to Recovered (elastic#84123)"
  Update code-comments describing babel plugins (elastic#84622)
  [Security Solution] [Cases] Cypress for case connector selector options (elastic#80745)
  [Discover] Unskip doc table tests (elastic#84564)
  [Lens] (Accessibility) Improve landmarks in Lens (elastic#84511)
  [Lens] (Accessibility) Focus mistakenly stops on righthand form (elastic#84519)
  Return early when parallel install process detected (elastic#84190)
  [Security Solution][Detections] Support arrays in event fields for Severity/Risk overrides (elastic#83723)
  [Security Solution][Detections] Fix grammatical error in validation message for threshold field in "Create new rule" -> "Define rule" (elastic#84490)
  [Fleet] Update agent details page  (elastic#84434)
  adding documentation of use of NODE_EXTRA_CA_CERTS env var (elastic#84578)
  [Search] Integrate "Send to background" UI with session service (elastic#83073)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Embedding Embedding content via iFrame Feature:Search Querying infrastructure in Kibana release_note:skip Skip the PR/issue when compiling release notes v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants