Skip to content

Commit

Permalink
Merge branch 'master' into revert-side-car
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankHassanabad committed Sep 27, 2021
2 parents 9dbaae6 + ae4e7cc commit a1a94c5
Show file tree
Hide file tree
Showing 114 changed files with 3,043 additions and 1,350 deletions.
9 changes: 8 additions & 1 deletion .buildkite/scripts/steps/storybooks/build_and_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ const path = require('path');
const STORYBOOKS = [
'apm',
'canvas',
'codeeditor',
'ci_composite',
'url_template_editor',
'codeeditor',
'dashboard',
'dashboard_enhanced',
'data_enhanced',
'embeddable',
'expression_error',
'expression_image',
'expression_metric',
'expression_repeat_image',
'expression_reveal_image',
'expression_shape',
'expression_tagcloud',
'fleet',
'infra',
'security_solution',
Expand Down
18 changes: 17 additions & 1 deletion docs/user/dashboard/lens.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -441,4 +441,20 @@ Pagination in a data table is unsupported. To use pagination in data tables, cre
[%collapsible]
====
Specifying the color for a single data point, such as a single bar or line, is unsupported.
====
====

[discrete]
[[is-it-possible-to-inspect-the-elasticsearch-queries-in-Lens]]
.*How do I inspect {es} queries in visualizations?*
[%collapsible]
====
You can inspect the requests sent by the visualization to {es} using the Inspector. It can be accessed within the editor or in the dashboard.
====

[discrete]
[[how-to-isolate-a-single-series-in-a-chart]]
.*How do I isolate a single series in a chart?*
[%collapsible]
====
For area, line, and bar charts, press Shift, then click the series in the legend. All other series are automatically unselected.
====
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pageLoadAssetSize:
transform: 41007
triggersActionsUi: 100000
uiActions: 97717
uiActionsEnhanced: 313011
uiActionsEnhanced: 32000
upgradeAssistant: 81241
uptime: 40825
urlDrilldown: 70674
Expand Down
18 changes: 0 additions & 18 deletions src/core/server/elasticsearch/deprecations/deprecation_provider.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/core/server/elasticsearch/deprecations/index.ts

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@

export const MockClusterClient = jest.fn();
jest.mock('./client/cluster_client', () => ({ ClusterClient: MockClusterClient }));

export const isScriptingEnabledMock = jest.fn();
jest.doMock('./is_scripting_enabled', () => ({
isInlineScriptingEnabled: isScriptingEnabledMock,
}));
66 changes: 42 additions & 24 deletions src/core/server/elasticsearch/elasticsearch_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ jest.mock('./version_check/ensure_es_version', () => ({
pollEsNodesVersion: jest.fn(),
}));

import { MockClusterClient, isScriptingEnabledMock } from './elasticsearch_service.test.mocks';

import type { NodesVersionCompatibility } from './version_check/ensure_es_version';
import { MockClusterClient } from './elasticsearch_service.test.mocks';
import { BehaviorSubject } from 'rxjs';
import { first } from 'rxjs/operators';
import { REPO_ROOT } from '@kbn/dev-utils';
Expand All @@ -30,7 +31,6 @@ import { executionContextServiceMock } from '../execution_context/execution_cont
import { configSchema, ElasticsearchConfig } from './elasticsearch_config';
import { ElasticsearchService, SetupDeps } from './elasticsearch_service';
import { elasticsearchClientMock } from './client/mocks';
import { deprecationsServiceMock } from '../deprecations/deprecations_service.mock';
import { duration } from 'moment';
import { isValidConnection as isValidConnectionMock } from './is_valid_connection';
import { pollEsNodesVersion as pollEsNodesVersionMocked } from './version_check/ensure_es_version';
Expand All @@ -50,15 +50,11 @@ let coreContext: CoreContext;
let mockClusterClientInstance: ReturnType<typeof elasticsearchClientMock.createCustomClusterClient>;
let mockConfig$: BehaviorSubject<any>;
let setupDeps: SetupDeps;
let deprecationsSetup: ReturnType<typeof deprecationsServiceMock.createInternalSetupContract>;

beforeEach(() => {
deprecationsSetup = deprecationsServiceMock.createInternalSetupContract();

setupDeps = {
http: httpServiceMock.createInternalSetupContract(),
executionContext: executionContextServiceMock.createInternalSetupContract(),
deprecations: deprecationsSetup,
};

env = Env.createDefault(REPO_ROOT, getEnvOptions());
Expand All @@ -78,15 +74,20 @@ beforeEach(() => {
coreContext = { coreId: Symbol(), env, logger, configService: configService as any };
elasticsearchService = new ElasticsearchService(coreContext);

MockClusterClient.mockClear();
mockClusterClientInstance = elasticsearchClientMock.createCustomClusterClient();
MockClusterClient.mockImplementation(() => mockClusterClientInstance);

isScriptingEnabledMock.mockResolvedValue(true);

// @ts-expect-error TS does not get that `pollEsNodesVersion` is mocked
pollEsNodesVersionMocked.mockImplementation(pollEsNodesVersionActual);
});

afterEach(() => jest.clearAllMocks());
afterEach(() => {
jest.clearAllMocks();
MockClusterClient.mockClear();
isScriptingEnabledMock.mockReset();
});

describe('#preboot', () => {
describe('#config', () => {
Expand Down Expand Up @@ -181,22 +182,6 @@ describe('#setup', () => {
);
});

it('registers its deprecation provider', async () => {
const registry = deprecationsServiceMock.createSetupContract();

deprecationsSetup.getRegistry.mockReturnValue(registry);

await elasticsearchService.setup(setupDeps);

expect(deprecationsSetup.getRegistry).toHaveBeenCalledTimes(1);
expect(deprecationsSetup.getRegistry).toHaveBeenCalledWith('elasticsearch');

expect(registry.registerDeprecations).toHaveBeenCalledTimes(1);
expect(registry.registerDeprecations).toHaveBeenCalledWith({
getDeprecations: expect.any(Function),
});
});

it('esNodeVersionCompatibility$ only starts polling when subscribed to', async (done) => {
const mockedClient = mockClusterClientInstance.asInternalUser;
mockedClient.nodes.info.mockImplementation(() =>
Expand Down Expand Up @@ -302,6 +287,39 @@ describe('#start', () => {
});
});

describe('isInlineScriptingEnabled', () => {
it('does not throw error when scripting is enabled', async () => {
isScriptingEnabledMock.mockResolvedValue(true);

await elasticsearchService.setup(setupDeps);
expect(isScriptingEnabledMock).not.toHaveBeenCalled();

await expect(elasticsearchService.start()).resolves.toBeDefined();
expect(isScriptingEnabledMock).toHaveBeenCalledTimes(1);
});

it('throws an error if scripting is disabled', async () => {
isScriptingEnabledMock.mockResolvedValue(false);

await elasticsearchService.setup(setupDeps);

await expect(elasticsearchService.start()).rejects.toThrowError(
'Inline scripting is disabled'
);
});

it('does not throw error when `skipStartupConnectionCheck` is true', async () => {
isScriptingEnabledMock.mockResolvedValue(false);
mockConfig$.next({
...(await mockConfig$.pipe(first()).toPromise()),
skipStartupConnectionCheck: true,
});

await elasticsearchService.setup(setupDeps);
await expect(elasticsearchService.start()).resolves.toBeDefined();
});
});

describe('#createClient', () => {
it('allows to specify config properties', async () => {
await elasticsearchService.setup(setupDeps);
Expand Down
20 changes: 13 additions & 7 deletions src/core/server/elasticsearch/elasticsearch_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { ClusterClient, ElasticsearchClientConfig } from './client';
import { ElasticsearchConfig, ElasticsearchConfigType } from './elasticsearch_config';
import type { InternalHttpServiceSetup, GetAuthHeaders } from '../http';
import type { InternalExecutionContextSetup, IExecutionContext } from '../execution_context';
import type { InternalDeprecationsServiceSetup } from '../deprecations';
import {
InternalElasticsearchServicePreboot,
InternalElasticsearchServiceSetup,
Expand All @@ -28,11 +27,10 @@ import type { NodesVersionCompatibility } from './version_check/ensure_es_versio
import { pollEsNodesVersion } from './version_check/ensure_es_version';
import { calculateStatus$ } from './status';
import { isValidConnection } from './is_valid_connection';
import { getElasticsearchDeprecationsProvider } from './deprecations';
import { isInlineScriptingEnabled } from './is_scripting_enabled';

export interface SetupDeps {
http: InternalHttpServiceSetup;
deprecations: InternalDeprecationsServiceSetup;
executionContext: InternalExecutionContextSetup;
}

Expand Down Expand Up @@ -82,10 +80,6 @@ export class ElasticsearchService
this.executionContextClient = deps.executionContext;
this.client = this.createClusterClient('data', config);

deps.deprecations
.getRegistry('elasticsearch')
.registerDeprecations(getElasticsearchDeprecationsProvider());

const esNodesCompatibility$ = pollEsNodesVersion({
internalClient: this.client.asInternalUser,
log: this.log,
Expand Down Expand Up @@ -122,6 +116,18 @@ export class ElasticsearchService
if (!config.skipStartupConnectionCheck) {
// Ensure that the connection is established and the product is valid before moving on
await isValidConnection(this.esNodesCompatibility$);

// Ensure inline scripting is enabled on the ES cluster
const scriptingEnabled = await isInlineScriptingEnabled({
client: this.client.asInternalUser,
});
if (!scriptingEnabled) {
throw new Error(
'Inline scripting is disabled on the Elasticsearch cluster, and is mandatory for Kibana to function. ' +
'Please enabled inline scripting, then restart Kibana. ' +
'Refer to https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting-security.html for more info.'
);
}
}

return {
Expand Down
Loading

0 comments on commit a1a94c5

Please sign in to comment.