Skip to content

Ignore missing references on saved object exports#47685

Merged
rudolf merged 15 commits intoelastic:masterfrom
pgayvallet:kbn-43876-ignore-missing-refs
Oct 16, 2019
Merged

Ignore missing references on saved object exports#47685
rudolf merged 15 commits intoelastic:masterfrom
pgayvallet:kbn-43876-ignore-missing-refs

Conversation

@pgayvallet
Copy link
Copy Markdown
Contributor

@pgayvallet pgayvallet commented Oct 9, 2019

Release notes

When exporting saved objects with "include related objects" enabled, the saved objects management UI will now display a warning and continue instead of failing if some related objects could not be found.

Fixes #43876

Breaking changes

This PR changes the behaviour of the /api/saved_objects/_export experimental endpoint

  • no longer returns error when includeReferencesDeep option is true and some references are non-existing (ignore them instead)
  • returns an export summary at the end of the ndjson stream containing the number of exported objects and the number and id's of any missing references (this is a breaking change for consumers of the endpoint)
  • add an excludeExportDetails option to disable the previous behaviour

Screenshot 2019-10-10 at 17 59 15

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

- [ ] This was checked for cross-browser compatibility, including a check against IE11

For maintainers

@pgayvallet pgayvallet added Feature:Saved Objects Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// labels Oct 9, 2019
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

@pgayvallet pgayvallet force-pushed the kbn-43876-ignore-missing-refs branch from e537b42 to cdb38be Compare October 9, 2019 13:21
@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

@pgayvallet pgayvallet force-pushed the kbn-43876-ignore-missing-refs branch from c2b2e24 to 916b5d2 Compare October 9, 2019 15:48
@pgayvallet pgayvallet added release_note:skip Skip the PR/issue when compiling release notes v7.5.0 v8.0.0 labels Oct 9, 2019
@pgayvallet pgayvallet force-pushed the kbn-43876-ignore-missing-refs branch from 916b5d2 to 0ac506e Compare October 9, 2019 16:52
@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

@pgayvallet pgayvallet force-pushed the kbn-43876-ignore-missing-refs branch from 0ac506e to d64ebc9 Compare October 9, 2019 18:54
@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@pgayvallet pgayvallet marked this pull request as ready for review October 10, 2019 13:17
@pgayvallet pgayvallet requested review from a team as code owners October 10, 2019 13:17
@pgayvallet pgayvallet requested review from legrego and rudolf October 10, 2019 13:18
@rudolf
Copy link
Copy Markdown
Contributor

rudolf commented Oct 10, 2019

@mikecote Would be good to get your opinion on the design but I think what Pierre did is more elegant than my previous suggestion of failing the export and then retrying with ?ignoreMissingReferences=true.

At the end of the NDJSON stream we include a status entry with all the references which couldn't be found. I think if we move to a truly streaming API this will be really useful so that as someone only consuming the API you can be sure that the stream "completed" and that there weren't any errors (like if an exception occurred after exporting 1GB's of objects).

@pgayvallet pgayvallet added release_note:breaking release_note:fix and removed release_note:skip Skip the PR/issue when compiling release notes labels Oct 10, 2019
Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

@mikecote
Copy link
Copy Markdown
Contributor

@rudolf the approach makes sense to me 👍. The one drawback I can see is the entire file may have to be read (in memory) in order to gather the status entry. This is more a problem in the future with 1GB files and I'm sure there's a stream way to do this on the browser without reading the whole file. Though I think that problem can be deferred to the future as only 10,000 objects are supported at this time (and I think < 10MB imports).

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@pgayvallet
Copy link
Copy Markdown
Contributor Author

pgayvallet commented Oct 11, 2019

@mikecote The blob is more or less a reader interface, we need to read the whole blob to get the last entry, but we can only keep the last / current reading line in memory. This will definitely makes sense once we properly stream the content from server to browser. For now, I think reading (max) 10MB in memory is fine.

Copy link
Copy Markdown
Contributor

@rudolf rudolf left a comment

Choose a reason for hiding this comment

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

Left a couple of copy and docs comments but overall this looks very good

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@pgayvallet
Copy link
Copy Markdown
Contributor Author

@rudolf all changes has been made, PTAL 4 last commits

Copy link
Copy Markdown
Contributor

@rudolf rudolf left a comment

Choose a reason for hiding this comment

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

🎉

@pgayvallet
Copy link
Copy Markdown
Contributor Author

@legrego Could you review the changes impacting spaces ?

@legrego
Copy link
Copy Markdown
Member

legrego commented Oct 15, 2019

@pgayvallet will do! I have one PR to review ahead of this one, but I'll get to it as soon as possible

@legrego
Copy link
Copy Markdown
Member

legrego commented Oct 15, 2019

returns an export summary at the end of the ndjson stream containing number of exported objects and number / id of missing references if any. (this is a breaking change for consumers of the endpoint)

question: Is there a reason why we have to make this a breaking change for consumers?

add a excludeExportDetails option to disable the previous behaviour

If we change this to includeExportDetails, and default the value to false, then existing consumers will continue to work without changes. We'd need to update the UI to include this query parameter, but all other things equal, it's easier for us to add this parameter than it is to ask all other consumers to add the exclude option.


Also, sorry for the merge conflict - we started moving the spaces plugin to the new platform. I don't expect the changes to be all that difficult though. Let me know if you need help resolving!

@pgayvallet
Copy link
Copy Markdown
Contributor Author

Well, the first point would be that this API is flagged as experimental, meaning that breaking changes may occurs.

But the actual reason is that the ndjson format being that containing, we really wanted a way to add Metadata to the format. As an extra line is the only approach, we want to change the format as soon as possible to avoid doing it later. The Metadata should now be a part of the default export. The 'exclude' option is here for rétro-compatibility. Not the other way around.

I hope that make sense

@pgayvallet
Copy link
Copy Markdown
Contributor Author

@rudolf what do you think about @legrego proposal?

Copy link
Copy Markdown
Member

@legrego legrego left a comment

Choose a reason for hiding this comment

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

Pending merge conflicts, the changes to spaces LGTM! Tested locally.

@rudolf
Copy link
Copy Markdown
Contributor

rudolf commented Oct 16, 2019

In retrospect it might have been better to go with @legrego's proposal since not introducing a breaking change would have made it easy to include this in 7.4.1 but I think it's too late to squeeze it into the release.

I think including the metadata in the response is a better default for this API. If you're an API consumer you shouldn't be relying on the HTTP status code, as when the internals have eventually been converted to be completely stream based we'll send a 200 before we've completed the whole export. So I think we should introduce the breaking change at some point.

Since this is an experimental API and we have an easy flag to opt-out of the breaking behaviour I agree with @pgayvallet that doing this sooner is probably preferable.

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@rudolf rudolf merged commit 7df981f into elastic:master Oct 16, 2019
rudolf pushed a commit to rudolf/kibana that referenced this pull request Oct 16, 2019
* add saved object export details in ndjson response

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* update core doc

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* exclude export details for space copy

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* fixing tests

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* display warning instead of success if export contains missing refs

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* nits/typo

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* properly updates api integration tests

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* fix typings

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* add test on objects_table component

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* remove added translations from jp/cn bundles

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* restoring line feeds

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* improve doc and user alert message

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* restoring line feeds on server.api.md

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* warning test label

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
rudolf added a commit that referenced this pull request Oct 16, 2019
* add saved object export details in ndjson response

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* update core doc

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* exclude export details for space copy

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* fixing tests

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* display warning instead of success if export contains missing refs

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* nits/typo

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* properly updates api integration tests

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* fix typings

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* add test on objects_table component

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* remove added translations from jp/cn bundles

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* restoring line feeds

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* improve doc and user alert message

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* restoring line feeds on server.api.md

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* warning test label

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
@joshdover
Copy link
Copy Markdown
Contributor

Removing the breaking label as this is not a stable API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Saved Objects release_note:fix Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v7.5.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Saved objects export - unable to export when references are missing

6 participants