Skip to content

Commit

Permalink
[Ops] Bump Node.js to version 18 (elastic#160289)
Browse files Browse the repository at this point in the history
## Summary

Bumps node.js to 18.17.0 (replacement for PR elastic#144012 which was later
reverted)

As a result, these categorical additions were needed:
- `node` evocations will need the `--openssl-legacy-provider` flag,
wherever it would use certain crypto functionalities
- tests required updating of the expected HTTPS Agent call arguments,
`noDelay` seems to be a default
 - `window.[NAME]` fields cannot be written directly
 - some stricter typechecks

This is using our in-house built node.js 18 versions through the URLs
the proxy-cache. (built with
elastic/kibana-custom-nodejs-builds#4)

These urls are served from a bucket, where the RHEL7/Centos7 compatible
node distributables are. (see:
elastic/kibana-ci-proxy-cache#7)

Further todos:
 - [x] check docs wording and consistency
 - [ ] update the dependency report
 - [x] explain custom builds in documentation
 - [x] node_sass prebuilts

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Tiago Costa <tiago.costa@elastic.co>
Co-authored-by: Thomas Watson <w@tson.dk>
  • Loading branch information
4 people committed Jul 28, 2023
1 parent 144cbab commit 4f464f7
Show file tree
Hide file tree
Showing 30 changed files with 134 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NOTE: This Dockerfile is ONLY used to run certain tasks in CI. It is not used to run Kibana or as a distributable.
# If you're looking for the Kibana Docker image distributable, please see: src/dev/build/tasks/os_packages/docker_generator/templates/dockerfile.template.ts

ARG NODE_VERSION=16.20.1
ARG NODE_VERSION=18.17.0

FROM node:${NODE_VERSION} AS base

Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.20.1
18.17.0
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.20.1
18.17.0
12 changes: 6 additions & 6 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ check_rules_nodejs_version(minimum_version_string = "3.8.0")
# we can update that rule.
node_repositories(
node_repositories = {
"16.20.1-darwin_amd64": ("node-v16.20.1-darwin-x64.tar.gz", "node-v16.20.1-darwin-x64", "d1f9c2a7c3a0fe09860f701af5fb8ff9ac72d72faa7ebabfeb5794503e79f955"),
"16.20.1-darwin_arm64": ("node-v16.20.1-darwin-arm64.tar.gz", "node-v16.20.1-darwin-arm64", "5f6b31c5a75567d382ba67220f3d7a2d9bb0c03d8af9307cd35a9cb32a6fde9d"),
"16.20.1-linux_arm64": ("node-v16.20.1-linux-arm64.tar.xz", "node-v16.20.1-linux-arm64", "7fce19f3d1c2952599a0b47f9f5d8f497265ad577f37f256a8c6a03be6353234"),
"16.20.1-linux_amd64": ("node-v16.20.1-linux-x64.tar.xz", "node-v16.20.1-linux-x64", "b6c60e1e106ad7d8881e83945a5208c1b1d1b63e6901c04b9dafa607aff3a154"),
"16.20.1-windows_amd64": ("node-v16.20.1-win-x64.zip", "node-v16.20.1-win-x64", "2a7fde996c57a969f0498742f99385a520eb14aac864e0eff9c32e3f3633ff0a"),
"18.17.0-darwin_amd64": ("node-v18.17.0-darwin-x64.tar.gz", "node-v18.17.0-darwin-x64", "2f381442381f7fbde2ca644c3275bec9c9c2a8d361f467b40e39428acdd6ccff"),
"18.17.0-darwin_arm64": ("node-v18.17.0-darwin-arm64.tar.gz", "node-v18.17.0-darwin-arm64", "19731ef427e77ad9c5f476eb62bfb02a7f179d3012feed0bbded62e45f23e679"),
"18.17.0-linux_arm64": ("node-v18.17.0-linux-arm64.tar.xz", "node-v18.17.0-linux-arm64", "fbd2904178ee47da6e0386bc9704a12b1f613da6ad194878a517d4a69ba56544"),
"18.17.0-linux_amd64": ("node-v18.17.0-linux-x64.tar.xz", "node-v18.17.0-linux-x64", "f36facda28c4d5ce76b3a1b4344e688d29d9254943a47f2f1909b1a10acb1959"),
"18.17.0-windows_amd64": ("node-v18.17.0-win-x64.zip", "node-v18.17.0-win-x64", "06e30b4e70b18d794651ef132c39080e5eaaa1187f938721d57edae2824f4e96"),
},
node_version = "16.20.1",
node_version = "18.17.0",
node_urls = [
"https://nodejs.org/dist/v{version}/{filename}",
],
Expand Down
4 changes: 4 additions & 0 deletions docs/user/setup.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Windows. Since Kibana runs on Node.js, we include the necessary Node.js
binaries for these platforms. Running Kibana against a separately maintained
version of Node.js is not supported.

To support certain older Linux platforms (most notably CentOS7/RHEL7), {kib}
for Linux ships with a custom build of Node.js with glibc 2.17 support. For
details, see <<custom-nodejs-builds>>.

[float]
[[elasticsearch-version]]
== Elasticsearch version
Expand Down
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"makelogs": "node scripts/makelogs",
"spec_to_console": "node scripts/spec_to_console",
"start": "node scripts/kibana --dev",
"storybook": "node scripts/storybook",
"storybook": "node --openssl-legacy-provider scripts/storybook",
"test:ftr": "node scripts/functional_tests",
"test:ftr:runner": "node scripts/functional_test_runner",
"test:ftr:server": "node scripts/functional_tests_server",
Expand All @@ -66,7 +66,7 @@
"url": "https://github.com/elastic/kibana.git"
},
"engines": {
"node": "16.20.1",
"node": "18.17.0",
"yarn": "^1.21.1"
},
"resolutions": {
Expand All @@ -76,7 +76,8 @@
"**/@babel/traverse": "^7.21.2",
"**/@babel/types": "^7.21.2",
"**/@types/babel__generator/@babel/types": "^7.21.0",
"**/@types/node": "16.11.7",
"**/@types/node": "18.17.1",
"**/@types/react": "^16.14.25",
"**/@types/react-dom": "^16.9.8",
"**/chokidar": "^3.4.3",
"**/globule/minimatch": "^3.1.2",
Expand Down Expand Up @@ -187,8 +188,6 @@
"@turf/length": "^6.0.2",
"@types/react-is": "^16.7.2",
"JSONStream": "1.3.5",
"abort-controller": "^3.0.0",
"abortcontroller-polyfill": "^1.7.3",
"antlr4ts": "^0.5.0-alpha.3",
"archiver": "^5.2.0",
"axios": "^0.27.2",
Expand Down Expand Up @@ -529,7 +528,7 @@
"@types/ejs": "^3.0.6",
"@types/elastic__datemath": "link:bazel-bin/packages/elastic-datemath/npm_module_types",
"@types/elasticsearch": "^5.0.33",
"@types/enzyme": "^3.10.8",
"@types/enzyme": "^3.10.12",
"@types/eslint": "^7.28.0",
"@types/express": "^4.17.13",
"@types/extract-zip": "^1.6.2",
Expand Down Expand Up @@ -581,8 +580,8 @@
"@types/mustache": "^0.8.31",
"@types/ncp": "^2.0.1",
"@types/nock": "^10.0.3",
"@types/node": "16.11.7",
"@types/node-fetch": "^2.6.0",
"@types/node": "18.17.1",
"@types/node-fetch": "2.6.4",
"@types/node-forge": "^1.3.1",
"@types/nodemailer": "^6.4.0",
"@types/normalize-path": "^3.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-es/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ NPM_MODULE_EXTRA_FILES = [

RUNTIME_DEPS = [
"@npm//@elastic/elasticsearch",
"@npm//abort-controller",
"@npm//chalk",
"@npm//dedent",
"@npm//del",
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-es/src/artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { pipeline, Transform } from 'stream';
import { setTimeout } from 'timers/promises';

import fetch, { Headers } from 'node-fetch';
import AbortController from 'abort-controller';
import chalk from 'chalk';
import { ToolingLog } from '@kbn/dev-utils';

Expand Down
5 changes: 4 additions & 1 deletion packages/kbn-monaco/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ webpack(
"$(location webpack.config.js)",
"--output-path",
"$(@D)",
"--env",
"--env",
"prod",
"--stats=errors-only"
],
env = {
"NODE_OPTIONS": "--openssl-legacy-provider"
}
)

ts_config(
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-optimizer/src/optimizer/observe_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function usingWorkerProc<T>(
nodeOptions: [
'--preserve-symlinks',
'--preserve-symlinks-main',
'--openssl-legacy-provider',
...(inspectFlag && config.inspectWorkers
? [`${inspectFlag}=${inspectPortCounter++}`]
: []),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ it('builds a generated plugin into a viable archive', async () => {
process.execPath,
['scripts/generate_plugin', '-y', '--name', 'fooTestPlugin'],
{
env: {
NODE_OPTIONS: '--openssl-legacy-provider',
},
cwd: REPO_ROOT,
all: true,
}
Expand All @@ -61,6 +64,9 @@ it('builds a generated plugin into a viable archive', async () => {
process.execPath,
['../../scripts/plugin_helpers', 'build', '--kibana-version', '7.5.0'],
{
env: {
NODE_OPTIONS: '--openssl-legacy-provider',
},
cwd: PLUGIN_DIR,
all: true,
}
Expand Down
5 changes: 3 additions & 2 deletions packages/kbn-ui-shared-deps-npm/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ RUNTIME_DEPS = [
"@npm//@elastic/eui",
"@npm//@elastic/numeral",
"@npm//@emotion/react",
"@npm//abortcontroller-polyfill",
"@npm//babel-loader",
"@npm//babel-plugin-transform-react-remove-prop-types",
"@npm//core-js",
Expand Down Expand Up @@ -72,7 +71,6 @@ TYPES_DEPS = [
"@npm//@elastic/eui",
"@npm//@elastic/numeral",
"@npm//@emotion/react",
"@npm//abortcontroller-polyfill",
"@npm//babel-loader",
"@npm//core-js",
"@npm//css-loader",
Expand Down Expand Up @@ -146,6 +144,9 @@ webpack(
"$(@D)",
"--stats=errors-only"
],
env = {
"NODE_OPTIONS": "--openssl-legacy-provider"
}
)

js_library(
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-ui-shared-deps-src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ webpack(
"$(@D)",
"--stats=errors-only"
],
env = {
"NODE_OPTIONS": "--openssl-legacy-provider"
}
)

js_library(
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/apm_system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

jest.mock('@elastic/apm-rum');
import type { DeeplyMockedKeys, MockedKeys } from '@kbn/utility-types/jest';
import { init, apm } from '@elastic/apm-rum';
import { init, apm, Transaction } from '@elastic/apm-rum';
import { ApmSystem } from './apm_system';
import { Subject } from 'rxjs';
import { InternalApplicationStart } from './application/types';
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/apm_system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import type { ApmBase, AgentConfigOptions } from '@elastic/apm-rum';
import type { ApmBase, AgentConfigOptions, Transaction } from '@elastic/apm-rum';
import { modifyUrl } from '@kbn/std';
import { CachedResourceObserver } from './apm_resource_counter';
import type { InternalApplicationStart } from './application';
Expand Down
13 changes: 8 additions & 5 deletions src/core/public/chrome/chrome_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ class FakeApp implements App {
const store = new Map();
const originalLocalStorage = window.localStorage;

(window as any).localStorage = {
setItem: (key: string, value: string) => store.set(String(key), String(value)),
getItem: (key: string) => store.get(String(key)),
removeItem: (key: string) => store.delete(String(key)),
};
Object.defineProperty(window, 'localStorage', {
value: {
setItem: (key: string, value: string) => store.set(String(key), String(value)),
getItem: (key: string) => store.get(String(key)),
removeItem: (key: string) => store.delete(String(key)),
},
writable: true,
});

function defaultStartDeps(availableApps?: App[]) {
const deps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ describe('RecentlyAccessed#start()', () => {
let originalLocalStorage: Storage;
beforeAll(() => {
originalLocalStorage = window.localStorage;
window.localStorage = new LocalStorageMock();
Object.defineProperty(window, 'localStorage', {
value: new LocalStorageMock(),
writable: true,
});
});
beforeEach(() => localStorage.clear());
afterAll(() => (window.localStorage = originalLocalStorage));
Expand Down
2 changes: 1 addition & 1 deletion src/dev/build/lib/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export async function downloadToDisk({
const downloadedSha = hash.digest('hex');
if (downloadedSha !== shaChecksum) {
throw new Error(
`Downloaded checksum ${downloadedSha} does not match the expected ${shaAlgorithm} checksum.`
`Downloaded checksum ${downloadedSha} does not match the expected (${shaAlgorithm}) checksum ${shaChecksum}, for file: ${url}.`
);
}
} catch (_error) {
Expand Down
4 changes: 2 additions & 2 deletions src/dev/build/lib/integration_tests/download.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('downloadToDisk', () => {
shaAlgorithm: 'sha256',
});
await expect(promise).rejects.toMatchInlineSnapshot(
`[Error: Downloaded checksum 2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae does not match the expected sha256 checksum.]`
`[Error: Downloaded checksum ${FOO_SHA256} does not match the expected (sha256) checksum bar, for file: ${serverUrl}.]`
);

try {
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('downloadToDisk', () => {
" debg Deleting downloaded data at TMP_DIR/__tmp_download_js_test_file__",
" info Retrying in 0.1 seconds",
" debg [2/3] Attempting download of TEST_SERVER_URL sha256",
" debg Download failed: Downloaded checksum fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9 does not match the expected sha256 checksum.",
" debg Download failed: Downloaded checksum fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9 does not match the expected (sha256) checksum 2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae, for file: TEST_SERVER_URL.",
" debg Deleting downloaded data at TMP_DIR/__tmp_download_js_test_file__",
" info Retrying in 0.2 seconds",
" debg [3/3] Attempting download of TEST_SERVER_URL sha256",
Expand Down
53 changes: 32 additions & 21 deletions src/dev/build/tasks/patch_native_modules_task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,40 +41,51 @@ interface Package {
const packages: Package[] = [
{
name: 're2',
version: '1.16.0',
version: '1.17.7',
destinationPath: 'node_modules/re2/build/Release/re2.node',
extractMethod: 'gunzip',
archives: {
'darwin-x64': {
url: 'https://github.com/uhop/node-re2/releases/download/1.16.0/darwin-x64-93.gz',
sha256: 'a267c6202d86d08170eb4a833acf81d83660ce33e8981fcd5b7f6e0310961d56',
},
'linux-x64': {
url: 'https://github.com/uhop/node-re2/releases/download/1.16.0/linux-x64-93.gz',
sha256: 'e0ca5d6527fe7ec0fe98b6960c47b66a5bb2823c3bebb3bf4ed4d58eed3d23c5',
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.7/linux-x64-108.gz',
sha256: 'e0b62ff7c415c95f57232f2726711c0fd71056c848538f095ba3fa1126ef5e31',
},

// ARM build is currently done manually as Github Actions used in upstream project
// ARM builds are currently done manually as Github Actions used in upstream project
// do not natively support an ARM target.

// From a AWS Graviton instance:
// * checkout the node-re2 project,
// * install Node using the same minor used by Kibana
// * git submodule update --init --recursive to download re2
// * npm install, which will also create a build
// * gzip -c build/Release/re2.node > linux-arm64-83.gz
// * upload to kibana-ci-proxy-cache bucket
// From an AWS Graviton instance running Ubuntu or a GCE T2A instance running Debian:
// * install build-essential package: `sudo apt-get update` + `sudo apt install build-essential`
// * install nvm and the node version used by the Kibana repository
// * `npm install re2@1.17.7`
// * re2 will build itself on install
// * `cp node_modules/re2/build/Release/re2.node linux-arm64-$(node -e "console.log(process.versions.modules)")`
// * `gzip linux-arm64-*`
// * capture the sha256 with: `shasum -a 256 linux-arm64-*`
// * upload the `linux-arm64-*.gz` artifact to the `yarn-prebuilt-artifacts` bucket in GCS using the correct version number
'linux-arm64': {
url: 'https://storage.googleapis.com/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.16.0/linux-arm64-93.gz',
sha256: '7a786e0b75985e5aafdefa9af55cad8e85e69a3326f16d8c63d21d6b5b3bff1b',
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.7/linux-arm64-108.gz',
sha256: 'e2025ead87be9f1ec4a9d892d1cce69c573101762720d56f52b1d52ed7ae0fef',
},

'darwin-x64': {
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.7/darwin-x64-108.gz',
sha256: '4ed378c5a7fe6134b717afe7642254aff1ed7a881cbcaa53a012ac3efab49f99',
},

// A similar process is necessary for building on ARM macs:
// * bootstrap and re2 will build itself on install
// * `cp node_modules/re2/build/Release/re2.node darwin-arm64-$(node -e "console.log(process.versions.modules)")`
// * `gzip darwin-arm64-*`
// * capture the sha256 with: `shasum -a 256 darwin-arm64-*`
// * upload the `darwin-arm64-*.gz` artifact to the `yarn-prebuilt-artifacts` bucket in GCS using the correct version number
'darwin-arm64': {
url: 'https://storage.googleapis.com/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.16.0/darwin-arm64-93.gz',
sha256: '28b540cdddf13578f1bd28a03e29ffdc26a7f00ec859c369987b8d51ec6357c8',
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.7/darwin-arm64-108.gz',
sha256: '42afc32137ff5c5bebae5d68347a9786906748c2f28e06194d8950707f2ae90e',
},

'win32-x64': {
url: 'https://github.com/uhop/node-re2/releases/download/1.16.0/win32-x64-93.gz',
sha256: '37245ceb59a086b5e7e9de8746a3cdf148c383be9ae2580f92baea90d0d39947',
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.7/win32-x64-108.gz',
sha256: 'ff72fe02de652262659c8e17e44a932f3c873362233756b40d1a97538d05de92',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ describe('Editor', () => {
input = create(document.querySelector('#ConAppEditor'));
$(input.getCoreEditor().getContainer()).show();
input.autocomplete._test.removeChangeListener();
oldUrl = global.URL;
olldWindow = { ...global.window };
global.URL = URL;
Object.defineProperty(global, 'window', {
value: Object.create(window),
writable: true,
});
Object.defineProperty(window, 'location', {
value: {
origin: 'http://localhost:5620',
},
});
storage = createStorage({
engine: global.window.localStorage,
prefix: 'console_test',
});
setStorage(storage);
});
afterEach(function () {
$(input.getCoreEditor().getContainer()).hide();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ describe('requestOAuthClientCredentialsToken', () => {
"maxSockets": Infinity,
"maxTotalSockets": Infinity,
"options": Object {
"noDelay": true,
"path": null,
"rejectUnauthorized": true,
},
Expand Down
Loading

0 comments on commit 4f464f7

Please sign in to comment.