Skip to content

Commit

Permalink
Merge branch 'main' of github.com:elastic/kibana
Browse files Browse the repository at this point in the history
  • Loading branch information
CoenWarmer committed Feb 23, 2024
2 parents 335019c + a852776 commit 62dd52d
Show file tree
Hide file tree
Showing 80 changed files with 1,141 additions and 511 deletions.
4 changes: 2 additions & 2 deletions .buildkite/pipelines/on_merge_unsupported_ftrs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ steps:
queue: n2-4-virt
depends_on: build
timeout_in_minutes: 60
parallelism: 10
parallelism: 16
retry:
automatic:
- exit_status: '*'
Expand All @@ -80,7 +80,7 @@ steps:
queue: n2-4-virt
depends_on: build
timeout_in_minutes: 60
parallelism: 6
parallelism: 10
retry:
automatic:
- exit_status: '*'
Expand Down
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,9 @@ x-pack/test/security_solution_cypress/cypress/tasks/expandable_flyout @elastic/
/x-pack/plugins/stack_connectors/server/connector_types/sentinelone @elastic/security-defend-workflows
/x-pack/plugins/stack_connectors/common/sentinelone @elastic/security-defend-workflows

## Security Solution shared OAS schemas
/x-pack/plugins/security_solution/common/api/model @elastic/security-detection-rule-management @elastic/security-detection-engine

## Security Solution sub teams - Detection Rule Management
/x-pack/plugins/security_solution/common/api/detection_engine/fleet_integrations @elastic/security-detection-rule-management
/x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema @elastic/security-detection-rule-management @elastic/security-detection-engine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import { errors } from '@elastic/elasticsearch';
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-mocks';
import { retryCallCluster, migrationRetryCallCluster } from './retry_call_cluster';

Expand Down Expand Up @@ -69,11 +68,9 @@ describe('retryCallCluster', () => {

describe('migrationRetryCallCluster', () => {
let client: ReturnType<typeof elasticsearchClientMock.createElasticsearchClient>;
let logger: ReturnType<typeof loggingSystemMock.createLogger>;

beforeEach(() => {
client = elasticsearchClientMock.createElasticsearchClient();
logger = loggingSystemMock.createLogger();
});

const mockClientPingWithErrorBeforeSuccess = (error: any) => {
Expand All @@ -88,21 +85,21 @@ describe('migrationRetryCallCluster', () => {
new errors.NoLivingConnectionsError('no living connections', {} as any)
);

const result = await migrationRetryCallCluster(() => client.ping(), logger, 1);
const result = await migrationRetryCallCluster(() => client.ping(), 1);
expect(result).toEqual(dummyBody);
});

it('retries ES API calls that rejects with `ConnectionError`', async () => {
mockClientPingWithErrorBeforeSuccess(new errors.ConnectionError('connection error', {} as any));

const result = await migrationRetryCallCluster(() => client.ping(), logger, 1);
const result = await migrationRetryCallCluster(() => client.ping(), 1);
expect(result).toEqual(dummyBody);
});

it('retries ES API calls that rejects with `TimeoutError`', async () => {
mockClientPingWithErrorBeforeSuccess(new errors.TimeoutError('timeout error', {} as any));

const result = await migrationRetryCallCluster(() => client.ping(), logger, 1);
const result = await migrationRetryCallCluster(() => client.ping(), 1);
expect(result).toEqual(dummyBody);
});

Expand All @@ -113,7 +110,7 @@ describe('migrationRetryCallCluster', () => {
} as any)
);

const result = await migrationRetryCallCluster(() => client.ping(), logger, 1);
const result = await migrationRetryCallCluster(() => client.ping(), 1);
expect(result).toEqual(dummyBody);
});

Expand All @@ -124,7 +121,7 @@ describe('migrationRetryCallCluster', () => {
} as any)
);

const result = await migrationRetryCallCluster(() => client.ping(), logger, 1);
const result = await migrationRetryCallCluster(() => client.ping(), 1);
expect(result).toEqual(dummyBody);
});

Expand All @@ -135,7 +132,7 @@ describe('migrationRetryCallCluster', () => {
} as any)
);

const result = await migrationRetryCallCluster(() => client.ping(), logger, 1);
const result = await migrationRetryCallCluster(() => client.ping(), 1);
expect(result).toEqual(dummyBody);
});

Expand All @@ -146,7 +143,7 @@ describe('migrationRetryCallCluster', () => {
} as any)
);

const result = await migrationRetryCallCluster(() => client.ping(), logger, 1);
const result = await migrationRetryCallCluster(() => client.ping(), 1);
expect(result).toEqual(dummyBody);
});

Expand All @@ -157,7 +154,7 @@ describe('migrationRetryCallCluster', () => {
} as any)
);

const result = await migrationRetryCallCluster(() => client.ping(), logger, 1);
const result = await migrationRetryCallCluster(() => client.ping(), 1);
expect(result).toEqual(dummyBody);
});

Expand All @@ -173,65 +170,10 @@ describe('migrationRetryCallCluster', () => {
} as any)
);

const result = await migrationRetryCallCluster(() => client.ping(), logger, 1);
const result = await migrationRetryCallCluster(() => client.ping(), 1);
expect(result).toEqual(dummyBody);
});

it('logs only once for each unique error message', async () => {
client.ping
.mockImplementationOnce(() =>
createErrorReturn(
new errors.ResponseError({
statusCode: 503,
} as any)
)
)
.mockImplementationOnce(() =>
createErrorReturn(new errors.ConnectionError('connection error', {} as any))
)
.mockImplementationOnce(() =>
createErrorReturn(
new errors.ResponseError({
statusCode: 503,
} as any)
)
)
.mockImplementationOnce(() =>
createErrorReturn(new errors.ConnectionError('connection error', {} as any))
)
.mockImplementationOnce(() =>
createErrorReturn(
new errors.ResponseError({
statusCode: 500,
body: {
error: {
type: 'snapshot_in_progress_exception',
},
},
} as any)
)
)
.mockImplementationOnce(() =>
elasticsearchClientMock.createSuccessTransportRequestPromise({ ...dummyBody })
);

await migrationRetryCallCluster(() => client.ping(), logger, 1);

expect(loggingSystemMock.collect(logger).warn).toMatchInlineSnapshot(`
Array [
Array [
"Unable to connect to Elasticsearch. Error: Response Error",
],
Array [
"Unable to connect to Elasticsearch. Error: connection error",
],
Array [
"Unable to connect to Elasticsearch. Error: snapshot_in_progress_exception",
],
]
`);
});

it('rejects when ES API calls reject with other errors', async () => {
client.ping
.mockImplementationOnce(() =>
Expand All @@ -250,9 +192,9 @@ describe('migrationRetryCallCluster', () => {
elasticsearchClientMock.createSuccessTransportRequestPromise({ ...dummyBody })
);

await expect(
migrationRetryCallCluster(() => client.ping(), logger, 1)
).rejects.toMatchInlineSnapshot(`[ResponseError: I'm a teapot]`);
await expect(migrationRetryCallCluster(() => client.ping(), 1)).rejects.toMatchInlineSnapshot(
`[ResponseError: I'm a teapot]`
);
});

it('stops retrying when ES API calls reject with other errors', async () => {
Expand All @@ -268,8 +210,8 @@ describe('migrationRetryCallCluster', () => {
elasticsearchClientMock.createSuccessTransportRequestPromise({ ...dummyBody })
);

await expect(
migrationRetryCallCluster(() => client.ping(), logger, 1)
).rejects.toMatchInlineSnapshot(`[Error: unknown error]`);
await expect(migrationRetryCallCluster(() => client.ping(), 1)).rejects.toMatchInlineSnapshot(
`[Error: unknown error]`
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import { defer, throwError, iif, timer } from 'rxjs';
import { concatMap, retryWhen } from 'rxjs/operators';
import type { Logger } from '@kbn/logging';

const retryResponseStatuses = [
503, // ServiceUnavailable
Expand Down Expand Up @@ -60,7 +59,6 @@ export const retryCallCluster = <T extends Promise<unknown>>(apiCaller: () => T)
*/
export const migrationRetryCallCluster = <T extends Promise<unknown>>(
apiCaller: () => T,
log: Logger,
delay: number = 2500
): T => {
const previousErrors: string[] = [];
Expand All @@ -70,7 +68,6 @@ export const migrationRetryCallCluster = <T extends Promise<unknown>>(
errors.pipe(
concatMap((error) => {
if (!previousErrors.includes(error.message)) {
log.warn(`Unable to connect to Elasticsearch. Error: ${error.message}`);
previousErrors.push(error.message);
}
return iif(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export async function getCurrentIndexTypesMap({
client.indices.getMapping({
index: mainIndex,
}),
logger,
retryDelay
);

Expand Down
7 changes: 6 additions & 1 deletion packages/deeplinks/observability/deep_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ export type ObservabilityOverviewLinkId =
| 'rules'
| 'slos';

export type MetricsLinkId = 'inventory' | 'metrics-explorer' | 'hosts' | 'settings';
export type MetricsLinkId =
| 'inventory'
| 'metrics-explorer'
| 'hosts'
| 'settings'
| 'assetDetails';

export type ApmLinkId =
| 'services'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const SchedulePanel: React.FC<SchedulePanelProps> = ({ title, description
interface ConnectorContentSchedulingProps {
children?: React.ReactNode;
connector: Connector;
configurationPathOnClick: () => void;
configurationPathOnClick?: () => void;
dataTelemetryIdPrefix: string;
hasPlatinumLicense: boolean;
hasChanges: boolean;
Expand Down
33 changes: 19 additions & 14 deletions packages/kbn-unified-data-table/src/components/data_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
import type { ToastsStart, IUiSettingsClient } from '@kbn/core/public';
import type { Serializable } from '@kbn/utility-types';
import type { DataTableRecord } from '@kbn/discover-utils/types';
import { getShouldShowFieldHandler, DOC_HIDE_TIME_COLUMN_SETTING } from '@kbn/discover-utils';
import { getShouldShowFieldHandler } from '@kbn/discover-utils';
import type { DataViewFieldEditorStart } from '@kbn/data-view-field-editor-plugin/public';
import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public';
import type { ThemeServiceStart } from '@kbn/react-kibana-context-common';
Expand All @@ -63,7 +63,7 @@ import {
getEuiGridColumns,
getLeadControlColumns,
getVisibleColumns,
hasSourceTimeFieldValue,
canPrependTimeFieldColumn,
} from './data_table_columns';
import { UnifiedDataTableContext } from '../table_context';
import { getSchemaDetectors } from './data_table_schema';
Expand Down Expand Up @@ -630,15 +630,23 @@ export const UnifiedDataTable = ({
[dataView, onFieldEdited, services.dataViewFieldEditor]
);

const shouldShowTimeField = useMemo(
() =>
hasSourceTimeFieldValue(displayedColumns, dataView, columnTypes, showTimeCol, isPlainRecord),
[dataView, displayedColumns, isPlainRecord, showTimeCol, columnTypes]
const timeFieldName = dataView.timeFieldName;
const shouldPrependTimeFieldColumn = useCallback(
(activeColumns: string[]) =>
canPrependTimeFieldColumn(
activeColumns,
timeFieldName,
columnTypes,
showTimeCol,
isPlainRecord
),
[timeFieldName, isPlainRecord, showTimeCol, columnTypes]
);

const visibleColumns = useMemo(
() => getVisibleColumns(displayedColumns, dataView, shouldShowTimeField),
[dataView, displayedColumns, shouldShowTimeField]
() =>
getVisibleColumns(displayedColumns, dataView, shouldPrependTimeFieldColumn(displayedColumns)),
[dataView, displayedColumns, shouldPrependTimeFieldColumn]
);

const getCellValue = useCallback<UseDataGridColumnsCellActionsProps['getCellValue']>(
Expand Down Expand Up @@ -741,19 +749,16 @@ export const UnifiedDataTable = ({
]
);

const hideTimeColumn = useMemo(
() => services.uiSettings.get(DOC_HIDE_TIME_COLUMN_SETTING, false),
[services.uiSettings]
);
const schemaDetectors = useMemo(() => getSchemaDetectors(), []);
const columnsVisibility = useMemo(
() => ({
visibleColumns,
setVisibleColumns: (newColumns: string[]) => {
onSetColumns(newColumns, hideTimeColumn);
const dontModifyColumns = !shouldPrependTimeFieldColumn(newColumns);
onSetColumns(newColumns, dontModifyColumns);
},
}),
[visibleColumns, hideTimeColumn, onSetColumns]
[visibleColumns, onSetColumns, shouldPrependTimeFieldColumn]
);

/**
Expand Down
Loading

0 comments on commit 62dd52d

Please sign in to comment.