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

[SOR] use initialNamespaces when checking for conflict for create and bulkCreate #111023

Merged

Conversation

pgayvallet
Copy link
Contributor

@pgayvallet pgayvallet commented Sep 2, 2021

Summary

Found during #109196

Uses object.initialNamespaces when present, instead of the provided namespace, when checking for conflicts during create and bulkCreate operations

Checklist

@pgayvallet pgayvallet added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.16.0 v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Feature:Saved Objects labels Sep 2, 2021
Copy link
Contributor

@jportner jportner left a comment

Choose a reason for hiding this comment

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

LGTM, couple of nits below. Thanks for fixing this 🙏

@@ -778,6 +790,54 @@ describe('SavedObjectsRepository', () => {
});
});

it(`returns error when there is a conflict with an existing multi-namespace saved object with initialNamespaces (get)`, async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
it(`returns error when there is a conflict with an existing multi-namespace saved object with initialNamespaces (get)`, async () => {
it(`returns error when there is an unresolvable conflict with an existing multi-namespace saved object when using initialNamespaces (get)`, async () => {

@@ -2160,6 +2220,22 @@ describe('SavedObjectsRepository', () => {
expect(client.get).toHaveBeenCalled();
});

it(`throws when there is a conflict with an existing multi-namespace saved object when using initialNamespaces (get)`, async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
it(`throws when there is a conflict with an existing multi-namespace saved object when using initialNamespaces (get)`, async () => {
it(`throws when there is an unresolvable conflict with an existing multi-namespace saved object when using initialNamespaces (get)`, async () => {

}
const namespaceId = namespaces[0] === 'default' ? undefined : namespaces[0];

// const namespaceId = objectNamespace === 'default' ? undefined : objectNamespace ?? namespace;
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you forget to delete this?

Suggested change
// const namespaceId = objectNamespace === 'default' ? undefined : objectNamespace ?? namespace;

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 sure did !

@jportner
Copy link
Contributor

jportner commented Sep 2, 2021

Note: I would say we should backport this to 7.15, but it depends on #109967 which was only backported to 7.16.
WDYT? Perhaps we need to backport that, too? I hate to do it after feature freeze but this is a pretty terrible bug IMO

Edit: then again, it only affects multi-ns objects, of which we only have ML jobs in 7.x, so maybe it's not a big deal if we don't fix this in 7.15.

@kibanamachine
Copy link
Contributor

⏳ Build in-progress, with failures

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

@pgayvallet
Copy link
Contributor Author

retest

@pgayvallet pgayvallet added the auto-backport Deprecated - use backport:version if exact versions are needed label Sep 2, 2021
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

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

@pgayvallet pgayvallet marked this pull request as ready for review September 2, 2021 23:09
@pgayvallet pgayvallet requested a review from a team as a code owner September 2, 2021 23:09
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@@ -2140,12 +2150,18 @@ export class SavedObjectsRepository {
* @param type The type of the saved object.
* @param id The ID of the saved object.
* @param namespace The target namespace.
* @param initialNamespaces The target namespace(s) we intend to create the object in, if specified.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: The difference between namespace and initialNamespaces is subtle and it might be worth adding a bit more info here about when each is used.

@TinaHeiligers TinaHeiligers self-requested a review September 3, 2021 00:16
Copy link
Contributor

@TinaHeiligers TinaHeiligers left a comment

Choose a reason for hiding this comment

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

A small (very optional) nit, otherwise thanks for getting this done so quickly!
LGTM

@pgayvallet pgayvallet merged commit 9d216cd into elastic:master Sep 3, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Sep 3, 2021
…nd `bulkCreate` (elastic#111023)

* use initialNamespaces when checking for conflict

* nits
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Sep 3, 2021
…nd `bulkCreate` (#111023) (#111084)

* use initialNamespaces when checking for conflict

* nits

Co-authored-by: Pierre Gayvallet <[email protected]>
jloleysens added a commit to jloleysens/kibana that referenced this pull request Sep 3, 2021
…eporting-to-v2

* 'master' of github.com:elastic/kibana: (65 commits)
  Move to vis_types folder part 2 (elastic#110574)
  [SOR] use initialNamespaces when checking for conflict for `create` and `bulkCreate` (elastic#111023)
  [Discover] Remove export* syntax (elastic#110934)
  [Event log][7.x] Updated event log client to search across legacy IDs (elastic#109365)
  [Security Solution][Detection Rules] Changes 'activated' text on rule details page  (elastic#111044)
  [Metrics UI] Filter out APM nodes from the inventory view (elastic#110300)
  [package testing] Update logging and pid configuration (elastic#111059)
  [Dashboard] Read App State from URL on Soft Refresh (elastic#109354)
  Add correct roles to test user for functional tests in dashboard (elastic#110880)
  [DOCS] Adds Lens Inspector and minor edits (elastic#109736)
  [DOCS] Updates Spaces page (elastic#111005)
  normalize initialNamespaces (elastic#110936)
  [Reporting] Clean up `any` usage, reorganize server route files (elastic#110740)
  [Security Solution] [CTI] Fixes bug that caused Threshold and Indicator Match rules to ignore custom rule filters if a saved query was used in the rule definition. (elastic#109253)
  skip flaky suites: elastic#111001, elastic#111022
  [Security Solution][RAC] - Update reason field text (elastic#110308)
  [RAC][Security Solution] Make analyzer work with EuiDataGrid full screen (elastic#110913)
  [Metrics UI] Add integration tests for Metric Threshold Rule and refactor to fire correctly (elastic#109971)
  [DOCS] Updates Discover docs (elastic#110346)
  [RAC] Persistent timeline fields fix (elastic#110685)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Feature:Saved Objects release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants