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

[Snapshot + Restore] Set snapshots response size limit #103331

Merged
merged 12 commits into from
Jun 29, 2021

Conversation

alisonelizabeth
Copy link
Contributor

@alisonelizabeth alisonelizabeth commented Jun 24, 2021

This PR sets a limit (1000) on the number of snapshots displayed in the snapshots table in Snapshot + Restore and displays a warning if that limit is reached. This is a temporary solution to support scenarios where a user has a large number of snapshots that could potentially create performance issues on the client. In the near future, this will be replaced in favor of server-side pagination.

This PR is supported on the ES side by: elastic/elasticsearch#74451, elastic/elasticsearch#73952.

Also fixes #44817

How to test

  1. I'm not sure if the ES changes are available via snapshot yet, so you may need to build from source: yarn es source -E path.repo=/tmp/es_backups.
  2. Create a local FS repository. You will need to define the max_number_of_snapshots setting (default is 500). This setting isn't available in the UI, so it's easiest to set up via Console:
PUT /_snapshot/my_repo
{
  "type": "fs",
  "settings": {
    "location": "/tmp/es_backups",
    "max_number_of_snapshots": 1200
  }
}
  1. Create >1000 snapshots. I've created a gist with instructions to create snapshots in bulk. This will take some time to run.
  2. Visit the "Snapshots" tab in Snapshot + Restore. Verify the snapshots are still displayed as expected and warning displays.

Note on ES API changes
As part of this work, I've replaced the batched snapshot requests in favor of fetching all snapshots in a single request. The ES snapshots API should also now be compatible again on 8.0 and 7.x, and we will no longer need to maintain two different codebases 🎉 (original PR where divergence was introduced: #39533).

Screenshots

Screen Shot 2021-06-28 at 2 16 38 PM

Screen Shot 2021-06-28 at 2 20 42 PM

Screen Shot 2021-06-28 at 8 06 58 PM

Screen Shot 2021-06-28 at 8 28 01 PM

@alisonelizabeth alisonelizabeth added v8.0.0 Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more release_note:skip Skip the PR/issue when compiling release notes Feature:Snapshot and Restore Elasticsearch snapshots and repositories UI v7.14.0 labels Jun 24, 2021
@alisonelizabeth alisonelizabeth marked this pull request as ready for review June 28, 2021 13:32
@alisonelizabeth alisonelizabeth requested review from a team as code owners June 28, 2021 13:32
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-stack-management (Team:Stack Management)

@alisonelizabeth
Copy link
Contributor Author

Copy link

@lockewritesdocs lockewritesdocs left a comment

Choose a reason for hiding this comment

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

Added some suggested revisions to the message text. Let me know if you want to discuss further!

alisonelizabeth and others added 3 commits June 28, 2021 13:49
…me/snapshot_list/snapshot_list.tsx

Co-authored-by: Adam Locke <[email protected]>
…me/snapshot_list/snapshot_list.tsx

Co-authored-by: Adam Locke <[email protected]>
Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

Thanks for doing this @alisonelizabeth! Tested locally, code LGTM.

@@ -65,3 +65,9 @@ export const TIME_UNITS: { [key: string]: 'd' | 'h' | 'm' | 's' } = {
MINUTE: 'm',
SECOND: 's',
};

/**
* [Temporary workaround] In order to prevent an unusable UI for users with a large number of snapshots,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we clarify what makes it unusable? For example, is it a client-side performance issue?

@@ -116,7 +116,7 @@ export function registerRepositoriesRoutes({
snapshot: '_all',
});

const { responses: snapshotResponses } = response.body;
const { snapshots: snapshotList } = response.body;
Copy link
Contributor

Choose a reason for hiding this comment

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

As part of the ES changes, the snapshots API should now be compatible again on 8.0 and 7.x

Note for myself and anyone else who is curious. This looks like a breaking change but it's really bringing master into alignment with 7.x (https://github.com/elastic/kibana/blob/7.x/x-pack/plugins/snapshot_restore/server/routes/api/repositories.ts#L115)

>
<FormattedMessage
id="xpack.snapshotRestore.snapshotsList.maxSnapshotsDisplayedDescription"
defaultMessage="You've reached the maximum number of snapshots. To view all of your snapshots, use {docLink}."
Copy link
Contributor

Choose a reason for hiding this comment

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

@lockewritesdocs Does "You've reached the maximum number of snapshots" sound like you've hit a technical limit, and you can't have more snapshots beyond this point? I think something like "You've reached the maximum number of snapshots that can be displayed" will remove this ambiguity. WDYT?

Also, do you think it'd be helpful to mention what that limit is, somehow?

Choose a reason for hiding this comment

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

We could say something like, "You've reached the maximum number of viewable snapshots."

I'm debating whether the limit is useful. If it's 500 or it's 1,000, does it matter if I can't see them? I'm not entirely sure.

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've changed this to: "You've reached the maximum number of viewable snapshots." I'm not sure if the limit is useful either. I think it's also somewhat obvious based on the pagination.

Choose a reason for hiding this comment

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

++ @alisonelizabeth -- I think this is a great compromise.

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

Didn't re-test locally but I re-reviewed the code and it's great to see we're retaining the "partial response" UX even if some of the snapshots have errors. Thanks for digging into this!

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

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
snapshotRestore 460.2KB 461.6KB +1.4KB

Page load bundle

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

id before after diff
core 417.7KB 417.7KB +55.0B
snapshotRestore 41.1KB 41.2KB +118.0B
total +173.0B
Unknown metric groups

API count

id before after diff
snapshotRestore 22 23 +1

History

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

@alisonelizabeth alisonelizabeth merged commit e387d3d into elastic:master Jun 29, 2021
@alisonelizabeth alisonelizabeth deleted the sr/limit_snapshots branch June 29, 2021 15:32
alisonelizabeth added a commit that referenced this pull request Jun 30, 2021
#103693)

* [Snapshot + Restore] Set snapshots response size limit (#103331)

# Conflicts:
#	x-pack/plugins/snapshot_restore/server/routes/api/repositories.test.ts
#	x-pack/plugins/snapshot_restore/server/routes/api/repositories.ts
#	x-pack/plugins/snapshot_restore/server/routes/api/snapshots.test.ts
#	x-pack/plugins/snapshot_restore/server/routes/api/snapshots.ts

* fix merge conflict

* skip test

Co-authored-by: Kibana Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Snapshot and Restore Elasticsearch snapshots and repositories UI release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v7.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SR] Replace batched snapshot ES requests with single request
6 participants