-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Graph] Make Graph saved object share-capable #111404
Conversation
5d35bfc
to
6d46130
Compare
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
@@ -88,4 +88,5 @@ export const graphMigrations = { | |||
doc.references = []; | |||
return doc; | |||
}, | |||
'8.0.0': (doc: SavedObjectUnsanitizedDoc<any>) => doc, // no-op, bump migration version to satisfy integration tests after adding convertToMultiNamespaceTypeVersion to graph_workspace SO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bit shouldn't be necessary, and I don't think it will fix the integration tests.
Sorry I should have probably clarified, specifying convertToMultiNamespaceTypeVersion
causes Core to add a special migration under the hood, so any Graph objects created will automatically have a migrationVersion of 8.0.0.
I think the problem in this case is the test data is actually malformed, it happened to work before but now it does not, so the test data needs to be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this locally and it did fix the test... I'll try to see what you mean by malformed data. Btw I based this PR on https://github.com/elastic/kibana/pull/110386/files, how come it is helpful there and not here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this locally and it did fix the test... I'll try to see what you mean by malformed data.
Sorry, I got this PR for Graph confused with the other one for Lens #111403 (review)
So ignore what I said about malformed data!
Btw I based this PR on https://github.com/elastic/kibana/pull/110386/files, how come it is helpful there and not here?
That PR is for Alerting, which uses encrypted saved objects. They need a no-op migration function that will decrypt and re-encrypt the object (Step 5 of the Sharing Saved Objects dev guide). We had to do it that way because of the way encryption is handled in a plugin, not in Core.
Anyway, you adding a no-op migration here doesn't hurt anything, but it shouldn't be needed to pass CI. If it is needed, that might be indicative of a Core bug that I need to fix.
What exactly was the test failure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's reproducible locally. Without my changes in migrations file the version for graph_workspace
stays on the last explicit migration (7.11).
The actual version is equal 8.0.0 (correct) and the expectedVersion is wrong. That's because the expected one is read for all saved objects here: https://github.com/elastic/kibana/blob/master/src/core/server/saved_objects/migrationsv2/integration_tests/migration_from_v1.test.ts#L116 from type.migrations
property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh, okay, thanks for clarifying.
So yeah, I think in this case the core integration test needs to be changed, you shouldn't have to add this no-op to pass the test 😄
If you can wait a day or two, I'd be happy to add the Core changes and test them out locally. We can merge them in this PR if you're OK with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, it can wait till 8.0.0! 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, it appears to be after working hours for you so I took the liberty of just pushing the changes to this branch to get CI started, I hope you don't mind 🙂
This reverts commit 04d2f49.
This reverts commit 7b0a74d.
The existing tests incorrectly asserted an object's `migrationVersion` solely based on the registered type's `migration` field; in reality, the `convertToMultiNamespaceTypeVersion` field is also used when determining an object's `migrationVersion`. This commit simply updates the test to reflect that.
namespaceType: 'multiple-isolated', | ||
convertToMultiNamespaceTypeVersion: '8.0.0', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jportner we don't need to adapt any call to use resolve
instead of get
for this specific SO type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done separately in this PR: #109617
if (migrations || convertToMultiNamespaceTypeVersion) { | ||
const migrationsMap = typeof migrations === 'function' ? migrations() : migrations; | ||
const migrationsKeys = migrationsMap ? Object.keys(migrationsMap) : []; | ||
if (convertToMultiNamespaceTypeVersion) { | ||
// Setting this option registers a conversion migration that is reflected in the object's `migrationVersions` field | ||
migrationsKeys.push(convertToMultiNamespaceTypeVersion); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QQ: so you're checking for convertToMultiNamespaceTypeVersion
2 times. if think the first is redundant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convertToMultiNamespaceTypeVersion
will impact the object's migrationVersion
regardless of whether a migrations
object/function is defined or not.
To rephrase: the union of the object type definition's migrations
and convertToMultiNamespaceTypeVersion
determines the resulting objects' migrationVersion
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kertal in 122 line it's ||
operation so all good :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, do not have objections in terms of Grpah. Code review only.
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 , code review, didn't test
…-link-to-kibana-app * 'master' of github.com:elastic/kibana: (120 commits) [TSVB] Support custom field format (elastic#101245) [VisEditors] Add code ownership to the functional tests (elastic#111680) [Lens] Make Lens saved object share-capable (elastic#111403) [Graph] Make Graph saved object share-capable (elastic#111404) [Stack Monitoring] Add breadcrumb support (elastic#111850) Update Jira Cloud to use OAuth2.0 (elastic#111493) Show warning message when attempting to create an APM alert in stack management (elastic#111781) Skip suite blocking ES snapshot promotion (elastic#111907) Respect `auth_provider_hint` if session is not authenticated. (elastic#111521) Added in 'Responses' field in alert telemetry & updated test (elastic#111892) [Usage collection] refactor cloud detector collector (elastic#110439) Make classnames a shared dep (elastic#111636) Fix link to e2e tests in APM testing.md (elastic#111869) [Security Solution] Add host.os.name.caseless mapping and runtime field (elastic#111455) [APM] Removes the beta label from APM tutorial (elastic#111499) (elastic#111828) [RAC] [Observability] Expand Observability alerts page functional tests (elastic#111297) Fix extra white space on the alert table whe page size is 50 or 100 (elastic#111568) [Metrics UI] Add Inventory Timeline open/close state to context and URL state (elastic#111034) [Graph] Switch to SavedObjectClient.resolve (elastic#109617) [APM] Adding lambda icon (elastic#111834) ... # Conflicts: # x-pack/plugins/reporting/public/management/__snapshots__/report_listing.test.tsx.snap
To be merged preferably after: #109617
Fixes #105812
Step 4 of https://www.elastic.co/guide/en/kibana/master/sharing-saved-objects.html#sharing-saved-objects-step-4
Checklist
Delete any items that are not applicable to this PR.
Risk Matrix
Delete this section if it is not applicable to this PR.
Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.
When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:
For maintainers