Skip to content

Commit

Permalink
Respond with 503 if Kibana is not ready yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
azasypkin committed Aug 2, 2018
1 parent b97a145 commit 33b9731
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/core/server/legacy_compat/legacy_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,18 @@ export class LegacyService implements CoreService {
path: '/{p*}',
method: '*',
options: { payload: { output: 'stream', parse: false, timeout: false } },
handler: ({ raw: { req, res } }, responseToolkit) => {
handler: async ({ raw: { req, res } }, responseToolkit) => {
if (this.kbnServer === undefined) {
this.log.debug(`Kibana server is not ready yet ${req.method}:${req.url}.`);

// If legacy server is not ready yet (e.g. it's still in optimization phase),
// we should let client know that and ask to retry after 30 seconds.
return responseToolkit
.response('Kibana server is not ready yet')
.code(503)
.header('Retry-After', '30');
}

this.log.debug(`Request will be handled by proxy ${req.method}:${req.url}.`);

// Forward request and response objects to the legacy platform. This method
Expand Down

0 comments on commit 33b9731

Please sign in to comment.