Skip to content

Commit

Permalink
Merge branch 'main' into cypress/global-auditbeat
Browse files Browse the repository at this point in the history
  • Loading branch information
MadameSheema authored Sep 7, 2023
2 parents 0e8e7a9 + 8f22eb1 commit 5810cac
Show file tree
Hide file tree
Showing 219 changed files with 6,528 additions and 951 deletions.
3 changes: 3 additions & 0 deletions .buildkite/pipelines/pipeline.kibana-serverless-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ steps:
SERVICE: kibana-controller
NAMESPACE: kibana-ci
IMAGE_NAME: kibana-serverless

notify:
- slack: "#kibana-mission-control"
4 changes: 2 additions & 2 deletions .buildkite/pipelines/pull_request/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ steps:
queue: n2-4-spot
depends_on: build
timeout_in_minutes: 40
parallelism: 12
parallelism: 2
soft_fail: true
retry:
automatic:
Expand All @@ -166,7 +166,7 @@ steps:
queue: n2-4-spot
depends_on: build
timeout_in_minutes: 40
parallelism: 6
parallelism: 2
soft_fail: true
retry:
automatic:
Expand Down
19 changes: 10 additions & 9 deletions .buildkite/pipelines/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,32 +105,33 @@ steps:
queue: n2-4-spot
depends_on: build
timeout_in_minutes: 40
parallelism: 12
parallelism: 2
retry:
automatic:
- exit_status: '*'
limit: 1

- command: .buildkite/scripts/steps/functional/security_serverless_explore.sh
label: 'Serverless Explore - Security Solution Cypress Tests'
- command: .buildkite/scripts/steps/functional/security_serverless_investigations.sh
label: 'Serverless Security Investigations Cypress Tests'
agents:
queue: n2-4-spot
depends_on: build
timeout_in_minutes: 60
parallelism: 4
timeout_in_minutes: 120
parallelism: 2
retry:
automatic:
- exit_status: '*'
limit: 1

- command: .buildkite/scripts/steps/functional/security_serverless_investigations.sh
label: 'Serverless Investigations - Security Solution Cypress Tests'
- command: .buildkite/scripts/steps/functional/security_serverless_explore.sh
label: 'Serverless Security Explore Cypress Tests'
agents:
queue: n2-4-spot
depends_on: build
timeout_in_minutes: 120
parallelism: 6
timeout_in_minutes: 60
parallelism: 2
retry:
automatic:
- exit_status: '*'
limit: 1

6 changes: 4 additions & 2 deletions .buildkite/scripts/lifecycle/post_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ if [[ "$IS_TEST_EXECUTION_STEP" == "true" ]]; then
buildkite-agent artifact upload '.es/**/*.hprof'
buildkite-agent artifact upload 'data/es_debug_*.tar.gz'

echo "--- Run Failed Test Reporter"
node scripts/report_failed_tests --build-url="${BUILDKITE_BUILD_URL}#${BUILDKITE_JOB_ID}" 'target/junit/**/*.xml'
if [[ $BUILDKITE_COMMAND_EXIT_STATUS -ne 0 ]]; then
echo "--- Run Failed Test Reporter"
node scripts/report_failed_tests --build-url="${BUILDKITE_BUILD_URL}#${BUILDKITE_JOB_ID}" 'target/junit/**/*.xml'
fi

if [[ -d 'target/test_failures' ]]; then
buildkite-agent artifact upload 'target/test_failures/**/*'
Expand Down
1 change: 1 addition & 0 deletions config/serverless.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ xpack.observability.enabled: false
xpack.securitySolution.enabled: false
xpack.serverless.observability.enabled: false
xpack.uptime.enabled: false
xpack.legacy_uptime.enabled: false
enterpriseSearch.enabled: false
monitoring.ui.enabled: false
xpack.fleet.enabled: false
Expand Down
4 changes: 3 additions & 1 deletion config/serverless.oblt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
enterpriseSearch.enabled: false
xpack.cloudSecurityPosture.enabled: false
xpack.securitySolution.enabled: false
xpack.uptime.enabled: false
xpack.legacy_uptime.enabled: false

## Enable the Serverless Observability plugin
xpack.serverless.observability.enabled: true
Expand All @@ -24,7 +26,7 @@ xpack.fleet.agentIdVerificationEnabled: false
xpack.apm.serverlessOnboarding: true

# Fleet specific configuration
xpack.fleet.internal.capabilities: ['apm', 'uptime', 'observability']
xpack.fleet.internal.capabilities: ['apm', 'observability']

## Required for force installation of APM Package
xpack.fleet.packages:
Expand Down
1 change: 1 addition & 0 deletions config/serverless.security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ enterpriseSearch.enabled: false
xpack.apm.enabled: false
xpack.observability.enabled: false
xpack.uptime.enabled: false
xpack.legacy_uptime.enabled: false

## Enable the Security Solution Serverless plugin
xpack.securitySolutionServerless.enabled: true
Expand Down
1 change: 1 addition & 0 deletions config/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ xpack.alerting.rules.run.ruleTypeOverrides:
xpack.alerting.rules.minimumScheduleInterval.enforce: true
xpack.alerting.rules.maxScheduledPerMinute: 400
xpack.actions.run.maxAttempts: 10
xpack.actions.queued.max: 10000

# Disables ESQL in advanced settings (hides it from the UI)
uiSettings:
Expand Down
3 changes: 3 additions & 0 deletions docs/settings/alert-action-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ xpack.actions.run:
maxAttempts: 5
--

`xpack.actions.queued.max` {ess-icon}::
Specifies the maximum number of actions that can be queued. Default: 1000000

[float]
[[preconfigured-connector-settings]]
=== Preconfigured connector settings
Expand Down
16 changes: 16 additions & 0 deletions packages/kbn-config-schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,22 @@ function recordOf<K extends string, V>(
return new RecordOfType(keyType, valueType, options);
}

function oneOf<A, B, C, D, E, F, G, H, I, J, K>(
types: [
Type<A>,
Type<B>,
Type<C>,
Type<D>,
Type<E>,
Type<F>,
Type<G>,
Type<H>,
Type<I>,
Type<J>,
Type<K>
],
options?: TypeOptions<A | B | C | D | E | F | G | H | I | J | K>
): Type<A | B | C | D | E | F | G | H | I | J | K>;
function oneOf<A, B, C, D, E, F, G, H, I, J>(
types: [Type<A>, Type<B>, Type<C>, Type<D>, Type<E>, Type<F>, Type<G>, Type<H>, Type<I>, Type<J>],
options?: TypeOptions<A | B | C | D | E | F | G | H | I | J>
Expand Down
15 changes: 9 additions & 6 deletions packages/kbn-es/src/utils/docker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,15 +476,18 @@ describe('runServerlessCluster()', () => {
[baseEsPath]: {},
});
execa.mockImplementation(() => Promise.resolve({ stdout: '' }));
const info = jest.fn();
jest.requireMock('@elastic/elasticsearch').Client.mockImplementation(() => ({ info }));
const health = jest.fn();
jest
.requireMock('@elastic/elasticsearch')
.Client.mockImplementation(() => ({ cluster: { health } }));

info.mockImplementationOnce(() => Promise.reject()); // first call fails
info.mockImplementationOnce(() => Promise.resolve()); // then succeeds
health.mockImplementationOnce(() => Promise.reject()); // first call fails
health.mockImplementationOnce(() => Promise.resolve({ status: 'red' })); // second call return wrong status
health.mockImplementationOnce(() => Promise.resolve({ status: 'green' })); // then succeeds

await runServerlessCluster(log, { basePath: baseEsPath, waitForReady: true });
expect(info).toHaveBeenCalledTimes(2);
});
expect(health).toHaveBeenCalledTimes(3);
}, 10000);
});
});

Expand Down
23 changes: 3 additions & 20 deletions packages/kbn-es/src/utils/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
ELASTIC_SERVERLESS_SUPERUSER_PASSWORD,
} from './ess_file_realm';
import { SYSTEM_INDICES_SUPERUSER } from './native_realm';
import { waitUntilClusterReady } from './wait_until_cluster_ready';

interface BaseOptions {
tag?: string;
Expand Down Expand Up @@ -560,25 +561,6 @@ function getESClient(clientOptions: ClientOptions): Client {
});
}

const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));
async function waitUntilClusterReady(
clientOptions: ClientOptions,
timeoutMs = 60 * 1000
): Promise<void> {
const started = Date.now();
const client = getESClient(clientOptions);

while (started + timeoutMs > Date.now()) {
try {
await client.info();
break;
} catch (e) {
await delay(1000);
/* trap to continue */
}
}
}

/**
* Runs an ES Serverless Cluster through Docker
*/
Expand Down Expand Up @@ -636,7 +618,7 @@ export async function runServerlessCluster(log: ToolingLog, options: ServerlessO
portCmd[1].lastIndexOf(':')
)}`;

await waitUntilClusterReady({
const client = getESClient({
node: esNodeUrl,
...(options.ssl
? {
Expand All @@ -654,6 +636,7 @@ export async function runServerlessCluster(log: ToolingLog, options: ServerlessO
}
: {}),
});
await waitUntilClusterReady({ client, log });
log.success('ES is ready');
}

Expand Down
63 changes: 63 additions & 0 deletions packages/kbn-es/src/utils/wait_until_cluster_ready.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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.
*/

import { Client } from '@elastic/elasticsearch';
import { ToolingLog } from '@kbn/tooling-log';
const DEFAULT_READY_TIMEOUT = 60 * 1000; // 1 minute

export interface WaitOptions {
client: Client;
log: ToolingLog;
readyTimeout?: number;
}

/**
* General method to wait for the ES cluster status to be green
*/
export async function waitUntilClusterReady({
client,
log,
readyTimeout = DEFAULT_READY_TIMEOUT,
}: WaitOptions) {
let attempt = 0;
const start = Date.now();

log.info('waiting for ES cluster to report a green status');

while (true) {
attempt += 1;

try {
const resp = await client.cluster.health();
if (resp.status === 'green') {
return;
}

throw new Error(`not ready, cluster health is ${resp.status}`);
} catch (error) {
const timeSinceStart = Date.now() - start;
if (timeSinceStart > readyTimeout) {
const sec = readyTimeout / 1000;
throw new Error(`ES cluster failed to come online with the ${sec} second timeout`);
}

if (error?.message?.startsWith('not ready,')) {
if (timeSinceStart > 10_000) {
log.warning(error.message);
}
} else {
log.warning(
`waiting for ES cluster to come online, attempt ${attempt} failed with: ${error?.message}`
);
}

const waitSec = attempt * 1.5;
await new Promise((resolve) => setTimeout(resolve, waitSec * 1000));
}
}
}
32 changes: 15 additions & 17 deletions packages/kbn-search-api-panels/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import React from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiSpacer, EuiImage, EuiText } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { AuthenticatedUser } from '@kbn/security-plugin/common';

export * from './components/code_box';
export * from './components/github_link';
Expand All @@ -24,19 +25,14 @@ export * from './types';
export * from './utils';

export interface WelcomeBannerProps {
userProfile: {
user: {
full_name?: string;
username?: string;
};
};
user?: AuthenticatedUser;
assetBasePath?: string;
image?: string;
showDescription?: boolean;
}

export const WelcomeBanner: React.FC<WelcomeBannerProps> = ({
userProfile,
user,
assetBasePath,
image,
showDescription = true,
Expand All @@ -54,16 +50,18 @@ export const WelcomeBanner: React.FC<WelcomeBannerProps> = ({
</h1>
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiTitle size="xxxs">
<h2>
{i18n.translate('searchApiPanels.welcomeBanner.header.greeting.title', {
defaultMessage: 'Hi {name}!',
values: { name: userProfile?.user?.full_name || userProfile?.user?.username },
})}
</h2>
</EuiTitle>
</EuiFlexItem>
{Boolean(user) && (
<EuiFlexItem grow={false}>
<EuiTitle size="xxxs">
<h2>
{i18n.translate('searchApiPanels.welcomeBanner.header.greeting.title', {
defaultMessage: 'Hi {name}!',
values: { name: user?.full_name || user.username },
})}
</h2>
</EuiTitle>
</EuiFlexItem>
)}
</EuiFlexGroup>
<EuiSpacer />
{showDescription && (
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-search-api-panels/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@kbn/core-http-browser",
"@kbn/core-application-browser",
"@kbn/share-plugin",
"@kbn/i18n-react"
"@kbn/i18n-react",
"@kbn/security-plugin"
]
}
Loading

0 comments on commit 5810cac

Please sign in to comment.