Skip to content

Commit

Permalink
Merge branch 'master' into transpile-kbn-securitysolution-io-ts-list-…
Browse files Browse the repository at this point in the history
…types-with-babel
  • Loading branch information
kibanamachine authored Aug 26, 2021
2 parents 9364741 + bb8ee0c commit 2b2b6cf
Show file tree
Hide file tree
Showing 131 changed files with 2,140 additions and 662 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
/src/plugins/data/ @elastic/kibana-app-services
/src/plugins/embeddable/ @elastic/kibana-app-services
/src/plugins/expressions/ @elastic/kibana-app-services
/src/plugins/field_formats/ @elastic/kibana-app-services
/src/plugins/index_pattern_editor/ @elastic/kibana-app-services
/src/plugins/inspector/ @elastic/kibana-app-services
/src/plugins/kibana_react/ @elastic/kibana-app-services
/src/plugins/kibana_react/public/code_editor @elastic/kibana-presentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
| [QuerySuggestionField](./kibana-plugin-plugins-data-public.querysuggestionfield.md) | \* |
| [QuerySuggestionGetFnArgs](./kibana-plugin-plugins-data-public.querysuggestiongetfnargs.md) | \* |
| [Reason](./kibana-plugin-plugins-data-public.reason.md) | |
| [RefreshInterval](./kibana-plugin-plugins-data-public.refreshinterval.md) | |
| [SavedQuery](./kibana-plugin-plugins-data-public.savedquery.md) | |
| [SavedQueryService](./kibana-plugin-plugins-data-public.savedqueryservice.md) | |
| [SearchSessionInfoProvider](./kibana-plugin-plugins-data-public.searchsessioninfoprovider.md) | Provide info about current search session to be stored in the Search Session saved object |
Expand Down Expand Up @@ -176,6 +175,7 @@
| [RangeFilter](./kibana-plugin-plugins-data-public.rangefilter.md) | |
| [RangeFilterMeta](./kibana-plugin-plugins-data-public.rangefiltermeta.md) | |
| [RangeFilterParams](./kibana-plugin-plugins-data-public.rangefilterparams.md) | |
| [RefreshInterval](./kibana-plugin-plugins-data-public.refreshinterval.md) | |
| [SavedQueryTimeFilter](./kibana-plugin-plugins-data-public.savedquerytimefilter.md) | |
| [SearchBarProps](./kibana-plugin-plugins-data-public.searchbarprops.md) | |
| [StatefulSearchBarProps](./kibana-plugin-plugins-data-public.statefulsearchbarprops.md) | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@

[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [RefreshInterval](./kibana-plugin-plugins-data-public.refreshinterval.md)

## RefreshInterval interface
## RefreshInterval type

<b>Signature:</b>

```typescript
export interface RefreshInterval
export declare type RefreshInterval = {
pause: boolean;
value: number;
};
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [pause](./kibana-plugin-plugins-data-public.refreshinterval.pause.md) | <code>boolean</code> | |
| [value](./kibana-plugin-plugins-data-public.refreshinterval.value.md) | <code>number</code> | |

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) &gt; [createDefaultInspectorAdapters](./kibana-plugin-plugins-expressions-public.createdefaultinspectoradapters.md)

## createDefaultInspectorAdapters variable

<b>Signature:</b>

```typescript
createDefaultInspectorAdapters: () => DefaultInspectorAdapters
```
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@

| Variable | Description |
| --- | --- |
| [createDefaultInspectorAdapters](./kibana-plugin-plugins-expressions-public.createdefaultinspectoradapters.md) | |
| [ReactExpressionRenderer](./kibana-plugin-plugins-expressions-public.reactexpressionrenderer.md) | |

## Type Aliases
Expand Down
29 changes: 27 additions & 2 deletions packages/kbn-es/src/integration_tests/__fixtures__/es_bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,36 @@ const { ES_KEY_PATH, ES_CERT_PATH } = require('@kbn/dev-utils');
},
(req, res) => {
const url = new URL(req.url, serverUrl);
const send = (code, body) => {
res.writeHead(code, { 'content-type': 'application/json' });
const send = (code, body, headers = {}) => {
res.writeHead(code, { 'content-type': 'application/json', ...headers });
res.end(JSON.stringify(body));
};

// ES client's Product check request: it checks some fields in the body and the header
if (url.pathname === '/') {
return send(
200,
{
name: 'es-bin',
cluster_name: 'elasticsearch',
cluster_uuid: 'k0sr2gr9S4OBtygmu9ndzA',
version: {
number: '8.0.0-SNAPSHOT',
build_flavor: 'default',
build_type: 'tar',
build_hash: 'b11c15b7e0af64f90c3eb9c52c2534b4f143a070',
build_date: '2021-08-03T19:32:39.781056185Z',
build_snapshot: true,
lucene_version: '8.9.0',
minimum_wire_compatibility_version: '7.15.0',
minimum_index_compatibility_version: '7.0.0',
},
tagline: 'You Know, for Search',
},
{ 'x-elastic-product': 'Elasticsearch' }
);
}

if (url.pathname === '/_xpack') {
return send(400, {
error: {
Expand Down
19 changes: 0 additions & 19 deletions packages/kbn-es/src/utils/native_realm.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,6 @@ const chalk = require('chalk');

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

/**
* Hack to skip the Product Check performed by the Elasticsearch-js client.
* We noticed a couple of bugs that may need to be fixed before taking full
* advantage of this feature.
*
* The bugs are detailed in this issue: https://github.com/elastic/kibana/issues/105557
*
* The hack is copied from the test/utils in the elasticsearch-js repo
* (https://github.com/elastic/elasticsearch-js/blob/master/test/utils/index.js#L45-L56)
*/
function skipProductCheck(client) {
const tSymbol = Object.getOwnPropertySymbols(client.transport || client).filter(
(symbol) => symbol.description === 'product check'
)[0];
(client.transport || client)[tSymbol] = 2;
}

exports.NativeRealm = class NativeRealm {
constructor({ elasticPassword, port, log = defaultLog, ssl = false, caCert }) {
this._client = new Client({
Expand All @@ -39,8 +22,6 @@ exports.NativeRealm = class NativeRealm {
}
: undefined,
});
// 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.
skipProductCheck(this._client);
this._elasticPassword = elasticPassword;
this._log = log;
}
Expand Down
12 changes: 12 additions & 0 deletions packages/kbn-rule-data-utils/src/alerts_as_data_status.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export const ALERT_STATUS_ACTIVE = 'active';
export const ALERT_STATUS_RECOVERED = 'recovered';

export type AlertStatus = typeof ALERT_STATUS_ACTIVE | typeof ALERT_STATUS_RECOVERED;
1 change: 1 addition & 0 deletions packages/kbn-rule-data-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
export * from './technical_field_names';
export * from './alerts_as_data_rbac';
export * from './alerts_as_data_severity';
export * from './alerts_as_data_status';
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ plugins:
initialize: false
migrations:
skip: true
elasticsearch:
skipStartupConnectionCheck: true
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ plugins:
initialize: false
migrations:
skip: true
elasticsearch:
skipStartupConnectionCheck: true
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ plugins:
initialize: false
migrations:
skip: true
elasticsearch:
skipStartupConnectionCheck: true
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('Core app routes', () => {
beforeAll(async function () {
root = kbnTestServer.createRoot({
plugins: { initialize: false },
elasticsearch: { skipStartupConnectionCheck: true },
server: {
basePath: '/base-path',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ describe('Platform assets', function () {
let root: Root;

beforeAll(async function () {
root = kbnTestServer.createRoot({ plugins: { initialize: false } });
root = kbnTestServer.createRoot({
plugins: { initialize: false },
elasticsearch: { skipStartupConnectionCheck: true },
});

await root.preboot();
await root.setup();
Expand Down
24 changes: 0 additions & 24 deletions src/core/server/elasticsearch/client/configure_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ export const configureClient = (
const client = new Client({ ...clientOptions, Transport: KibanaTransport });
addLogging(client, logger.get('query', type));

// ------------------------------------------------------------------------ //
// Hack to disable the "Product check" while the bugs in //
// https://github.com/elastic/kibana/issues/105557 are handled. //
skipProductCheck(client);
// ------------------------------------------------------------------------ //

return client;
};

Expand Down Expand Up @@ -137,21 +131,3 @@ const addLogging = (client: Client, logger: Logger) => {
}
});
};

/**
* Hack to skip the Product Check performed by the Elasticsearch-js client.
* We noticed a couple of bugs that may need to be fixed before taking full
* advantage of this feature.
*
* The bugs are detailed in this issue: https://github.com/elastic/kibana/issues/105557
*
* The hack is copied from the test/utils in the elasticsearch-js repo
* (https://github.com/elastic/elasticsearch-js/blob/master/test/utils/index.js#L45-L56)
*/
function skipProductCheck(client: Client) {
const tSymbol = Object.getOwnPropertySymbols(client.transport || client).filter(
(symbol) => symbol.description === 'product check'
)[0];
// @ts-expect-error `tSymbol` is missing in the index signature of Transport
(client.transport || client)[tSymbol] = 2;
}
31 changes: 31 additions & 0 deletions src/core/server/elasticsearch/elasticsearch_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ test('set correct defaults', () => {
"requestTimeout": "PT30S",
"serviceAccountToken": undefined,
"shardTimeout": "PT30S",
"skipStartupConnectionCheck": false,
"sniffInterval": false,
"sniffOnConnectionFault": false,
"sniffOnStart": false,
Expand Down Expand Up @@ -397,3 +398,33 @@ test('serviceAccountToken does not throw if username is not set', () => {

expect(() => config.schema.validate(obj)).not.toThrow();
});

describe('skipStartupConnectionCheck', () => {
test('defaults to `false`', () => {
const obj = {};
expect(() => config.schema.validate(obj)).not.toThrow();
expect(config.schema.validate(obj)).toEqual(
expect.objectContaining({
skipStartupConnectionCheck: false,
})
);
});

test('accepts `false` on both prod and dev mode', () => {
const obj = {
skipStartupConnectionCheck: false,
};
expect(() => config.schema.validate(obj, { dist: false })).not.toThrow();
expect(() => config.schema.validate(obj, { dist: true })).not.toThrow();
});

test('accepts `true` only when running from source to allow integration tests to run without an ES server', () => {
const obj = {
skipStartupConnectionCheck: true,
};
expect(() => config.schema.validate(obj, { dist: false })).not.toThrow();
expect(() => config.schema.validate(obj, { dist: true })).toThrowErrorMatchingInlineSnapshot(
`"[skipStartupConnectionCheck]: \\"skipStartupConnectionCheck\\" can only be set to true when running from source to allow integration tests to run without an ES server"`
);
});
});
27 changes: 27 additions & 0 deletions src/core/server/elasticsearch/elasticsearch_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,21 @@ export const configSchema = schema.object({
}),
schema.boolean({ defaultValue: false })
),
skipStartupConnectionCheck: schema.conditional(
// Using dist over dev because integration_tests run with dev: false,
// and this config is solely introduced to allow some of the integration tests to run without an ES server.
schema.contextRef('dist'),
true,
schema.boolean({
validate: (rawValue) => {
if (rawValue === true) {
return '"skipStartupConnectionCheck" can only be set to true when running from source to allow integration tests to run without an ES server';
}
},
defaultValue: false,
}),
schema.boolean({ defaultValue: false })
),
});

const deprecations: ConfigDeprecationProvider = () => [
Expand Down Expand Up @@ -220,6 +235,17 @@ export const config: ServiceConfigDescriptor<ElasticsearchConfigType> = {
* @public
*/
export class ElasticsearchConfig {
/**
* @internal
* Only valid in dev mode. Skip the valid connection check during startup. The connection check allows
* Kibana to ensure that the Elasticsearch connection is valid before allowing
* any other services to be set up.
*
* @remarks
* You should disable this check at your own risk: Other services in Kibana
* may fail if this step is not completed.
*/
public readonly skipStartupConnectionCheck: boolean;
/**
* The interval between health check requests Kibana sends to the Elasticsearch.
*/
Expand Down Expand Up @@ -337,6 +363,7 @@ export class ElasticsearchConfig {
this.password = rawConfig.password;
this.serviceAccountToken = rawConfig.serviceAccountToken;
this.customHeaders = rawConfig.customHeaders;
this.skipStartupConnectionCheck = rawConfig.skipStartupConnectionCheck;

const { alwaysPresentCertificate, verificationMode } = rawConfig.ssl;
const { key, keyPassphrase, certificate, certificateAuthorities } = readKeyAndCerts(rawConfig);
Expand Down
Loading

0 comments on commit 2b2b6cf

Please sign in to comment.