From 42e64a1de4eebd14a67f1a9fbe4bcb5b1563b1e9 Mon Sep 17 00:00:00 2001 From: Yulong Date: Tue, 22 Jan 2019 10:36:59 +0800 Subject: [PATCH] [Code] change back to `codeNode` (#29073) --- x-pack/plugins/code/index.ts | 3 ++- x-pack/plugins/code/server/init.ts | 5 +++-- x-pack/plugins/code/server/server_options.ts | 2 ++ x-pack/test/functional/config.js | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/code/index.ts b/x-pack/plugins/code/index.ts index 199aaa19103be..97c19bb773072 100644 --- a/x-pack/plugins/code/index.ts +++ b/x-pack/plugins/code/index.ts @@ -28,7 +28,7 @@ export const code = (kibana: any) => }, config(Joi: any) { return Joi.object({ - enabled: Joi.boolean().default(false), + enabled: Joi.boolean().default(true), queueIndex: Joi.string().default('.code-worker-queue'), // 1 hour by default. queueTimeout: Joi.number().default(moment.duration(1, 'hour').asMilliseconds()), @@ -47,6 +47,7 @@ export const code = (kibana: any) => isAdmin: Joi.boolean().default(true), // If we show the admin buttons disableScheduler: Joi.boolean().default(true), // Temp option to disable all schedulers. enableGlobalReference: Joi.boolean().default(false), // Global reference as optional feature for now + codeNode: Joi.boolean().default(false), }).default(); }, init, diff --git a/x-pack/plugins/code/server/init.ts b/x-pack/plugins/code/server/init.ts index e99051041f499..6f32691bc8838 100644 --- a/x-pack/plugins/code/server/init.ts +++ b/x-pack/plugins/code/server/init.ts @@ -40,7 +40,7 @@ async function retryUntilAvailable( if (value) { return value; } else { - return new Promise(resolve => { + const promise = new Promise(resolve => { const retry = () => { func().then(v => { if (v) { @@ -57,6 +57,7 @@ async function retryUntilAvailable( }; setTimeout(retry, intervalMs); }); + return await promise; } } @@ -77,7 +78,7 @@ export function init(server: Server, options: any) { enableSecurity(server); // enable cluster status routes clusterRoute(server, codeNodeClient, log); - if (serverOptions.enabled) { + if (serverOptions.codeNode) { let info = await codeNodeClient.getCodeNodeInfo(); if (!info) { let url: string = server.info.uri; diff --git a/x-pack/plugins/code/server/server_options.ts b/x-pack/plugins/code/server/server_options.ts index 47fcbd0833d52..85613c93b9d39 100644 --- a/x-pack/plugins/code/server/server_options.ts +++ b/x-pack/plugins/code/server/server_options.ts @@ -44,5 +44,7 @@ export class ServerOptions { public readonly enabled: boolean = this.options.enabled; + public readonly codeNode: boolean = this.options.codeNode; + constructor(private options: any, private config: any) {} } diff --git a/x-pack/test/functional/config.js b/x-pack/test/functional/config.js index 1f1ef661ed286..006779e133514 100644 --- a/x-pack/test/functional/config.js +++ b/x-pack/test/functional/config.js @@ -158,7 +158,7 @@ export default async function ({ readConfigFile }) { '--server.uuid=5b2de169-2785-441b-ae8c-186a1936b17d', '--xpack.xpack_main.telemetry.enabled=false', '--xpack.security.encryptionKey="wuGNaIhoMpk5sO4UBxgr3NyW1sFcLgIf"', // server restarts should not invalidate active sessions - '--xpack.code.enabled="true"', + '--xpack.code.codeNode="true"', ], }, uiSettings: {