Skip to content

Commit

Permalink
Using buildFlavor to detect serverless
Browse files Browse the repository at this point in the history
  • Loading branch information
ymao1 committed Jul 31, 2024
1 parent 42a347a commit 61f587b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
1 change: 0 additions & 1 deletion x-pack/plugins/task_manager/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
],
"optionalPlugins": [
"cloud",
"serverless",
"usageCollection"
]
}
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/task_manager/server/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(),
});

Expand All @@ -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(),
});

Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/task_manager/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -81,7 +80,6 @@ export type TaskManagerStartContract = Pick<

export interface TaskManagerPluginStart {
cloud?: CloudStart;
serverless?: ServerlessPluginStart;
}

const LogHealthForBackgroundTasksOnlyMinutes = 60;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 61f587b

Please sign in to comment.