Skip to content

Commit

Permalink
[7.17] chore(NA): remove usage of re2 and replace it with a non nativ…
Browse files Browse the repository at this point in the history
…e module (#188134) (#188369)

# Backport

This will backport the following commits from `main` to `7.17`:
- [chore(NA): remove usage of re2 and replace it with a non native
module (#188134)](#188134)

<!--- Backport version: 8.9.8 -->

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

<!--BACKPORT [{"author":{"name":"Tiago
Costa","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-07-15T19:33:28Z","message":"chore(NA):
remove usage of re2 and replace it with a non native module
(#188134)\n\nThis PR removes the usage of the native module version of
`re2` and\r\nreplaces it with a js port called `re2js`.\r\nIt also ends
our usage of native node modules in production and it\r\nremoves the
task from the build as well. Further steps will be taken\r\nalong our
strategy to avoid future usages of native node modules in
prod\r\nenvironments.","sha":"3c338a82c2d6d59c91f0f3b74f725231c69c5b13","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["chore","Team:Operations","release_note:skip","backport:all-open","v8.16.0"],"number":188134,"url":"https://github.com/elastic/kibana/pull/188134","mergeCommit":{"message":"chore(NA):
remove usage of re2 and replace it with a non native module
(#188134)\n\nThis PR removes the usage of the native module version of
`re2` and\r\nreplaces it with a js port called `re2js`.\r\nIt also ends
our usage of native node modules in production and it\r\nremoves the
task from the build as well. Further steps will be taken\r\nalong our
strategy to avoid future usages of native node modules in
prod\r\nenvironments.","sha":"3c338a82c2d6d59c91f0f3b74f725231c69c5b13"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.16.0","labelRegex":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/188134","number":188134,"mergeCommit":{"message":"chore(NA):
remove usage of re2 and replace it with a non native module
(#188134)\n\nThis PR removes the usage of the native module version of
`re2` and\r\nreplaces it with a js port called `re2js`.\r\nIt also ends
our usage of native node modules in production and it\r\nremoves the
task from the build as well. Further steps will be taken\r\nalong our
strategy to avoid future usages of native node modules in
prod\r\nenvironments.","sha":"3c338a82c2d6d59c91f0f3b74f725231c69c5b13"}}]}]
BACKPORT-->
  • Loading branch information
mistic authored Jul 16, 2024
1 parent d785d2f commit 73bc501
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 440 deletions.
1 change: 0 additions & 1 deletion .buildkite/scripts/common/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ fi

export GECKODRIVER_CDNURL="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache$CI_PROXY_CACHE_SUFFIX"
export CHROMEDRIVER_CDNURL="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache$CI_PROXY_CACHE_SUFFIX"
export RE2_DOWNLOAD_MIRROR="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache$CI_PROXY_CACHE_SUFFIX"
export CYPRESS_DOWNLOAD_MIRROR="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache$CI_PROXY_CACHE_SUFFIX/cypress"

export NODE_OPTIONS="--max-old-space-size=4096"
Expand Down
1 change: 0 additions & 1 deletion WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ yarn_install(
"GECKODRIVER_CDNURL": "https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache",
"CHROMEDRIVER_CDNURL": "https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache",
"CHROMEDRIVER_CDNBINARIESURL": "https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache",
"RE2_DOWNLOAD_MIRROR": "https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2",
"CYPRESS_DOWNLOAD_MIRROR": "https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/cypress",
}
)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@
"raw-loader": "^3.1.0",
"rbush": "^3.0.1",
"re-resizable": "^6.1.1",
"re2": "1.20.9",
"re2js": "0.4.1",
"react": "^16.14.0",
"react-ace": "^7.0.5",
"react-beautiful-dnd": "^13.0.0",
Expand Down
6 changes: 1 addition & 5 deletions packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8909,11 +8909,7 @@ const BootstrapCommand = {
const forceInstallStartTime = Date.now();
await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["removeYarnIntegrityFileIfExists"])(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(kibanaProjectPath, 'node_modules'));
await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["runBazel"])(['clean']);
await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["runBazel"])(['run', '@nodejs//:yarn'], runOffline, {
env: {
RE2_DOWNLOAD_MIRROR: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2'
}
});
await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["runBazel"])(['run', '@nodejs//:yarn'], runOffline);
timings.push({
id: 'force install dependencies',
ms: Date.now() - forceInstallStartTime
Expand Down
7 changes: 1 addition & 6 deletions packages/kbn-pm/src/commands/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,7 @@ export const BootstrapCommand: ICommand = {
const forceInstallStartTime = Date.now();
await removeYarnIntegrityFileIfExists(resolve(kibanaProjectPath, 'node_modules'));
await runBazel(['clean']);
await runBazel(['run', '@nodejs//:yarn'], runOffline, {
env: {
RE2_DOWNLOAD_MIRROR:
'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2',
},
});
await runBazel(['run', '@nodejs//:yarn'], runOffline);
timings.push({
id: 'force install dependencies',
ms: Date.now() - forceInstallStartTime,
Expand Down
39 changes: 0 additions & 39 deletions scripts/download_re2.sh

This file was deleted.

1 change: 0 additions & 1 deletion src/dev/build/build_distributables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export async function buildDistributables(log: ToolingLog, options: BuildOptions
*/
if (options.createPlatformFolders) {
await run(Tasks.CreateArchivesSources);
await run(Tasks.PatchNativeModules);
await run(Tasks.InstallChromium);
await run(Tasks.CleanExtraBinScripts);
await run(Tasks.CleanNodeBuilds);
Expand Down
1 change: 0 additions & 1 deletion src/dev/build/tasks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export * from './nodejs';
export * from './notice_file_task';
export * from './os_packages';
export * from './package_json';
export * from './patch_native_modules_task';
export * from './assert_file_time';
export * from './assert_no_uuid';
export * from './assert_path_length';
Expand Down
146 changes: 0 additions & 146 deletions src/dev/build/tasks/patch_native_modules_task.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/dev/ci_setup/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ export PATH="$PATH:$yarnGlobalDir"
export GECKODRIVER_CDNURL="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache"
export CHROMEDRIVER_CDNURL="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache"
export CHROMEDRIVER_CDNBINARIESURL="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache"
export RE2_DOWNLOAD_MIRROR="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache"
export CYPRESS_DOWNLOAD_MIRROR="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/cypress"

export CHECKS_REPORTER_ACTIVE=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { i18n } from '@kbn/i18n';
import alter from '../lib/alter.js';
import Chainable from '../lib/classes/chainable';
import { RE2JS } from 're2js';

export default new Chainable('label', {
args: [
Expand Down Expand Up @@ -40,10 +41,9 @@ export default new Chainable('label', {
const config = args.byName;
return alter(args, function (eachSeries) {
if (config.regex) {
// not using a standard `import` so that if there's an issue with the re2 native module
// that it doesn't prevent Kibana from starting up and we only have an issue using Timelion labels
const RE2 = require('re2');
eachSeries.label = eachSeries.label.replace(new RE2(config.regex), config.label);
eachSeries.label = RE2JS.compile(config.regex)
.matcher(eachSeries.label)
.replaceAll(config.label);
} else if (config.label) {
eachSeries.label = config.label;
}
Expand Down
Loading

0 comments on commit 73bc501

Please sign in to comment.