Skip to content

Commit

Permalink
Merge branch 'master' into auto_interval
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Sep 22, 2020
2 parents 90618b8 + c63ee1b commit 870c8dd
Show file tree
Hide file tree
Showing 120 changed files with 2,347 additions and 2,571 deletions.
4 changes: 2 additions & 2 deletions .ci/Jenkinsfile_baseline_capture
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ kibanaPipeline(timeoutMinutes: 120) {
]) {
parallel([
'oss-baseline': {
workers.ci(name: 'oss-baseline', size: 's-highmem', ramDisk: true, runErrorReporter: false) {
workers.ci(name: 'oss-baseline', size: 'l', ramDisk: true, runErrorReporter: false) {
kibanaPipeline.functionalTestProcess('oss-baseline', './test/scripts/jenkins_baseline.sh')()
}
},
'xpack-baseline': {
workers.ci(name: 'xpack-baseline', size: 's-highmem', ramDisk: true, runErrorReporter: false) {
workers.ci(name: 'xpack-baseline', size: 'l', ramDisk: true, runErrorReporter: false) {
kibanaPipeline.functionalTestProcess('xpack-baseline', './test/scripts/jenkins_xpack_baseline.sh')()
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ Get a list of field objects for an index pattern that may contain wildcards
getFieldsForWildcard(options: {
pattern: string | string[];
metaFields?: string[];
fieldCapsOptions?: {
allowNoIndices: boolean;
};
}): Promise<FieldDescriptor[]>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| options | <code>{</code><br/><code> pattern: string &#124; string[];</code><br/><code> metaFields?: string[];</code><br/><code> }</code> | |
| options | <code>{</code><br/><code> pattern: string &#124; string[];</code><br/><code> metaFields?: string[];</code><br/><code> fieldCapsOptions?: {</code><br/><code> allowNoIndices: boolean;</code><br/><code> };</code><br/><code> }</code> | |

<b>Returns:</b>

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
"babel-eslint": "^10.0.3",
"babel-jest": "^25.5.1",
"babel-plugin-istanbul": "^6.0.0",
"backport": "5.5.1",
"backport": "5.6.0",
"brace": "0.11.1",
"chai": "3.5.0",
"chance": "1.0.18",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-archiver/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export function runCli() {

const query = flags.query;
let parsedQuery;
if (typeof query === 'string') {
if (typeof query === 'string' && query.length > 0) {
try {
parsedQuery = JSON.parse(query);
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ export class IndexPatternsFetcher {
async getFieldsForWildcard(options: {
pattern: string | string[];
metaFields?: string[];
fieldCapsOptions?: { allowNoIndices: boolean };
}): Promise<FieldDescriptor[]> {
const { pattern, metaFields } = options;
return await getFieldCapabilities(this._callDataCluster, pattern, metaFields);
const { pattern, metaFields, fieldCapsOptions } = options;
return await getFieldCapabilities(this._callDataCluster, pattern, metaFields, fieldCapsOptions);
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src/plugins/data/server/index_patterns/fetcher/lib/es_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,20 @@ export async function callIndexAliasApi(
*
* @param {Function} callCluster bound function for accessing an es client
* @param {Array<String>|String} indices
* @param {Object} fieldCapsOptions
* @return {Promise<FieldCapsResponse>}
*/
export async function callFieldCapsApi(callCluster: LegacyAPICaller, indices: string[] | string) {
export async function callFieldCapsApi(
callCluster: LegacyAPICaller,
indices: string[] | string,
fieldCapsOptions: { allowNoIndices: boolean } = { allowNoIndices: false }
) {
try {
return (await callCluster('fieldCaps', {
index: indices,
fields: '*',
ignoreUnavailable: true,
allowNoIndices: false,
...fieldCapsOptions,
})) as FieldCapsResponse;
} catch (error) {
throw convertEsError(indices, error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('index_patterns/field_capabilities/field_capabilities', () => {

await getFieldCapabilities(footballs[0], footballs[1]);
sinon.assert.calledOnce(callFieldCapsApi);
calledWithExactly(callFieldCapsApi, [footballs[0], footballs[1]]);
calledWithExactly(callFieldCapsApi, [footballs[0], footballs[1], undefined]);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,20 @@ import { FieldDescriptor } from '../../index_patterns_fetcher';
* @param {Function} callCluster bound function for accessing an es client
* @param {Array} [indices=[]] the list of indexes to check
* @param {Array} [metaFields=[]] the list of internal fields to include
* @param {Object} fieldCapsOptions
* @return {Promise<Array<FieldDescriptor>>}
*/
export async function getFieldCapabilities(
callCluster: LegacyAPICaller,
indices: string | string[] = [],
metaFields: string[] = []
metaFields: string[] = [],
fieldCapsOptions?: { allowNoIndices: boolean }
) {
const esFieldCaps: FieldCapsResponse = await callFieldCapsApi(callCluster, indices);
const esFieldCaps: FieldCapsResponse = await callFieldCapsApi(
callCluster,
indices,
fieldCapsOptions
);
const fieldsFromFieldCapsByName = keyBy(readFieldCapsResponse(esFieldCaps), 'name');

const allFieldsUnsorted = Object.keys(fieldsFromFieldCapsByName)
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/data/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,9 @@ export class IndexPatternsFetcher {
getFieldsForWildcard(options: {
pattern: string | string[];
metaFields?: string[];
fieldCapsOptions?: {
allowNoIndices: boolean;
};
}): Promise<IndexPatternFieldDescriptor[]>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,77 @@
*/

import { i18n } from '@kbn/i18n';
import { get } from 'lodash';

export function getPainlessError(error: Error) {
const rootCause: Array<{ lang: string; script: string }> | undefined = get(
error,
'body.attributes.error.root_cause'
);
const message: string = get(error, 'body.message');
interface FailedShards {
shard: number;
index: string;
node: string;
reason: {
type: string;
reason: string;
script_stack: string[];
script: string;
lang: string;
position: {
offset: number;
start: number;
end: number;
};
caused_by: {
type: string;
reason: string;
};
};
}

interface EsError {
body: {
statusCode: number;
error: string;
message: string;
attributes?: {
error?: {
root_cause?: [
{
lang: string;
script: string;
}
];
type: string;
reason: string;
caused_by: {
type: string;
reason: string;
phase: string;
grouped: boolean;
failed_shards: FailedShards[];
};
};
};
};
}

export function getCause(error: EsError) {
const cause = error.body?.attributes?.error?.root_cause;
if (cause) {
return cause[0];
}

const failedShards = error.body?.attributes?.error?.caused_by?.failed_shards;

if (failedShards && failedShards[0] && failedShards[0].reason) {
return error.body?.attributes?.error?.caused_by?.failed_shards[0].reason;
}
}

export function getPainlessError(error: EsError) {
const cause = getCause(error);

if (!rootCause) {
if (!cause) {
return;
}

const [{ lang, script }] = rootCause;
const { lang, script } = cause;

if (lang !== 'painless') {
return;
Expand All @@ -44,6 +101,6 @@ export function getPainlessError(error: Error) {
defaultMessage: "Error with Painless scripted field '{script}'.",
values: { script },
}),
error: message,
error: error.body?.message,
};
}
8 changes: 0 additions & 8 deletions src/plugins/embeddable/public/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import { UiActionsSetup } from '../../ui_actions/public';
import {
contextMenuTrigger,
createFilterAction,
panelBadgeTrigger,
EmbeddableContext,
CONTEXT_MENU_TRIGGER,
Expand All @@ -29,8 +28,6 @@ import {
ACTION_INSPECT_PANEL,
REMOVE_PANEL_ACTION,
ACTION_EDIT_PANEL,
FilterActionContext,
ACTION_APPLY_FILTER,
panelNotificationTrigger,
PANEL_NOTIFICATION_TRIGGER,
} from './lib';
Expand All @@ -48,7 +45,6 @@ declare module '../../ui_actions/public' {
[ACTION_INSPECT_PANEL]: EmbeddableContext;
[REMOVE_PANEL_ACTION]: EmbeddableContext;
[ACTION_EDIT_PANEL]: EmbeddableContext;
[ACTION_APPLY_FILTER]: FilterActionContext;
}
}

Expand All @@ -60,8 +56,4 @@ export const bootstrap = (uiActions: UiActionsSetup) => {
uiActions.registerTrigger(contextMenuTrigger);
uiActions.registerTrigger(panelBadgeTrigger);
uiActions.registerTrigger(panelNotificationTrigger);

const actionApplyFilter = createFilterAction();

uiActions.registerAction(actionApplyFilter);
};
1 change: 0 additions & 1 deletion src/plugins/embeddable/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { EmbeddablePublicPlugin } from './plugin';

export {
ACTION_ADD_PANEL,
ACTION_APPLY_FILTER,
ACTION_EDIT_PANEL,
Adapters,
AddPanelAction,
Expand Down
Loading

0 comments on commit 870c8dd

Please sign in to comment.