mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[root] add more logs for bootstrap and shutdown (#161629)
## Summary
Looking at the logs, I realized we were not logging anything in `info`
level when Kibana is starting up or shutting down at the `Root` level,
making it quite awkward when trying to understand when an instance / pod
was started or shut down and even why. Also, we were not logging the
stack trace of the shutdown reason when present.
FWIW, this is (the exhaustive list of) what's displayed in some shutdown
scenarios (most recent to least recent):
<img width="1579" alt="Screenshot 2023-07-11 at 11 41 27"
src="a1a069d1
-84ba-4124-aea4-298a70adac58">
As you can see:
1. We have no idea why Kibana was shut down
2. We don't know where this `no element in sequence` error even comes
from
This PR adds a few logs:
- `Kibana is starting` during `bootstrap`
- `Kibana is shutting down` during `shutdown`
- The shutdown reason's stack when provided
- `SIGINT received - initiating shutdown` and `SIGTERM received -
initiating shutdown` when receiving the associated signals
This commit is contained in:
parent
9a7cc5a1d1
commit
ea1e6ed240
3 changed files with 23 additions and 6 deletions
|
@ -49,6 +49,9 @@ export async function bootstrap({ configs, cliArgs, applyConfigOverrides }: Boot
|
|||
|
||||
const root = new Root(rawConfigService, env, onRootShutdown);
|
||||
const cliLogger = root.logger.get('cli');
|
||||
const rootLogger = root.logger.get('root');
|
||||
|
||||
rootLogger.info('Kibana is starting');
|
||||
|
||||
cliLogger.debug('Kibana configurations evaluated in this order: ' + env.configs.join(', '));
|
||||
|
||||
|
@ -77,8 +80,14 @@ export async function bootstrap({ configs, cliArgs, applyConfigOverrides }: Boot
|
|||
cliLogger.info(`Reloaded Kibana configuration (reason: ${reason}).`, { tags: ['config'] });
|
||||
}
|
||||
|
||||
process.on('SIGINT', () => shutdown());
|
||||
process.on('SIGTERM', () => shutdown());
|
||||
process.on('SIGINT', () => {
|
||||
rootLogger.info('SIGINT received - initiating shutdown');
|
||||
shutdown();
|
||||
});
|
||||
process.on('SIGTERM', () => {
|
||||
rootLogger.info('SIGTERM received - initiating shutdown');
|
||||
shutdown();
|
||||
});
|
||||
|
||||
function shutdown(reason?: Error) {
|
||||
rawConfigService.stop();
|
||||
|
@ -96,7 +105,7 @@ export async function bootstrap({ configs, cliArgs, applyConfigOverrides }: Boot
|
|||
}
|
||||
|
||||
if (isSetupOnHold) {
|
||||
root.logger.get().info('Holding setup until preboot stage is completed.');
|
||||
rootLogger.info('Holding setup until preboot stage is completed.');
|
||||
const { shouldReloadConfig } = await preboot.waitUntilCanSetup();
|
||||
if (shouldReloadConfig) {
|
||||
await reloadConfiguration('configuration might have changed during preboot stage');
|
||||
|
|
|
@ -81,7 +81,7 @@ export class Root {
|
|||
}
|
||||
|
||||
public async shutdown(reason?: any) {
|
||||
this.log.debug('shutting root down');
|
||||
this.log.info('Kibana is shutting down');
|
||||
|
||||
if (reason) {
|
||||
if (reason.code === 'EADDRINUSE' && Number.isInteger(reason.port)) {
|
||||
|
@ -91,7 +91,7 @@ export class Root {
|
|||
}
|
||||
|
||||
if (reason.code !== MIGRATION_EXCEPTION_CODE) {
|
||||
this.log.fatal(reason);
|
||||
this.log.fatal(formatShutdownReason(reason));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,3 +159,11 @@ export class Root {
|
|||
this.loggingConfigSubscription.add(connectSubscription);
|
||||
}
|
||||
}
|
||||
|
||||
const formatShutdownReason = (reason: any): string => {
|
||||
let message = `Reason: ${reason.message ?? reason}`;
|
||||
if (reason.stack) {
|
||||
message = `${message}\n${reason.stack}`;
|
||||
}
|
||||
return message;
|
||||
};
|
||||
|
|
|
@ -82,7 +82,7 @@ describe('migration v2', () => {
|
|||
expect(
|
||||
records.find((rec) =>
|
||||
rec.message.startsWith(
|
||||
`Unable to complete saved object migrations for the [.kibana] index: While indexing a batch of saved objects, Elasticsearch returned a 413 Request Entity Too Large exception. Ensure that the Kibana configuration option 'migrations.maxBatchSizeBytes' is set to a value that is lower than or equal to the Elasticsearch 'http.max_content_length' configuration option.`
|
||||
`Reason: Unable to complete saved object migrations for the [.kibana] index: While indexing a batch of saved objects, Elasticsearch returned a 413 Request Entity Too Large exception. Ensure that the Kibana configuration option 'migrations.maxBatchSizeBytes' is set to a value that is lower than or equal to the Elasticsearch 'http.max_content_length' configuration option.`
|
||||
)
|
||||
)
|
||||
).toBeDefined();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue