Skip to content

Lens client side shim cleanup#56976

Merged
flash1293 merged 17 commits intoelastic:masterfrom
flash1293:lens-cleanup
Feb 13, 2020
Merged

Lens client side shim cleanup#56976
flash1293 merged 17 commits intoelastic:masterfrom
flash1293:lens-cleanup

Conversation

@flash1293
Copy link
Copy Markdown
Contributor

@flash1293 flash1293 commented Feb 6, 2020

Fixes #56726
Fixes #55909

This PR cleans up the plugin shim to prepare the migration to the new platform.

  • Pass down dependencies from the root plugin to all visualizations and datasources
  • Remove direct legacy imports in favor of passed down services where possible
  • Move actual legacy dependencies either into a __LEGACY plugin or into legacy_imports

I had to change one thing in the API because the indexpattern datasource needs start contracts for some things. I solved this by allowing a promise of a datasource/visualization definition as well when registering.

While everything is initialized from a central top level plugin instance, I still kept the general structure of services that are shaped like plugins - this will make it easy to break out individual parts into separate plugins if we ever decide to do so.

@flash1293
Copy link
Copy Markdown
Contributor Author

Jenkins, test this.

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

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

@flash1293 flash1293 marked this pull request as ready for review February 7, 2020 13:27
@flash1293 flash1293 requested a review from a team February 7, 2020 13:27
@flash1293 flash1293 requested a review from a team as a code owner February 7, 2020 13:27
@flash1293 flash1293 added the Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// label Feb 7, 2020
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

Copy link
Copy Markdown
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

There are a few inconsistencies with our SASS patterns, but those existed before and I can fix those in a follow up. Other than that the file renames LGTM 👍

definitions.map(definition =>
definition instanceof Promise ? definition : Promise.resolve(definition)
)
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Promise.all can take non-Promise objects and passes them through automatically. I think this is equivalent to:

const resolvedDefinitions = await Promise.all(definitions);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Wow thanks, TIL.

Copy link
Copy Markdown
Contributor

@wylieconlon wylieconlon left a comment

Choose a reason for hiding this comment

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

Overall, changes LGTM! I previously left one comment but it's a nitpick.

@kibanamachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky


Test Failures

Kibana Pipeline / kibana-xpack-agent / Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/advanced_settings/feature_controls/advanced_settings_security·ts.Advanced Settings security feature controls no advanced_settings privileges does not allow navigation to advanced settings; redirects to management home

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has failed 5 times on tracked branches: https://github.com/elastic/kibana/issues/57377

[00:00:00]       │
[00:00:00]         └-: Advanced Settings
[00:00:00]           └-> "before all" hook
[00:00:00]           └-: security feature controls
[00:00:00]             └-> "before all" hook
[00:00:00]             └-> "before all" hook
[00:00:00]               │ info [empty_kibana] Loading "mappings.json"
[00:00:00]               │ info [empty_kibana] Loading "data.json.gz"
[00:00:00]               │ info [o.e.c.m.MetaDataDeleteIndexService] [kibana-ci-immutable-centos-tests-xl-1581592307533976452] [.kibana_1/CL92jNucRt-OosSdrx0l1w] deleting index
[00:00:00]               │ info [empty_kibana] Deleted existing index [".kibana_1"]
[00:00:00]               │ info [o.e.c.m.MetaDataCreateIndexService] [kibana-ci-immutable-centos-tests-xl-1581592307533976452] [.kibana] creating index, cause [api], templates [], shards [1]/[1], mappings [_doc]
[00:00:00]               │ info [empty_kibana] Created index ".kibana"
[00:00:00]               │ debg [empty_kibana] ".kibana" settings {"index":{"number_of_replicas":"1","number_of_shards":"1"}}
[00:00:00]               │ info [empty_kibana] Indexed 2 docs into ".kibana"
[00:00:39]               │ info [o.e.c.m.MetaDataMappingService] [kibana-ci-immutable-centos-tests-xl-1581592307533976452] [.kibana/WYFkgh1DRV69VLZjt1dxLQ] update_mapping [_doc]
[00:00:41]               │ info Creating index .kibana_2.
[00:00:41]               │ info [o.e.c.m.MetaDataCreateIndexService] [kibana-ci-immutable-centos-tests-xl-1581592307533976452] [.kibana_2] creating index, cause [api], templates [], shards [1]/[1], mappings [_doc]
[00:00:41]               │ info [o.e.c.r.a.AllocationService] [kibana-ci-immutable-centos-tests-xl-1581592307533976452] updating number_of_replicas to [0] for indices [.kibana_2]
[00:00:41]               │ info Reindexing .kibana to .kibana_1
[00:00:41]               │ info [o.e.c.m.MetaDataCreateIndexService] [kibana-ci-immutable-centos-tests-xl-1581592307533976452] [.kibana_1] creating index, cause [api], templates [], shards [1]/[1], mappings [_doc]
[00:00:41]               │ info [o.e.c.r.a.AllocationService] [kibana-ci-immutable-centos-tests-xl-1581592307533976452] updating number_of_replicas to [0] for indices [.kibana_1]
[00:00:41]               │ info [o.e.c.m.MetaDataCreateIndexService] [kibana-ci-immutable-centos-tests-xl-1581592307533976452] [.tasks] creating index, cause [auto(task api)], templates [], shards [1]/[1], mappings [_doc]
[00:00:41]               │ info [o.e.c.r.a.AllocationService] [kibana-ci-immutable-centos-tests-xl-1581592307533976452] updating number_of_replicas to [0] for indices [.tasks]
[00:00:42]               │ info [o.e.t.LoggingTaskListener] [kibana-ci-immutable-centos-tests-xl-1581592307533976452] 779 finished with response BulkByScrollResponse[took=71.8ms,timed_out=false,sliceId=null,updated=0,created=4,deleted=0,batches=1,versionConflicts=0,noops=0,retries=0,throttledUntil=0s,bulk_failures=[],search_failures=[]]
[00:00:42]               │ info [o.e.c.m.MetaDataDeleteIndexService] [kibana-ci-immutable-centos-tests-xl-1581592307533976452] [.kibana/WYFkgh1DRV69VLZjt1dxLQ] deleting index
[00:00:42]               │ info Migrating .kibana_1 saved objects to .kibana_2
[00:00:42]               │ debg Migrating saved objects config:6.0.0-alpha1, space:default, maps-telemetry:maps-telemetry, config:8.0.0-SNAPSHOT
[00:00:42]               │ info [o.e.c.m.MetaDataMappingService] [kibana-ci-immutable-centos-tests-xl-1581592307533976452] [.kibana_2/XV8tqw2NRDyTvtlhqdw5qw] update_mapping [_doc]
[00:00:42]               │ info [o.e.c.m.MetaDataMappingService] [kibana-ci-immutable-centos-tests-xl-1581592307533976452] [.kibana_2/XV8tqw2NRDyTvtlhqdw5qw] update_mapping [_doc]
[00:00:42]               │ info Pointing alias .kibana to .kibana_2.
[00:00:42]               │ info Finished in 841ms.
[00:00:42]               │ debg applying update to kibana config: {"accessibility:disableAnimations":true,"dateFormat:tz":"UTC"}
[00:00:42]               │ info [o.e.c.m.MetaDataMappingService] [kibana-ci-immutable-centos-tests-xl-1581592307533976452] [.kibana_2/XV8tqw2NRDyTvtlhqdw5qw] update_mapping [_doc]
[00:02:50]             └-: no advanced_settings privileges
[00:02:50]               └-> "before all" hook
[00:02:50]               └-> "before all" hook
[00:02:50]                 │ debg creating role no_advanced_settings_privileges_role
[00:02:50]                 │ info [o.e.x.s.a.r.TransportPutRoleAction] [kibana-ci-immutable-centos-tests-xl-1581592307533976452] added role [no_advanced_settings_privileges_role]
[00:02:50]                 │ debg created role no_advanced_settings_privileges_role
[00:02:50]                 │ debg creating user no_advanced_settings_privileges_user
[00:02:50]                 │ info [o.e.x.s.a.u.TransportPutUserAction] [kibana-ci-immutable-centos-tests-xl-1581592307533976452] added user [no_advanced_settings_privileges_user]
[00:02:50]                 │ debg created user no_advanced_settings_privileges_user
[00:02:50]                 │ debg navigating to login url: http://localhost:6131/login
[00:02:50]                 │ debg Navigate to: http://localhost:6131/login
[00:02:50]                 │ proc [kibana]   log   [11:48:59.095] [info][authentication][plugins][security] Authentication attempt failed: [security_exception] unable to authenticate user [global_advanced_settings_read_user] for REST request [/_security/_authenticate], with { header={ WWW-Authenticate="Basic realm=\"security\" charset=\"UTF-8\"" } }
[00:02:50]                 │ debg ... sleep(700) start
[00:02:50]                 │ERROR browser[SEVERE] http://localhost:6131/ - Failed to load resource: the server responded with a status of 401 (Unauthorized)
[00:02:51]                 │ debg ... sleep(700) end
[00:02:51]                 │ debg returned from get, calling refresh
[00:02:51]                 │ debg browser[INFO] http://localhost:6131/login?next=%2F 350 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-P5polb1UreUSOe5V/Pv7tc+yeZuJXiOi/3fqhGsU7BE='), or a nonce ('nonce-...') is required to enable inline execution.
[00:02:51]                 │
[00:02:51]                 │ debg browser[INFO] http://localhost:6131/bundles/app/login/bootstrap.js 9:19 "^ A single error about an inline script not firing due to content security policy is expected!"
[00:02:51]                 │ debg currentUrl = http://localhost:6131/login?next=%2F
[00:02:51]                 │          appUrl = http://localhost:6131/login
[00:02:51]                 │ debg Find.findByCssSelector('[data-test-subj="kibanaChrome"]') with timeout=60000
[00:02:56]                 │ debg browser[INFO] http://localhost:6131/bundles/plugin/data/data.plugin.js 67:139970 "INFO: 2020-02-13T11:49:04Z
[00:02:56]                 │        Adding connection to http://localhost:6131/elasticsearch
[00:02:56]                 │
[00:02:56]                 │      "
[00:02:56]                 │ debg ... sleep(501) start
[00:02:57]                 │ debg ... sleep(501) end
[00:02:57]                 │ debg in navigateTo url = http://localhost:6131/login?next=%2F#/
[00:02:57]                 │ debg TestSubjects.exists(statusPageContainer)
[00:02:57]                 │ debg Find.existsByDisplayedByCssSelector('[data-test-subj="statusPageContainer"]') with timeout=2500
[00:02:59]                 │ debg --- retry.tryForTime error: [data-test-subj="statusPageContainer"] is not displayed
[00:03:00]                 │ debg TestSubjects.setValue(loginUsername, no_advanced_settings_privileges_user)
[00:03:00]                 │ debg TestSubjects.click(loginUsername)
[00:03:00]                 │ debg Find.clickByCssSelector('[data-test-subj="loginUsername"]') with timeout=10000
[00:03:00]                 │ debg Find.findByCssSelector('[data-test-subj="loginUsername"]') with timeout=10000
[00:03:00]                 │ debg TestSubjects.setValue(loginPassword, no_advanced_settings_privileges_user-password)
[00:03:00]                 │ debg TestSubjects.click(loginPassword)
[00:03:00]                 │ debg Find.clickByCssSelector('[data-test-subj="loginPassword"]') with timeout=10000
[00:03:00]                 │ debg Find.findByCssSelector('[data-test-subj="loginPassword"]') with timeout=10000
[00:03:01]                 │ debg TestSubjects.click(loginSubmit)
[00:03:01]                 │ debg Find.clickByCssSelector('[data-test-subj="loginSubmit"]') with timeout=10000
[00:03:01]                 │ debg Find.findByCssSelector('[data-test-subj="loginSubmit"]') with timeout=10000
[00:03:01]                 │ debg Waiting up to 20000ms for logout button visible...
[00:03:01]                 │ debg TestSubjects.exists(userMenuButton)
[00:03:01]                 │ debg Find.existsByDisplayedByCssSelector('[data-test-subj="userMenuButton"]') with timeout=2500
[00:03:04]                 │ debg browser[INFO] http://localhost:6131/app/kibana#/ 350 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-P5polb1UreUSOe5V/Pv7tc+yeZuJXiOi/3fqhGsU7BE='), or a nonce ('nonce-...') is required to enable inline execution.
[00:03:04]                 │
[00:03:04]                 │ debg browser[INFO] http://localhost:6131/bundles/app/kibana/bootstrap.js 9:19 "^ A single error about an inline script not firing due to content security policy is expected!"
[00:03:04]                 │ debg --- retry.tryForTime error: [data-test-subj="userMenuButton"] is not displayed
[00:03:05]                 │ debg browser[INFO] http://localhost:6131/bundles/plugin/data/data.plugin.js 67:139970 "INFO: 2020-02-13T11:49:14Z
[00:03:05]                 │        Adding connection to http://localhost:6131/elasticsearch
[00:03:05]                 │
[00:03:05]                 │      "
[00:03:05]                 │ debg TestSubjects.exists(userMenuButton)
[00:03:05]                 │ debg Find.existsByDisplayedByCssSelector('[data-test-subj="userMenuButton"]') with timeout=2500
[00:03:07]                 │ debg TestSubjects.exists(userMenu)
[00:03:07]                 │ debg Find.existsByDisplayedByCssSelector('[data-test-subj="userMenu"]') with timeout=2500
[00:03:09]                 │ debg --- retry.tryForTime error: [data-test-subj="userMenu"] is not displayed
[00:03:10]                 │ debg TestSubjects.click(userMenuButton)
[00:03:10]                 │ debg Find.clickByCssSelector('[data-test-subj="userMenuButton"]') with timeout=10000
[00:03:10]                 │ debg Find.findByCssSelector('[data-test-subj="userMenuButton"]') with timeout=10000
[00:03:10]                 │ debg Waiting up to 20000ms for user menu opened...
[00:03:10]                 │ debg TestSubjects.exists(userMenu)
[00:03:10]                 │ debg Find.existsByDisplayedByCssSelector('[data-test-subj="userMenu"]') with timeout=2500
[00:03:10]                 │ debg TestSubjects.exists(userMenu > logoutLink)
[00:03:10]                 │ debg Find.existsByDisplayedByCssSelector('[data-test-subj="userMenu"] [data-test-subj="logoutLink"]') with timeout=2500
[00:03:10]               └-> shows Management navlink
[00:03:10]                 └-> "before each" hook: global before each
[00:03:10]                 │ debg TestSubjects.find(navDrawer)
[00:03:10]                 │ debg Find.findByCssSelector('[data-test-subj="navDrawer"]') with timeout=10000
[00:03:10]                 └- ✓ pass  (31ms) "Advanced Settings security feature controls no advanced_settings privileges shows Management navlink"
[00:03:10]               └-> does not allow navigation to advanced settings; redirects to management home
[00:03:10]                 └-> "before each" hook: global before each
[00:03:10]                 │ debg navigateToActualUrl http://localhost:6131/app/kibana#management/kibana/settings
[00:03:10]                 │ debg browser[INFO] http://localhost:6131/app/kibana?_t=1581594558955#management/kibana/settings 350 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-P5polb1UreUSOe5V/Pv7tc+yeZuJXiOi/3fqhGsU7BE='), or a nonce ('nonce-...') is required to enable inline execution.
[00:03:10]                 │
[00:03:10]                 │ debg browser[INFO] http://localhost:6131/bundles/app/kibana/bootstrap.js 9:19 "^ A single error about an inline script not firing due to content security policy is expected!"
[00:03:10]                 │ debg TestSubjects.exists(managementHome)
[00:03:10]                 │ debg Find.existsByDisplayedByCssSelector('[data-test-subj="managementHome"]') with timeout=10000
[00:03:14]                 │ debg --- retry.tryForTime error: [data-test-subj="managementHome"] is not displayed
[00:03:15]                 │ debg browser[INFO] http://localhost:6131/bundles/plugin/data/data.plugin.js 67:139970 "INFO: 2020-02-13T11:49:23Z
[00:03:15]                 │        Adding connection to http://localhost:6131/elasticsearch
[00:03:15]                 │
[00:03:15]                 │      "
[00:03:20]                 │ debg browser[INFO] http://localhost:6131/app/kibana#/management 350 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-P5polb1UreUSOe5V/Pv7tc+yeZuJXiOi/3fqhGsU7BE='), or a nonce ('nonce-...') is required to enable inline execution.
[00:03:20]                 │
[00:03:20]                 │ debg browser[INFO] http://localhost:6131/bundles/app/kibana/bootstrap.js 9:19 "^ A single error about an inline script not firing due to content security policy is expected!"
[00:03:20]                 │ debg browser[INFO] http://localhost:6131/bundles/plugin/data/data.plugin.js 67:139970 "INFO: 2020-02-13T11:49:28Z
[00:03:20]                 │        Adding connection to http://localhost:6131/elasticsearch
[00:03:20]                 │
[00:03:20]                 │      "
[00:03:20]                 │ debg --- retry.tryForTime failed again with the same message...
[00:03:21]                 │ info Taking screenshot "/dev/shm/workspace/kibana/x-pack/test/functional/screenshots/failure/Advanced Settings security feature controls no advanced_settings privileges does not allow navigation to advanced settings_ redirects to management home.png"
[00:03:22]                 │ info Current URL is: http://localhost:6131/app/kibana#/management?_g=()
[00:03:22]                 │ info Saving page source to: /dev/shm/workspace/kibana/x-pack/test/functional/failure_debug/html/Advanced Settings security feature controls no advanced_settings privileges does not allow navigation to advanced settings_ redirects to management home.html
[00:03:23]                 └- ✖ fail: "Advanced Settings security feature controls no advanced_settings privileges does not allow navigation to advanced settings; redirects to management home"
[00:03:23]                 │

Stack Trace

Error: expected testSubject(managementHome) to exist
    at TestSubjects.existOrFail (/dev/shm/workspace/kibana/test/functional/services/test_subjects.ts:60:15)

History

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

@flash1293 flash1293 merged commit 4437858 into elastic:master Feb 13, 2020
@flash1293 flash1293 deleted the lens-cleanup branch February 13, 2020 12:54
flash1293 added a commit to flash1293/kibana that referenced this pull request Feb 13, 2020
mbondyra added a commit to mbondyra/kibana that referenced this pull request Feb 13, 2020
* master: (22 commits)
  Use log4j pattern syntax (elastic#57433)
  [ML] Categorization field example endpoint tests (elastic#57471)
  [Lens] Filter out pinned filters from saved object of Lens (elastic#57197)
  Lens client side shim cleanup (elastic#56976)
  [Maps] do not show border color for icon in legend when border width is zero (elastic#57501)
  refactors 'data-providers' tests (elastic#57474)
  add `absolute` option to `getUrlForApp` (elastic#57193)
  [Telemetry] Migrate public to NP (elastic#56285)
  address flaky test where instances might have different start… (elastic#57506)
  fix(NA): support legacy plugins path in plugins (elastic#57472)
  build immutable bundles for new platform plugins (elastic#53976)
  [SIEM] [Detection Engine] Reject if duplicate rule_id in request payload (elastic#57057)
  Add autocomplete="off" for input type="password" to appease the scanners (elastic#56922)
  Use default spaces suffix for signals index if spaces disabled (elastic#57244)
  [Alerting] Create alert design cleanup (elastic#56929)
  Management Api - add to migration guide (elastic#56892)
  fixing maps (elastic#56706)
  [Maps] Autocomplete for custom color palettes and custom icon palettes (elastic#56446)
  [Alerting] make actionGroup name's i18n-able (elastic#57404)
  fixed flaky test (elastic#57490)
  ...

# Conflicts:
#	src/legacy/core_plugins/telemetry/public/components/__snapshots__/telemetry_form.test.js.snap
#	src/plugins/telemetry/public/components/telemetry_management_section.tsx
gmmorris added a commit to gmmorris/kibana that referenced this pull request Feb 13, 2020
* master: (22 commits)
  skip flaky suite (elastic#50018)
  skip settings tests (elastic#57608)
  skip failing suite (elastic#44631)
  [SIEM] [Case] Initial UI (elastic#57283)
  handle viewing sample dashboards on default dist (elastic#57510)
  Fix detection of "system requests" in plugins (elastic#57149)
  [ML] New Platform server shim: update job service schema (elastic#57614)
  skip flaky suite (elastic#44631)
  [APM] Update monospace font family variable (elastic#57555)
  skip flaky test (elastic#57377)
  Skip save query tests (elastic#57589)
  [Maps] allow simultaneous opening of multiple tooltips (elastic#57226)
  [Uptime] Fix/host connected components (elastic#56969)
  [logs][metrics][docs] Update screenshots for 7.6 (elastic#57254)
  [ML] New Platform server shim: update job service routes to use new platform router (elastic#57403)
  [Maps] Fix document source top hits split by scripted field (elastic#57481)
  Use log4j pattern syntax (elastic#57433)
  [ML] Categorization field example endpoint tests (elastic#57471)
  [Lens] Filter out pinned filters from saved object of Lens (elastic#57197)
  Lens client side shim cleanup (elastic#56976)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Lens Feature:NP Migration release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v7.7.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up Lens shimmed plugin [Lens] Expose a top-level plugin for embedding and registration, hide other folders

5 participants