Skip to content

Commit 6b8f782

Browse files
hammad-nasir-elastickibanamachineelasticmachine
authored
Link code for "Kibana server is not ready yet" to related doc (#241345)
Resolves [issue](#158518) ## Summary Adding the respective troubleshooting document link to our logs for the "Kibana server is not ready yet" error. This helps the support team by having a possible decrease in tickets where customers are able to do some troubleshooting before opening a ticket and better SDHs as the support team would work through the troubleshooting docs prior to opening the SDH. Related doc being referenced in the ticket: https://www.elastic.co/docs/troubleshoot/kibana/error-server-not-ready --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
1 parent 0a99fc4 commit 6b8f782

File tree

35 files changed

+154
-29
lines changed

35 files changed

+154
-29
lines changed

src/core/packages/doc-links/server/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
export type { DocLinksServiceStart, DocLinksServiceSetup } from './src/types';
10+
export type {
11+
DocLinksServiceStart,
12+
DocLinksServiceSetup,
13+
DocLinksServicePreboot,
14+
} from './src/types';

src/core/packages/doc-links/server/src/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ export interface DocLinksServiceSetup {
2121

2222
/** @public */
2323
export type DocLinksServiceStart = DocLinksServiceSetup;
24+
25+
/** @public */
26+
export type DocLinksServicePreboot = DocLinksServiceSetup;

src/core/packages/http/server-internal/src/http_service.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { getEnvOptions } from '@kbn/config-mocks';
1818
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
1919
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
2020
import { contextServiceMock } from '@kbn/core-http-context-server-mocks';
21+
import { docLinksServiceMock } from '@kbn/core-doc-links-server-mocks';
2122
import { Router } from '@kbn/core-http-router-server-internal';
2223
jest.mock('@kbn/core-http-router-server-internal');
2324
import { HttpService } from './http_service';
@@ -51,8 +52,11 @@ const createConfigService = (value: Partial<HttpConfigType> = {}) => {
5152
const contextPreboot = contextServiceMock.createPrebootContract();
5253
const contextSetup = contextServiceMock.createSetupContract();
5354

55+
const docLinksPreboot = docLinksServiceMock.createSetupContract();
56+
5457
const prebootDeps = {
5558
context: contextPreboot,
59+
docLinks: docLinksPreboot,
5660
};
5761
const setupDeps = {
5862
context: contextSetup,

src/core/packages/http/server-internal/src/http_service.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import type {
3333
InternalContextSetup,
3434
InternalContextPreboot,
3535
} from '@kbn/core-http-context-server-internal';
36+
import type { DocLinksServicePreboot } from '@kbn/core-doc-links-server';
3637
import type { RouterOptions } from '@kbn/core-http-router-server-internal';
3738
import { Router } from '@kbn/core-http-router-server-internal';
3839

@@ -56,6 +57,7 @@ import { externalUrlConfig, ExternalUrlConfig } from './external_url';
5657

5758
export interface PrebootDeps {
5859
context: InternalContextPreboot;
60+
docLinks: DocLinksServicePreboot;
5961
}
6062

6163
export interface SetupDeps {
@@ -105,6 +107,7 @@ export class HttpService
105107

106108
public async preboot(deps: PrebootDeps): Promise<InternalHttpServicePreboot> {
107109
this.log.debug('setting up preboot server');
110+
108111
const config = await firstValueFrom(this.config$);
109112

110113
const prebootSetup = await this.prebootServer.setup({
@@ -114,7 +117,9 @@ export class HttpService
114117
path: '/{p*}',
115118
method: '*',
116119
handler: (req, responseToolkit) => {
117-
this.log.debug(`Kibana server is not ready yet ${req.method}:${req.url.href}.`);
120+
this.log.debug(
121+
`Kibana server is not ready yet ${req.method}:${req.url.href}. For troubleshooting guidance, see ${deps.docLinks.links.server.troubleshootServerNotReady}`
122+
);
118123

119124
// If server is not ready yet, because plugins or core can perform
120125
// long running tasks (build assets, saved objects migrations etc.)

src/core/packages/http/server-internal/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
"@kbn/logging-mocks",
3636
"@kbn/router-to-openapispec",
3737
"@kbn/core-base-server-mocks",
38+
"@kbn/core-doc-links-server",
39+
"@kbn/core-doc-links-server-mocks",
3840
],
3941
"exclude": [
4042
"target/**/*",

src/core/packages/http/server-mocks/src/test_utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { Env } from '@kbn/config';
1515
import { getEnvOptions, configServiceMock } from '@kbn/config-mocks';
1616
import type { CoreContext } from '@kbn/core-base-server-internal';
1717
import { contextServiceMock } from '@kbn/core-http-context-server-mocks';
18+
import { docLinksServiceMock } from '@kbn/core-doc-links-server-mocks';
1819
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
1920
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
2021
import type { IRouter } from '@kbn/core-http-server';
@@ -169,6 +170,7 @@ export const createHttpService = (): HttpIntegrationTestService => {
169170
preboot: async () => {
170171
await svc.preboot({
171172
context: contextServiceMock.createPrebootContract(),
173+
docLinks: docLinksServiceMock.createSetupContract(),
172174
});
173175
},
174176
setup: () => {

src/core/packages/http/server-mocks/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@kbn/core-http-context-server-mocks",
2626
"@kbn/core-execution-context-server-mocks",
2727
"@kbn/lazy-object",
28+
"@kbn/core-doc-links-server-mocks",
2829
],
2930
"exclude": [
3031
"target/**/*",

src/core/packages/root/server-internal/src/server.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ test('preboot services on "preboot"', async () => {
8787
expect(mockContextService.preboot).not.toHaveBeenCalled();
8888
expect(mockHttpService.preboot).not.toHaveBeenCalled();
8989
expect(mockI18nService.preboot).not.toHaveBeenCalled();
90+
expect(mockDocLinksService.setup).not.toHaveBeenCalled();
9091
expect(mockElasticsearchService.preboot).not.toHaveBeenCalled();
9192
expect(mockUiSettingsService.preboot).not.toHaveBeenCalled();
9293
expect(mockRenderingService.preboot).not.toHaveBeenCalled();
@@ -102,6 +103,7 @@ test('preboot services on "preboot"', async () => {
102103
expect(mockContextService.preboot).toHaveBeenCalledTimes(1);
103104
expect(mockHttpService.preboot).toHaveBeenCalledTimes(1);
104105
expect(mockI18nService.preboot).toHaveBeenCalledTimes(1);
106+
expect(mockDocLinksService.setup).toHaveBeenCalledTimes(1);
105107
expect(mockElasticsearchService.preboot).toHaveBeenCalledTimes(1);
106108
expect(mockUiSettingsService.preboot).toHaveBeenCalledTimes(1);
107109
expect(mockRenderingService.preboot).toHaveBeenCalledTimes(1);
@@ -128,7 +130,6 @@ test('sets up services on "setup"', async () => {
128130
expect(mockLoggingService.setup).not.toHaveBeenCalled();
129131
expect(mockI18nService.setup).not.toHaveBeenCalled();
130132
expect(mockDeprecationService.setup).not.toHaveBeenCalled();
131-
expect(mockDocLinksService.setup).not.toHaveBeenCalled();
132133
expect(mockCustomBrandingService.setup).not.toHaveBeenCalled();
133134
expect(mockUserSettingsService.setup).not.toHaveBeenCalled();
134135
expect(mockSecurityService.setup).not.toHaveBeenCalled();
@@ -150,7 +151,7 @@ test('sets up services on "setup"', async () => {
150151
expect(mockLoggingService.setup).toHaveBeenCalledTimes(1);
151152
expect(mockI18nService.setup).toHaveBeenCalledTimes(1);
152153
expect(mockDeprecationService.setup).toHaveBeenCalledTimes(1);
153-
expect(mockDocLinksService.setup).toHaveBeenCalledTimes(1);
154+
expect(mockDocLinksService.setup).toHaveBeenCalledTimes(2);
154155
expect(mockCustomBrandingService.setup).toHaveBeenCalledTimes(1);
155156
expect(mockUserSettingsService.setup).toHaveBeenCalledTimes(1);
156157
expect(mockSecurityService.setup).toHaveBeenCalledTimes(1);

src/core/packages/root/server-internal/src/server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,12 @@ export class Server {
210210
const contextServicePreboot = this.context.preboot({
211211
pluginDependencies: new Map([...pluginTree.asOpaqueIds]),
212212
});
213+
const docLinksPreboot = this.docLinks.setup();
213214

214-
const httpPreboot = await this.http.preboot({ context: contextServicePreboot });
215+
const httpPreboot = await this.http.preboot({
216+
context: contextServicePreboot,
217+
docLinks: docLinksPreboot,
218+
});
215219

216220
// setup i18n prior to any other service, to have translations ready
217221
const i18nPreboot = await this.i18n.preboot({ http: httpPreboot, pluginPaths });

src/core/packages/test-helpers/test-utils/src/setup_server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { savedObjectsServiceMock } from '@kbn/core-saved-objects-server-mocks';
1818
import { elasticsearchServiceMock } from '@kbn/core-elasticsearch-server-mocks';
1919
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-server-mocks';
2020
import { deprecationsServiceMock } from '@kbn/core-deprecations-server-mocks';
21+
import { docLinksServiceMock } from '@kbn/core-doc-links-server-mocks';
2122

2223
const defaultCoreId = Symbol('core');
2324

@@ -45,7 +46,10 @@ export const setupServer = async (coreId: symbol = defaultCoreId) => {
4546
const coreContext = createCoreContext({ coreId });
4647
const contextService = new ContextService(coreContext);
4748
const server = new HttpService(coreContext);
48-
await server.preboot({ context: contextServiceMock.createPrebootContract() });
49+
await server.preboot({
50+
context: contextServiceMock.createPrebootContract(),
51+
docLinks: docLinksServiceMock.createSetupContract(),
52+
});
4953
const httpSetup = await server.setup({
5054
context: contextService.setup({ pluginDependencies: new Map() }),
5155
executionContext: executionContextServiceMock.createInternalSetupContract(),

0 commit comments

Comments
 (0)