Skip to content

Commit 42fbd47

Browse files
Merge branch 'master' into refactor_connectors
2 parents 269d164 + 9112b6c commit 42fbd47

File tree

58 files changed

+640
-143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+640
-143
lines changed

src/core/server/http/http_server.test.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,14 @@ describe('setup contract', () => {
10681068
await create();
10691069
expect(create()).rejects.toThrowError('A cookieSessionStorageFactory was already created');
10701070
});
1071+
1072+
it('does not throw if called after stop', async () => {
1073+
const { createCookieSessionStorageFactory } = await server.setup(config);
1074+
await server.stop();
1075+
expect(() => {
1076+
createCookieSessionStorageFactory(cookieOptions);
1077+
}).not.toThrow();
1078+
});
10711079
});
10721080

10731081
describe('#isTlsEnabled', () => {
@@ -1113,4 +1121,54 @@ describe('setup contract', () => {
11131121
expect(getServerInfo().protocol).toEqual('https');
11141122
});
11151123
});
1124+
1125+
describe('#registerStaticDir', () => {
1126+
it('does not throw if called after stop', async () => {
1127+
const { registerStaticDir } = await server.setup(config);
1128+
await server.stop();
1129+
expect(() => {
1130+
registerStaticDir('/path1/{path*}', '/path/to/resource');
1131+
}).not.toThrow();
1132+
});
1133+
});
1134+
1135+
describe('#registerOnPreAuth', () => {
1136+
test('does not throw if called after stop', async () => {
1137+
const { registerOnPreAuth } = await server.setup(config);
1138+
await server.stop();
1139+
expect(() => {
1140+
registerOnPreAuth((req, res) => res.unauthorized());
1141+
}).not.toThrow();
1142+
});
1143+
});
1144+
1145+
describe('#registerOnPostAuth', () => {
1146+
test('does not throw if called after stop', async () => {
1147+
const { registerOnPostAuth } = await server.setup(config);
1148+
await server.stop();
1149+
expect(() => {
1150+
registerOnPostAuth((req, res) => res.unauthorized());
1151+
}).not.toThrow();
1152+
});
1153+
});
1154+
1155+
describe('#registerOnPreResponse', () => {
1156+
test('does not throw if called after stop', async () => {
1157+
const { registerOnPreResponse } = await server.setup(config);
1158+
await server.stop();
1159+
expect(() => {
1160+
registerOnPreResponse((req, res, t) => t.next());
1161+
}).not.toThrow();
1162+
});
1163+
});
1164+
1165+
describe('#registerAuth', () => {
1166+
test('does not throw if called after stop', async () => {
1167+
const { registerAuth } = await server.setup(config);
1168+
await server.stop();
1169+
expect(() => {
1170+
registerAuth((req, res) => res.unauthorized());
1171+
}).not.toThrow();
1172+
});
1173+
});
11161174
});

src/core/server/http/http_server.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export class HttpServer {
7474
private registeredRouters = new Set<IRouter>();
7575
private authRegistered = false;
7676
private cookieSessionStorageCreated = false;
77+
private stopped = false;
7778

7879
private readonly log: Logger;
7980
private readonly authState: AuthStateStorage;
@@ -144,6 +145,10 @@ export class HttpServer {
144145
if (this.server === undefined) {
145146
throw new Error('Http server is not setup up yet');
146147
}
148+
if (this.stopped) {
149+
this.log.warn(`start called after stop`);
150+
return;
151+
}
147152
this.log.debug('starting http server');
148153

149154
for (const router of this.registeredRouters) {
@@ -189,13 +194,13 @@ export class HttpServer {
189194
}
190195

191196
public async stop() {
197+
this.stopped = true;
192198
if (this.server === undefined) {
193199
return;
194200
}
195201

196202
this.log.debug('stopping http server');
197203
await this.server.stop();
198-
this.server = undefined;
199204
}
200205

201206
private getAuthOption(
@@ -234,6 +239,9 @@ export class HttpServer {
234239
if (this.server === undefined) {
235240
throw new Error('Server is not created yet');
236241
}
242+
if (this.stopped) {
243+
this.log.warn(`setupConditionalCompression called after stop`);
244+
}
237245

238246
const { enabled, referrerWhitelist: list } = config.compression;
239247
if (!enabled) {
@@ -261,6 +269,9 @@ export class HttpServer {
261269
if (this.server === undefined) {
262270
throw new Error('Server is not created yet');
263271
}
272+
if (this.stopped) {
273+
this.log.warn(`registerOnPostAuth called after stop`);
274+
}
264275

265276
this.server.ext('onPostAuth', adoptToHapiOnPostAuthFormat(fn, this.log));
266277
}
@@ -269,6 +280,9 @@ export class HttpServer {
269280
if (this.server === undefined) {
270281
throw new Error('Server is not created yet');
271282
}
283+
if (this.stopped) {
284+
this.log.warn(`registerOnPreAuth called after stop`);
285+
}
272286

273287
this.server.ext('onRequest', adoptToHapiOnPreAuthFormat(fn, this.log));
274288
}
@@ -277,6 +291,9 @@ export class HttpServer {
277291
if (this.server === undefined) {
278292
throw new Error('Server is not created yet');
279293
}
294+
if (this.stopped) {
295+
this.log.warn(`registerOnPreResponse called after stop`);
296+
}
280297

281298
this.server.ext('onPreResponse', adoptToHapiOnPreResponseFormat(fn, this.log));
282299
}
@@ -288,6 +305,9 @@ export class HttpServer {
288305
if (this.server === undefined) {
289306
throw new Error('Server is not created yet');
290307
}
308+
if (this.stopped) {
309+
this.log.warn(`createCookieSessionStorageFactory called after stop`);
310+
}
291311
if (this.cookieSessionStorageCreated) {
292312
throw new Error('A cookieSessionStorageFactory was already created');
293313
}
@@ -305,6 +325,9 @@ export class HttpServer {
305325
if (this.server === undefined) {
306326
throw new Error('Server is not created yet');
307327
}
328+
if (this.stopped) {
329+
this.log.warn(`registerAuth called after stop`);
330+
}
308331
if (this.authRegistered) {
309332
throw new Error('Auth interceptor was already registered');
310333
}
@@ -348,6 +371,9 @@ export class HttpServer {
348371
if (this.server === undefined) {
349372
throw new Error('Http server is not setup up yet');
350373
}
374+
if (this.stopped) {
375+
this.log.warn(`registerStaticDir called after stop`);
376+
}
351377

352378
this.server.route({
353379
path,

x-pack/plugins/endpoint/public/applications/endpoint/store/hosts/middleware.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export const hostMiddlewareFactory: ImmutableMiddlewareFactory<HostState> = core
7070
type: 'serverReturnedHostDetails',
7171
payload: response,
7272
});
73-
// FIXME: once we have the API implementation in place, we should call it parallel with the above api call and then dispatch this with the results of the second call
7473
dispatch({
7574
type: 'serverReturnedHostPolicyResponse',
7675
payload: {

x-pack/plugins/endpoint/server/routes/alerts/list/lib/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ export const getRequestData = async (
6060
reqData.fromIndex = reqData.pageIndex * reqData.pageSize;
6161
}
6262

63-
// See: https://github.com/elastic/elasticsearch-js/issues/662
64-
// and https://github.com/elastic/endpoint-app-team/issues/221
6563
if (
6664
reqData.searchBefore !== undefined &&
6765
reqData.searchBefore[0] === '' &&

x-pack/plugins/endpoint/server/routes/metadata/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ async function enrichHostMetadata(
171171
try {
172172
/**
173173
* Get agent status by elastic agent id if available or use the host id.
174-
* https://github.com/elastic/endpoint-app-team/issues/354
175174
*/
176175

177176
if (!elasticAgentId) {

x-pack/plugins/event_log/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,21 +274,28 @@ PUT _ilm/policy/event_log_policy
274274
"hot": {
275275
"actions": {
276276
"rollover": {
277-
"max_size": "5GB",
277+
"max_size": "50GB",
278278
"max_age": "30d"
279279
}
280280
}
281+
},
282+
"delete": {
283+
"min_age": "90d",
284+
"actions": {
285+
"delete": {}
286+
}
281287
}
282288
}
283289
}
284290
}
285291
```
286292

287293
This means that ILM would "rollover" the current index, say
288-
`.kibana-event-log-000001` by creating a new index `.kibana-event-log-000002`,
294+
`.kibana-event-log-8.0.0-000001` by creating a new index `.kibana-event-log-8.0.0-000002`,
289295
which would "inherit" everything from the index template, and then ILM will
290296
set the write index of the the alias to the new index. This would happen
291-
when the original index grew past 5 GB, or was created more than 30 days ago.
297+
when the original index grew past 50 GB, or was created more than 30 days ago.
298+
After rollover, the indices will be removed after 90 days to avoid disks to fill up.
292299

293300
For more relevant information on ILM, see:
294301
[getting started with ILM doc][] and [write index alias behavior][]:

x-pack/plugins/event_log/server/es/documents.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,18 @@ export function getIlmPolicy() {
3131
hot: {
3232
actions: {
3333
rollover: {
34-
max_size: '5GB',
34+
max_size: '50GB',
3535
max_age: '30d',
3636
// max_docs: 1, // you know, for testing
3737
},
3838
},
3939
},
40+
delete: {
41+
min_age: '90d',
42+
actions: {
43+
delete: {},
44+
},
45+
},
4046
},
4147
},
4248
};

x-pack/plugins/infra/public/components/alerting/metrics/expression.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import {
1313
EuiText,
1414
EuiFormRow,
1515
EuiButtonEmpty,
16+
EuiCheckbox,
17+
EuiToolTip,
18+
EuiIcon,
1619
EuiFieldSearch,
1720
} from '@elastic/eui';
1821
import { IFieldType } from 'src/plugins/data/public';
@@ -57,6 +60,7 @@ interface Props {
5760
groupBy?: string;
5861
filterQuery?: string;
5962
sourceId?: string;
63+
alertOnNoData?: boolean;
6064
};
6165
alertsContext: AlertsContextValue<AlertContextMeta>;
6266
setAlertParams(key: string, value: any): void;
@@ -282,6 +286,28 @@ export const Expressions: React.FC<Props> = props => {
282286
</EuiButtonEmpty>
283287
</div>
284288

289+
<EuiSpacer size={'m'} />
290+
<EuiCheckbox
291+
id="metrics-alert-no-data-toggle"
292+
label={
293+
<>
294+
{i18n.translate('xpack.infra.metrics.alertFlyout.alertOnNoData', {
295+
defaultMessage: "Alert me if there's no data",
296+
})}{' '}
297+
<EuiToolTip
298+
content={i18n.translate('xpack.infra.metrics.alertFlyout.noDataHelpText', {
299+
defaultMessage:
300+
'Enable this to trigger the action if the metric(s) do not report any data over the expected time period, or if the alert fails to query Elasticsearch',
301+
})}
302+
>
303+
<EuiIcon type="questionInCircle" color="subdued" />
304+
</EuiToolTip>
305+
</>
306+
}
307+
checked={alertParams.alertOnNoData}
308+
onChange={e => setAlertParams('alertOnNoData', e.target.checked)}
309+
/>
310+
285311
<EuiSpacer size={'m'} />
286312

287313
<EuiFormRow

x-pack/plugins/infra/public/components/alerting/metrics/metric_threshold_alert_type.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ export function getAlertType(): AlertTypeModel {
2323
defaultActionMessage: i18n.translate(
2424
'xpack.infra.metrics.alerting.threshold.defaultActionMessage',
2525
{
26-
defaultMessage: `\\{\\{alertName\\}\\} - \\{\\{context.group\\}\\}
26+
defaultMessage: `\\{\\{alertName\\}\\} - \\{\\{context.group\\}\\} is in a state of \\{\\{context.alertState\\}\\}
2727
28-
\\{\\{context.metricOf.condition0\\}\\} has crossed a threshold of \\{\\{context.thresholdOf.condition0\\}\\}
29-
Current value is \\{\\{context.valueOf.condition0\\}\\}
28+
Reason:
29+
\\{\\{context.reason\\}\\}
3030
`,
3131
}
3232
),

0 commit comments

Comments
 (0)