kibana/packages
Gerard Soldevila 42bf33f146
[8.6] Reduce startup time by skipping update mappings step when possible (#145604) (#146637)
# Backport

This will backport the following commits from `main` to `8.6`:
- [Reduce startup time by skipping update mappings step when possible
(#145604)](https://github.com/elastic/kibana/pull/145604)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Gerard
Soldevila","email":"gerard.soldevila@elastic.co"},"sourceCommit":{"committedDate":"2022-11-28T14:34:58Z","message":"Reduce
startup time by skipping update mappings step when possible
(#145604)\n\nThe goal of this PR is to reduce the startup times of
Kibana server by\r\nimproving the migration logic.\r\n\r\nFixes
https://github.com/elastic/kibana/issues/145743\r\nRelated
https://github.com/elastic/kibana/issues/144035)\r\n\r\nThe migration
logic is run systematically at startup, whether the\r\ncustomers are
upgrading or not.\r\nHistorically, these steps have been very quick, but
we recently found\r\nout about some customers that have more than **one
million** Saved\r\nObjects stored, making the overall startup process
slow, even when there\r\nare no migrations to perform.\r\n\r\nThis PR
specifically targets the case where there are no migrations
to\r\nperform, aka a Kibana node is started against an ES cluster that
is\r\nalready up to date wrt stack version and list of
plugins.\r\n\r\nIn this scenario, we aim at skipping the
`UPDATE_TARGET_MAPPINGS` step\r\nof the migration logic, which
internally runs the\r\n`updateAndPickupMappings` method, which turns out
to be expensive if the\r\nsystem indices contain lots of
SO.\r\n\r\n\r\nI locally tested the following scenarios too:\r\n\r\n-
**Fresh install.** The step is not even run, as the `.kibana`
index\r\ndid not exist \r\n- **Stack version + list of plugins up to
date.** Simply restarting\r\nKibana after the fresh install. The step is
run and leads to `DONE`, as\r\nthe md5 hashes match those stored in
`.kibana._mapping._meta` \r\n- **Faking re-enabling an old plugin.** I
manually removed one of the\r\nMD5 hashes from the stored
.kibana._mapping._meta through `curl`, and\r\nthen restarted Kibana. The
step is run and leads to\r\n`UPDATE_TARGET_MAPPINGS` as it used to
before the PR \r\n- **Faking updating a plugin.** Same as the previous
one, but altering\r\nan existing md5 stored in the metas. \r\n\r\nAnd
that is the curl command used to tamper with the stored
_meta:\r\n```bash\r\ncurl -X PUT
\"kibana:changeme@localhost:9200/.kibana/_mapping?pretty\" -H
'Content-Type: application/json' -d'\r\n{\r\n \"_meta\": {\r\n
\"migrationMappingPropertyHashes\": {\r\n \"references\":
\"7997cf5a56cc02bdc9c93361bde732b0\",\r\n }\r\n
}\r\n}\r\n'\r\n```","sha":"b1e18a0414ed99456706119d15173b687c6e7366","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","enhancement","release_note:skip","Feature:Migrations","backport:prev-minor","v8.7.0"],"number":145604,"url":"https://github.com/elastic/kibana/pull/145604","mergeCommit":{"message":"Reduce
startup time by skipping update mappings step when possible
(#145604)\n\nThe goal of this PR is to reduce the startup times of
Kibana server by\r\nimproving the migration logic.\r\n\r\nFixes
https://github.com/elastic/kibana/issues/145743\r\nRelated
https://github.com/elastic/kibana/issues/144035)\r\n\r\nThe migration
logic is run systematically at startup, whether the\r\ncustomers are
upgrading or not.\r\nHistorically, these steps have been very quick, but
we recently found\r\nout about some customers that have more than **one
million** Saved\r\nObjects stored, making the overall startup process
slow, even when there\r\nare no migrations to perform.\r\n\r\nThis PR
specifically targets the case where there are no migrations
to\r\nperform, aka a Kibana node is started against an ES cluster that
is\r\nalready up to date wrt stack version and list of
plugins.\r\n\r\nIn this scenario, we aim at skipping the
`UPDATE_TARGET_MAPPINGS` step\r\nof the migration logic, which
internally runs the\r\n`updateAndPickupMappings` method, which turns out
to be expensive if the\r\nsystem indices contain lots of
SO.\r\n\r\n\r\nI locally tested the following scenarios too:\r\n\r\n-
**Fresh install.** The step is not even run, as the `.kibana`
index\r\ndid not exist \r\n- **Stack version + list of plugins up to
date.** Simply restarting\r\nKibana after the fresh install. The step is
run and leads to `DONE`, as\r\nthe md5 hashes match those stored in
`.kibana._mapping._meta` \r\n- **Faking re-enabling an old plugin.** I
manually removed one of the\r\nMD5 hashes from the stored
.kibana._mapping._meta through `curl`, and\r\nthen restarted Kibana. The
step is run and leads to\r\n`UPDATE_TARGET_MAPPINGS` as it used to
before the PR \r\n- **Faking updating a plugin.** Same as the previous
one, but altering\r\nan existing md5 stored in the metas. \r\n\r\nAnd
that is the curl command used to tamper with the stored
_meta:\r\n```bash\r\ncurl -X PUT
\"kibana:changeme@localhost:9200/.kibana/_mapping?pretty\" -H
'Content-Type: application/json' -d'\r\n{\r\n \"_meta\": {\r\n
\"migrationMappingPropertyHashes\": {\r\n \"references\":
\"7997cf5a56cc02bdc9c93361bde732b0\",\r\n }\r\n
}\r\n}\r\n'\r\n```","sha":"b1e18a0414ed99456706119d15173b687c6e7366"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/145604","number":145604,"mergeCommit":{"message":"Reduce
startup time by skipping update mappings step when possible
(#145604)\n\nThe goal of this PR is to reduce the startup times of
Kibana server by\r\nimproving the migration logic.\r\n\r\nFixes
https://github.com/elastic/kibana/issues/145743\r\nRelated
https://github.com/elastic/kibana/issues/144035)\r\n\r\nThe migration
logic is run systematically at startup, whether the\r\ncustomers are
upgrading or not.\r\nHistorically, these steps have been very quick, but
we recently found\r\nout about some customers that have more than **one
million** Saved\r\nObjects stored, making the overall startup process
slow, even when there\r\nare no migrations to perform.\r\n\r\nThis PR
specifically targets the case where there are no migrations
to\r\nperform, aka a Kibana node is started against an ES cluster that
is\r\nalready up to date wrt stack version and list of
plugins.\r\n\r\nIn this scenario, we aim at skipping the
`UPDATE_TARGET_MAPPINGS` step\r\nof the migration logic, which
internally runs the\r\n`updateAndPickupMappings` method, which turns out
to be expensive if the\r\nsystem indices contain lots of
SO.\r\n\r\n\r\nI locally tested the following scenarios too:\r\n\r\n-
**Fresh install.** The step is not even run, as the `.kibana`
index\r\ndid not exist \r\n- **Stack version + list of plugins up to
date.** Simply restarting\r\nKibana after the fresh install. The step is
run and leads to `DONE`, as\r\nthe md5 hashes match those stored in
`.kibana._mapping._meta` \r\n- **Faking re-enabling an old plugin.** I
manually removed one of the\r\nMD5 hashes from the stored
.kibana._mapping._meta through `curl`, and\r\nthen restarted Kibana. The
step is run and leads to\r\n`UPDATE_TARGET_MAPPINGS` as it used to
before the PR \r\n- **Faking updating a plugin.** Same as the previous
one, but altering\r\nan existing md5 stored in the metas. \r\n\r\nAnd
that is the curl command used to tamper with the stored
_meta:\r\n```bash\r\ncurl -X PUT
\"kibana:changeme@localhost:9200/.kibana/_mapping?pretty\" -H
'Content-Type: application/json' -d'\r\n{\r\n \"_meta\": {\r\n
\"migrationMappingPropertyHashes\": {\r\n \"references\":
\"7997cf5a56cc02bdc9c93361bde732b0\",\r\n }\r\n
}\r\n}\r\n'\r\n```","sha":"b1e18a0414ed99456706119d15173b687c6e7366"}}]}]
BACKPORT-->
2022-11-30 03:26:18 -07:00
..
analytics [EBT] Add flush method and call it during stop (#144925) 2022-11-16 14:48:11 +01:00
content-management skip flaky suite. #145267 2022-11-15 16:08:03 -06:00
core [8.6] Reduce startup time by skipping update mappings step when possible (#145604) (#146637) 2022-11-30 03:26:18 -07:00
home Upgrade EUI to v67.1.9 (#145490) 2022-11-17 14:53:30 -08:00
kbn-ace fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-alerts Bumping EUI to version 67.1.8 (#141279) 2022-11-07 21:45:50 +00:00
kbn-ambient-storybook-types fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-ambient-ui-types fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-analytics Remove dependencies for empty @types/* packages (#144324) 2022-11-07 04:37:43 -07:00
kbn-apm-config-loader fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-apm-synthtrace [APM] Agent explorer (PoC) (#143844) 2022-11-14 15:40:49 +01:00
kbn-apm-utils [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-axe-config fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-babel-plugin-synthetic-packages [bazel] fix some BUILD.bazel file inconsistencies 2022-10-26 11:07:55 -05:00
kbn-babel-preset Update dependency core-js to ^3.26.0 (main) (#144211) 2022-10-31 10:46:49 -07:00
kbn-bazel-packages fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-bazel-runner fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-cases-components fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-chart-icons Rename all vis-editors and datavis to visualizations (#144589) 2022-11-05 19:16:20 -04:00
kbn-ci-stats-core fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-ci-stats-performance-metrics fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-ci-stats-reporter fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-cli-dev-mode fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-coloring Rename all vis-editors and datavis to visualizations (#144589) 2022-11-05 19:16:20 -04:00
kbn-config fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-config-mocks fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-config-schema Remove dependencies for empty @types/* packages (#144324) 2022-11-07 04:37:43 -07:00
kbn-crypto fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-crypto-browser fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-datemath [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-dev-cli-errors fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-dev-cli-runner fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-dev-proc-runner fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-dev-utils fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-doc-links [8.6] [DOCS] Updating value lists URL (#146602) (#146630) 2022-11-29 14:40:16 -07:00
kbn-docs-utils [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-ebt-tools remove unnecessary import aliases (#144250) 2022-10-31 17:56:59 +01:00
kbn-es fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-es-archiver fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-es-errors fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-es-query Remove dependencies for empty @types/* packages (#144324) 2022-11-07 04:37:43 -07:00
kbn-es-types fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-eslint-config [bazel] fix some BUILD.bazel file inconsistencies 2022-10-26 11:07:55 -05:00
kbn-eslint-plugin-disable fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-eslint-plugin-eslint [bazel] fix some BUILD.bazel file inconsistencies 2022-10-26 11:07:55 -05:00
kbn-eslint-plugin-imports fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-expect [bazel] fix some BUILD.bazel file inconsistencies 2022-10-26 11:07:55 -05:00
kbn-failed-test-reporter-cli Remove dependencies for empty @types/* packages (#144324) 2022-11-07 04:37:43 -07:00
kbn-field-types fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-find-used-node-modules fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-flot-charts [bazel] fix some BUILD.bazel file inconsistencies 2022-10-26 11:07:55 -05:00
kbn-ftr-common-functional-services fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-ftr-screenshot-filename fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-generate fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-get-repo-files fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-guided-onboarding [8.6] [Security solution] Guided onboarding, security tour copy changes (#146061) (#146600) 2022-11-29 12:21:31 -07:00
kbn-handlebars [8.6] Fix typos in @kbn/handlebars package (#146385) (#146392) 2022-11-28 08:08:29 -07:00
kbn-hapi-mocks fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-health-gateway-server Fix Health Gateway Checks (#144985) 2022-11-14 08:29:36 -05:00
kbn-i18n fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-i18n-react fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-import-resolver fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-interpreter Move appservices plugins to visualizations team (#144991) 2022-11-14 11:53:42 +02:00
kbn-io-ts-utils fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-jest-serializers fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-journeys [kbn-journeys] extend apm labels with branch, gitRev, ciBuildName (#144521) 2022-11-04 23:11:45 +01:00
kbn-kibana-manifest-schema fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-language-documentation-popover Rename all vis-editors and datavis to visualizations (#144589) 2022-11-05 19:16:20 -04:00
kbn-logging fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-logging-mocks fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-managed-vscode-config fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-managed-vscode-config-cli fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-mapbox-gl [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-monaco fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-optimizer [8.6] chore(NA): updates from lmdb-store to lmdb (#145891) (#146643) 2022-11-29 18:12:04 -07:00
kbn-optimizer-webpack-helpers fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-osquery-io-ts-types [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-performance-testing-dataset-extractor fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-plugin-discovery fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-plugin-generator [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-plugin-helpers [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-react-field fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-repo-source-classifier fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-repo-source-classifier-cli fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-rule-data-utils [ResponseOps][Rules] Adding rule.url variable (#145035) 2022-11-15 16:05:32 -07:00
kbn-safer-lodash-set [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-securitysolution-autocomplete [Security Solution] [Exceptions] Adds options to create a shared exception list and to create a single item from the manage exceptions view (#144575) 2022-11-09 09:54:45 -05:00
kbn-securitysolution-es-utils [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-securitysolution-exception-list-components [8.6] [Security Solution] [Platform] Adds 'Optional' to the default description message when editing (#146108) (#146216) 2022-11-23 13:32:35 -07:00
kbn-securitysolution-hook-utils [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-securitysolution-io-ts-alerting-types [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-securitysolution-io-ts-list-types Add sorting for exceptions cards (#145070) 2022-11-15 13:55:38 -07:00
kbn-securitysolution-io-ts-types [Security Solution] [Exceptions] Updates the exceptions list table to match mockups (#142289) 2022-11-02 08:41:48 -07:00
kbn-securitysolution-io-ts-utils [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-securitysolution-list-api Add sorting for exceptions cards (#145070) 2022-11-15 13:55:38 -07:00
kbn-securitysolution-list-constants [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-securitysolution-list-hooks [8.6] [Security Solution] [Exceptions] Fix edit the exception while adding new comment. (#145575) (#145724) 2022-11-18 08:11:25 -07:00
kbn-securitysolution-list-utils [Security Solution] [Exceptions] Adds a new react route for viewing details about an individual exception list (#144754) 2022-11-14 07:32:52 -05:00
kbn-securitysolution-rules [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-securitysolution-t-grid [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-securitysolution-utils [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-server-http-tools Remove dependencies for empty @types/* packages (#144324) 2022-11-07 04:37:43 -07:00
kbn-server-route-repository fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-shared-svg fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-shared-ux-utility rename codeowners from shared-ux to global-experience (#144746) 2022-11-08 09:13:16 -07:00
kbn-some-dev-log fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-sort-package-json fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-spec-to-console [bazel] fix some BUILD.bazel file inconsistencies 2022-10-26 11:07:55 -05:00
kbn-std fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-stdio-dev-helpers fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-storybook [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-synthetic-package-map fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-telemetry-tools [UsageCollection] Allow pass_through on Record<string, unknown> types (#144571) 2022-11-04 09:22:01 +01:00
kbn-test Remove dependencies for empty @types/* packages (#144324) 2022-11-07 04:37:43 -07:00
kbn-test-jest-helpers [ContentManagement] Inspector flyout (#144240) 2022-11-09 06:01:53 -07:00
kbn-test-subj-selector fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-timelion-grammar Rename all vis-editors and datavis to visualizations (#144589) 2022-11-05 19:16:20 -04:00
kbn-tinymath Rename all vis-editors and datavis to visualizations (#144589) 2022-11-05 19:16:20 -04:00
kbn-tooling-log fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-type-summarizer fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-type-summarizer-cli fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-type-summarizer-core fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-typed-react-router-config fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-ui-framework [bazel] fix some BUILD.bazel file inconsistencies 2022-10-26 11:07:55 -05:00
kbn-ui-shared-deps-npm fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-ui-shared-deps-src fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-ui-theme fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-user-profile-components Add the ability to limit the number of users you can select (#144618) 2022-11-07 12:39:30 +00:00
kbn-utility-types fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-utility-types-jest fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
kbn-utils [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
kbn-yarn-lock-validator fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00
shared-ux Upgrade EUI to v67.1.9 (#145490) 2022-11-17 14:53:30 -08:00
BUILD.bazel Migrate server-side Root and Server to packages (#144990) 2022-11-15 03:11:37 -07:00
README.md [kbn/pm] rewrite to avoid needing a build process (#136207) 2022-07-18 08:46:13 -07:00

Kibana-related packages

This folder contains packages that are intended for use in Kibana and Kibana plugins.

tl;dr:

  • Don't publish to npm registry
  • Always use the @kbn namespace
  • Always set "private": true in package.json

Using these packages

We no longer publish these packages to the npm registry. Now, instead of specifying a version when including these packages, we rely on yarn workspaces, which sets up a symlink to the package.

For example if you want to use the @kbn/i18n package in Kibana itself, you can specify the dependency like this:

"@kbn/i18n": "1.0.0"

However, if you want to use this from a Kibana plugin, you need to use a link: dependency and account for the relative location of the Kibana repo, so it would instead be:

"@kbn/i18n": "link:../../kibana/packages/kbn-i18n"

Creating a new package

Create a new sub-folder. The name of the folder should mirror the name in the package's package.json. E.g. if the name is @kbn/i18n the folder name should be kbn-i18n.

All new packages should use the @kbn namespace, and should be marked with "private": true.

Unit tests for a package

Currently there is only one tool being used in order to test packages which is Jest. Below we will explain how it should be done.

Jest

A package should follow the pattern of having .test.js files as siblings of the source code files, and these run by Jest.

A package using the .test.js naming convention will have those tests automatically picked up by Jest and run by the unit test runner, currently mapped to the Kibana test script in the root package.json.

  • yarn test runs all unit tests.
  • yarn jest runs all Jest tests in Kibana.

In order for the plugin or package to use Jest, a jest.config.js file must be present in it's root. However, there are safeguards for this in CI should a test file be added without a corresponding config file.


Each package can also specify its own test script in the package's package.json, for cases where you'd prefer to run the tests from the local package directory.