Skip to content

Commit b2615e2

Browse files
authored
[7.14] Disable Product check in @elastic/elasticsearch-js (#107642) (#107826)
* Disable Product check in @elastic/elasticsearch-js (#107642) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> # Conflicts: # package.json # yarn.lock * Bump @elastic/elasticsearch-js version
1 parent c88a616 commit b2615e2

File tree

5 files changed

+56
-5
lines changed

5 files changed

+56
-5
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"@elastic/apm-rum-react": "^1.2.11",
9999
"@elastic/charts": "32.0.1",
100100
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath",
101-
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@7.14.0-canary.6",
101+
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@7.14.0-canary.7",
102102
"@elastic/ems-client": "7.14.0",
103103
"@elastic/eui": "34.5.2",
104104
"@elastic/filesaver": "1.1.2",

packages/kbn-es/src/utils/native_realm.js

+19
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ const chalk = require('chalk');
1111

1212
const { log: defaultLog } = require('./log');
1313

14+
/**
15+
* Hack to skip the Product Check performed by the Elasticsearch-js client.
16+
* We noticed a couple of bugs that may need to be fixed before taking full
17+
* advantage of this feature.
18+
*
19+
* The bugs are detailed in this issue: https://github.com/elastic/kibana/issues/105557
20+
*
21+
* The hack is copied from the test/utils in the elasticsearch-js repo
22+
* (https://github.com/elastic/elasticsearch-js/blob/master/test/utils/index.js#L45-L56)
23+
*/
24+
function skipProductCheck(client) {
25+
const tSymbol = Object.getOwnPropertySymbols(client.transport || client).filter(
26+
(symbol) => symbol.description === 'product check'
27+
)[0];
28+
(client.transport || client)[tSymbol] = 2;
29+
}
30+
1431
exports.NativeRealm = class NativeRealm {
1532
constructor({ elasticPassword, port, log = defaultLog, ssl = false, caCert }) {
1633
this._client = new Client({
@@ -22,6 +39,8 @@ exports.NativeRealm = class NativeRealm {
2239
}
2340
: undefined,
2441
});
42+
// TODO: @elastic/es-clients I had to disable the product check here because the client is getting 404 while ES is initializing, but the requests here auto retry them.
43+
skipProductCheck(this._client);
2544
this._elasticPassword = elasticPassword;
2645
this._log = log;
2746
}

src/core/server/elasticsearch/client/configure_client.ts

+24
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ export const configureClient = (
2222
const client = new Client(clientOptions);
2323
addLogging(client, logger.get('query', type));
2424

25+
// ------------------------------------------------------------------------ //
26+
// Hack to disable the "Product check" while the bugs in //
27+
// https://github.com/elastic/kibana/issues/105557 are handled. //
28+
skipProductCheck(client);
29+
// ------------------------------------------------------------------------ //
30+
2531
return client;
2632
};
2733

@@ -78,3 +84,21 @@ const addLogging = (client: Client, logger: Logger) => {
7884
}
7985
});
8086
};
87+
88+
/**
89+
* Hack to skip the Product Check performed by the Elasticsearch-js client.
90+
* We noticed a couple of bugs that may need to be fixed before taking full
91+
* advantage of this feature.
92+
*
93+
* The bugs are detailed in this issue: https://github.com/elastic/kibana/issues/105557
94+
*
95+
* The hack is copied from the test/utils in the elasticsearch-js repo
96+
* (https://github.com/elastic/elasticsearch-js/blob/master/test/utils/index.js#L45-L56)
97+
*/
98+
function skipProductCheck(client: Client) {
99+
const tSymbol = Object.getOwnPropertySymbols(client.transport || client).filter(
100+
(symbol) => symbol.description === 'product check'
101+
)[0];
102+
// @ts-expect-error `tSymbol` is missing in the index signature of Transport
103+
(client.transport || client)[tSymbol] = 2;
104+
}

src/setup_node_env/exit_on_warning.js

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ var IGNORE_WARNINGS = [
2929
file: '/node_modules/supertest/node_modules/superagent/lib/node/index.js',
3030
line: 418,
3131
},
32+
{
33+
// TODO: @elastic/es-clients - The new client will attempt a Product check and it will `process.emitWarning`
34+
// that the security features are blocking such check.
35+
// Such emit is causing Node.js to crash unless we explicitly catch it.
36+
// We need to discard that warning
37+
message:
38+
'The client is unable to verify that the server is Elasticsearch due to security privileges on the server side. Some functionality may not be compatible if the server is running an unsupported product.',
39+
},
3240
];
3341

3442
if (process.noProcessWarnings !== true) {

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -1403,10 +1403,10 @@
14031403
dependencies:
14041404
"@elastic/ecs-helpers" "^1.1.0"
14051405

1406-
"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@7.14.0-canary.6":
1407-
version "7.14.0-canary.6"
1408-
resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-7.14.0-canary.6.tgz#29ae3f53708e94d7efbd9d1a228f6b9f83f03645"
1409-
integrity sha512-Se4ClajPQn5T3h6vil4Jvje+ic29kD3boM1AfOEWhNieGz48JMJSxNX31OiaD0Q7MsVLVKd6Xx0rXqzgMXDd1A==
1406+
"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@7.14.0-canary.7":
1407+
version "7.14.0-canary.7"
1408+
resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-7.14.0-canary.7.tgz#c14a4c80a5d9584fbcb2d6b73da141e313a75b88"
1409+
integrity sha512-Vk3Q9NcTJhFvkGgHh4sbqdcUysjh9eZgjAtoXRwlXCgULwDsxFpAPeb/+HZjlW9BWCPjEVbo2vgEvU8/9cXjxg==
14101410
dependencies:
14111411
debug "^4.3.1"
14121412
hpagent "^0.1.1"

0 commit comments

Comments
 (0)