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

Add enhancements for legacy URL aliases #125960

Merged

Conversation

jportner
Copy link
Contributor

@jportner jportner commented Feb 17, 2022

Resolves #127047.

Overview

This PR makes a few changes:

  1. Legacy URL aliases now work in the Default space. There is currently no way to create them in the Default space organically, though -- that will come with a follow-on PR.
  2. Legacy URL aliases now include a purpose string attribute. This is returned to Saved Object consumers with resolve result as alias_purpose (only when the outcome is "aliasMatch" or "conflict").
  3. Legacy URL aliases created prior to version 8.2 now have a migration to set the purpose string attribute.
  4. The Spaces UI redirectLegacyUrl API now has a single options object parameter, and that requires a new aliasPurpose string option.

There are no bug fixes or user-facing features included in this PR, so I tagged it with release_note:skip.

Testing

For legacy URL aliases in the Default space:

I updated the integration tests accordingly.
I also include test data below to manually verify that aliases work in the Default space.

For aliasPurpose/alias_purpose:

If the purpose attribute is set in the legacy URL alias, then alias_purpose: true is included in the resolve / bulkResolve response.
The meat of this change is really in the UI for consumers of the redirectLegacyUrl API. Since this API changed, I updated all consumers of it. That said, it didn't feel necessary to add functional tests for different consumers for a simple attribute change.

I created test data to manually verify the changes work in the UI. Test procedures:

  1. Start a fresh local Kibana instance (without a basePath and without TLS enabled is easiest)
  2. Download the test data and scripts: sharing-saved-objects-test-data-3.zip
  3. Edit the load-test-data.sh script and modify any environment variables needed at the top of the file
  4. Execute the script to load the test data
  5. Log into Kibana
  6. Load each of the alias URLs below and observe that 1. you get redirected to a new URL, and 2. you do or don't see a toast after you are redirected.
Plugin Saved Object Default space links Another space links
dashboard dashboard redirect-with-toast,
redirect-without-toast
redirect-with-toast,
redirect-without-toast
discover search-session redirect-with-toast,
redirect-without-toast
redirect-with-toast,
redirect-without-toast
visualizations visualization redirect-with-toast,
redirect-without-toast
redirect-with-toast,
redirect-without-toast
canvas canvas-workpad redirect-with-toast,
redirect-without-toast
redirect-with-toast,
redirect-without-toast
cases cases redirect-with-toast,
redirect-without-toast
redirect-with-toast,
redirect-without-toast
graph graph-workspace redirect-with-toast,
redirect-without-toast
redirect-with-toast,
redirect-without-toast
lens lens redirect-with-toast,
redirect-without-toast
redirect-with-toast,
redirect-without-toast
maps map redirect-with-toast,
redirect-without-toast
redirect-with-toast,
redirect-without-toast
securitySolution timeline - -
securitySolution alert - -
triggersActionsUi alert - -

Note for the last three rows in the table: these usages of the redirectLegacyUrl API have been changed, but I wasn't able to figure out exactly how to test them in the UI as I'm not familiar with Kibana. I'd appreciate help from the codeowners here! You can manually create legacy URL aliases for a saved object using curl:

Manually create aliases

The curl command below will create two aliases, one that will redirect the user with a toast, and one that will redirect the user without a toast.

You can change the following values in the command:

  • Saved object type: alert
  • Saved object ID: 123
  • Space: default
curl -u superduperuser:changeme -XPOST "http://localhost:9200/.kibana/_bulk" -H 'Content-Type: application/json' -d'
{"index":{"_id":"legacy-url-alias:default:alert:redirect-without-toast"}}
{"coreMigrationVersion":"8.2.0","legacy-url-alias":{"purpose":"savedObjectImport","sourceId":"redirect-without-toast","targetId":"123","targetNamespace":"default","targetType":"alert"},"migrationVersion":{"legacy-url-alias":"8.2.0"},"references":[],"type":"legacy-url-alias"}
{"index":{"_id":"legacy-url-alias:default:alert:redirect-with-toast"}}
{"coreMigrationVersion":"8.2.0","legacy-url-alias":{"purpose":"savedObjectConversion","sourceId":"redirect-with-toast","targetId":"123","targetNamespace":"default","targetType":"alert"},"migrationVersion":{"legacy-url-alias":"8.2.0"},"references":[],"type":"legacy-url-alias"}
'

Docs changes

I updated the docs for Resolve, Bulk Resolve, and Sharing Saved Objects accordingly: preview link

@jportner jportner added release_note:fix auto-backport Deprecated - use backport:version if exact versions are needed v8.1.0 v8.2.0 v8.0.1 labels Feb 17, 2022
@jportner jportner force-pushed the issue-123550-fix-broken-weak-links-on-import branch 5 times, most recently from 54c0f2e to f03b7a9 Compare February 23, 2022 23:13
@jportner jportner removed the v8.0.1 label Feb 23, 2022
@jportner jportner force-pushed the issue-123550-fix-broken-weak-links-on-import branch 2 times, most recently from 045027c to a099924 Compare February 24, 2022 05:11
@jportner jportner added v8.1.1 and removed v8.1.0 labels Mar 1, 2022
Joe Portner added 2 commits March 7, 2022 09:51
If an alias has this optional boolean attribute set to "true", then
consumers that resolve the alias will avoid showing a toast message
upon redirecting users to the alias target.
@jportner jportner force-pushed the issue-123550-fix-broken-weak-links-on-import branch from a099924 to a8916f1 Compare March 7, 2022 14:53
@jportner jportner changed the title Add option to preserve weak links upon import/copy Add enhancements for legacy URL aliases Mar 7, 2022
@jportner jportner requested review from a team March 7, 2022 21:13
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.

So far, the approach makes sense to me.
I tested the PR out and it works as described.
Thanks for those fantastic test setup scripts!
We should probably get other folks from core to take a look too but that can happen after the PR is taken out of draft.

@pgayvallet
Copy link
Contributor

pgayvallet commented Mar 10, 2022

@jportner ack, will take a look next Monday

Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

Implementation LGTM in current state. I'm just a bit concerned about the suppressRedirectToast naming surfaced from the low-level SO APIs, but I guess that can be considered a NIT?

Joe Portner added 3 commits March 15, 2022 13:37
Changed from "suppressRedirectToast" boolean to "purpose" string.
The `resolve/bulkResolve` APIs interpret this and return the
"suppress_redirect_toast" field to consumers if "purpose" is
defined.
Copy link
Contributor

@thomheymann thomheymann left a comment

Choose a reason for hiding this comment

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

Tested locally and all looking good! 👍

Now when you resolve a saved object, if an alias exists, the
alias's purpose will be returned to the consumer.
Also adds a saved object migration to ensure that a purpose is set
for any existing aliases.
@jportner jportner added the release_note:skip Skip the PR/issue when compiling release notes label Mar 17, 2022
@jportner jportner requested a review from TinaHeiligers March 17, 2022 02:22
Copy link
Member

@cnasikas cnasikas left a comment

Choose a reason for hiding this comment

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

Tested locally. Cases changes LTGM!

@flash1293
Copy link
Contributor

@elasticmachine merge upstream

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

Vis editors changes LGTM, I tested the lens and TSVB examples and I also created manually an agg-based vis with a saved search both on default and on the another space. Everything works as expected!
Thanx for the detailed instructions Joe!

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.

DataDiscover.team code LGTM, thx for the great help providing test data, tested locally, Graph and Discover links work as expected. Would btw be a nice use case for our ci:deploy-cloud tag. Having a cloud instance with testdata already added for this would be 🍰

@jportner
Copy link
Contributor Author

@elasticmachine merge upstream

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.

LGTM
Thanks for updating the docs at the same time!

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

maps changes LGTM

Copy link
Contributor

@dhurley14 dhurley14 left a comment

Choose a reason for hiding this comment

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

Security Solution changes look good! I'm not sure if you saw this but we have some e2e tests around the resolve api in the security solution here https://github.com/elastic/kibana/blob/461415b24c98ed8430d729141bf243805e913083/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/resolve_read_rules.ts

Ran these tests locally and they passed but if you think it's worth adding / modifying an expect there feel free. Either way LGTM!

@jportner
Copy link
Contributor Author

Ran these tests locally and they passed but if you think it's worth adding / modifying an expect there feel free. Either way LGTM!

Nice! Added an assertion here: 8117ced

@jportner
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

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

Presentation team changes LGTM! The code changes make sense, just updating our usages of an API.

I couldn't test this locally due to a Kibana server error:
Screen Shot 2022-03-18 at 1 44 45 PM

It's unclear whether it's a problem in main, or a problem with my configuration. Either way, I'm approving to unblock as it seems like the changes have been tested quite thoroughly, and if there were any problems loading the dashboard or workpad saved objects, plenty of functional tests would have failed!

@jportner
Copy link
Contributor Author

jportner commented Mar 18, 2022

I spoke to @dhurley14 and we agreed to skip the failing Cypress test to "Mark one alert as acknowledged when more than one open alerts are selected":

it('Mark one alert as acknowledged when more than one open alerts are selected', () => {

These Cypress tests are only triggered when someone makes changes to the Security Solution code, so they aren't failing in our hourly CI builds or other PRs but he confirmed that this particular test is failing in the main branch.

Edit: skipped in ca8b683.

Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

LGTM

@jportner jportner enabled auto-merge (squash) March 18, 2022 18:34
@jportner jportner added backport:skip This commit does not require backporting and removed auto-backport Deprecated - use backport:version if exact versions are needed labels Mar 18, 2022
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
dashboard 148 149 +1
spaces 63 64 +1
total +2

Async chunks

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

id before after diff
canvas 1.0MB 1.0MB +4.0B
cases 292.8KB 292.9KB +105.0B
dashboard 294.8KB 294.8KB +39.0B
graph 449.3KB 449.4KB +60.0B
lens 1.1MB 1.1MB +62.0B
maps 2.5MB 2.5MB +62.0B
securitySolution 4.8MB 4.8MB +67.0B
triggersActionsUi 659.9KB 659.9KB +51.0B
visualizations 164.3KB 164.3KB +46.0B
total +496.0B

Page load bundle

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

id before after diff
cases 84.1KB 84.2KB +91.0B
core 295.9KB 295.9KB +30.0B
dashboard 66.4KB 66.5KB +68.0B
discover 50.4KB 50.5KB +82.0B
securitySolution 246.4KB 246.5KB +96.0B
spaces 20.3KB 20.4KB +71.0B
triggersActionsUi 96.5KB 96.5KB +32.0B
visualizations 45.5KB 45.6KB +31.0B
total +501.0B
Unknown metric groups

API count

id before after diff
core 2371 2374 +3
dashboard 150 151 +1
spaces 256 259 +3
total +7

ESLint disabled line counts

id before after diff
core 46 48 +2

Total ESLint disabled count

id before after diff
core 56 58 +2

History

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

@jportner jportner merged commit 4920ace into elastic:main Mar 18, 2022
@jportner jportner deleted the issue-123550-fix-broken-weak-links-on-import branch March 18, 2022 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes v8.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance legacy URL aliases for broader usage