From 61f587b252cf73838fdb3ccf0c2180e561edc071 Mon Sep 17 00:00:00 2001 From: Ying Date: Wed, 31 Jul 2024 15:13:24 -0400 Subject: [PATCH] Using buildFlavor to detect serverless --- x-pack/plugins/task_manager/kibana.jsonc | 1 - x-pack/plugins/task_manager/server/plugin.test.ts | 3 --- x-pack/plugins/task_manager/server/plugin.ts | 10 +++++----- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/task_manager/kibana.jsonc b/x-pack/plugins/task_manager/kibana.jsonc index 9d1a9e216bec7..33edc225e42c1 100644 --- a/x-pack/plugins/task_manager/kibana.jsonc +++ b/x-pack/plugins/task_manager/kibana.jsonc @@ -12,7 +12,6 @@ ], "optionalPlugins": [ "cloud", - "serverless", "usageCollection" ] } diff --git a/x-pack/plugins/task_manager/server/plugin.test.ts b/x-pack/plugins/task_manager/server/plugin.test.ts index a1589504bb364..353062dfec4fc 100644 --- a/x-pack/plugins/task_manager/server/plugin.test.ts +++ b/x-pack/plugins/task_manager/server/plugin.test.ts @@ -11,7 +11,6 @@ import { TaskManagerConfig } from './config'; import { Subject } from 'rxjs'; import { bufferCount, take } from 'rxjs'; import { CoreStatus, ServiceStatusLevels } from '@kbn/core/server'; -import { serverlessPluginMock } from '@kbn/serverless/server/mocks'; import { cloudMock } from '@kbn/cloud-plugin/public/mocks'; import { taskPollingLifecycleMock } from './polling_lifecycle.mock'; import { TaskPollingLifecycle } from './polling_lifecycle'; @@ -150,7 +149,6 @@ describe('TaskManagerPlugin', () => { const taskManagerPlugin = new TaskManagerPlugin(pluginInitializerContext); taskManagerPlugin.setup(coreMock.createSetup(), { usageCollection: undefined }); taskManagerPlugin.start(coreStart, { - serverless: serverlessPluginMock.createStartContract(), cloud: cloudMock.createStart(), }); @@ -168,7 +166,6 @@ describe('TaskManagerPlugin', () => { const taskManagerPlugin = new TaskManagerPlugin(pluginInitializerContext); taskManagerPlugin.setup(coreMock.createSetup(), { usageCollection: undefined }); taskManagerPlugin.start(coreStart, { - serverless: serverlessPluginMock.createStartContract(), cloud: cloudMock.createStart(), }); diff --git a/x-pack/plugins/task_manager/server/plugin.ts b/x-pack/plugins/task_manager/server/plugin.ts index a3a295169057d..23ef12605baa2 100644 --- a/x-pack/plugins/task_manager/server/plugin.ts +++ b/x-pack/plugins/task_manager/server/plugin.ts @@ -18,7 +18,6 @@ import { ServiceStatusLevels, CoreStatus, } from '@kbn/core/server'; -import { ServerlessPluginStart } from '@kbn/serverless/server'; import type { CloudStart } from '@kbn/cloud-plugin/server'; import { registerDeleteInactiveNodesTaskDefinition, @@ -81,7 +80,6 @@ export type TaskManagerStartContract = Pick< export interface TaskManagerPluginStart { cloud?: CloudStart; - serverless?: ServerlessPluginStart; } const LogHealthForBackgroundTasksOnlyMinutes = 60; @@ -250,7 +248,7 @@ export class TaskManagerPlugin public start( { savedObjects, elasticsearch, executionContext, docLinks }: CoreStart, - { cloud, serverless }: TaskManagerPluginStart + { cloud }: TaskManagerPluginStart ): TaskManagerStartContract { const savedObjectsRepository = savedObjects.createInternalRepository([ TASK_SO_NAME, @@ -281,18 +279,20 @@ export class TaskManagerPlugin requestTimeouts: this.config.request_timeouts, }); + const isServerless = this.initContext.env.packageInfo.buildFlavor === 'serverless'; + const defaultCapacity = getDefaultCapacity({ claimStrategy: this.config?.claim_strategy, heapSizeLimit: this.heapSizeLimit, isCloud: cloud?.isCloudEnabled ?? false, - isServerless: !!serverless, + isServerless, isBackgroundTaskNodeOnly: this.isNodeBackgroundTasksOnly(), }); this.logger.info( `Task manager isCloud=${ cloud?.isCloudEnabled ?? false - } isServerless=${!!serverless} claimStrategy=${ + } isServerless=${isServerless} claimStrategy=${ this.config!.claim_strategy } isBackgroundTaskNodeOnly=${this.isNodeBackgroundTasksOnly()} heapSizeLimit=${ this.heapSizeLimit