diff --git a/x-pack/plugins/fleet/common/types/index.ts b/x-pack/plugins/fleet/common/types/index.ts index 03584a48ff17c..7117973baa139 100644 --- a/x-pack/plugins/fleet/common/types/index.ts +++ b/x-pack/plugins/fleet/common/types/index.ts @@ -15,13 +15,6 @@ export interface FleetConfigType { registryProxyUrl?: string; agents: { enabled: boolean; - tlsCheckDisabled: boolean; - pollingRequestTimeout: number; - maxConcurrentConnections: number; - kibana: { - host?: string[] | string; - ca_sha256?: string; - }; elasticsearch: { host?: string; ca_sha256?: string; @@ -29,8 +22,6 @@ export interface FleetConfigType { fleet_server?: { hosts?: string[]; }; - agentPolicyRolloutRateLimitIntervalMs: number; - agentPolicyRolloutRateLimitRequestPerInterval: number; }; agentPolicies?: PreconfiguredAgentPolicy[]; packages?: PreconfiguredPackage[]; diff --git a/x-pack/plugins/fleet/public/applications/fleet/mock/plugin_configuration.ts b/x-pack/plugins/fleet/public/applications/fleet/mock/plugin_configuration.ts index 5d53425607361..7f0b71de779dc 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/mock/plugin_configuration.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/mock/plugin_configuration.ts @@ -14,19 +14,10 @@ export const createConfigurationMock = (): FleetConfigType => { registryProxyUrl: '', agents: { enabled: true, - tlsCheckDisabled: true, - pollingRequestTimeout: 1000, - maxConcurrentConnections: 100, - kibana: { - host: '', - ca_sha256: '', - }, elasticsearch: { host: '', ca_sha256: '', }, - agentPolicyRolloutRateLimitIntervalMs: 100, - agentPolicyRolloutRateLimitRequestPerInterval: 1000, }, }; }; diff --git a/x-pack/plugins/fleet/server/mocks/index.ts b/x-pack/plugins/fleet/server/mocks/index.ts index 4bc2bea1e58b6..a94f274b202ad 100644 --- a/x-pack/plugins/fleet/server/mocks/index.ts +++ b/x-pack/plugins/fleet/server/mocks/index.ts @@ -30,6 +30,10 @@ export const createAppContextStartContractMock = (): FleetAppContext => { security: securityMock.createStart(), logger: loggingSystemMock.create().get(), isProductionMode: true, + configInitialValue: { + agents: { enabled: true, elasticsearch: {} }, + enabled: true, + }, kibanaVersion: '8.0.0', kibanaBranch: 'master', }; diff --git a/x-pack/plugins/fleet/server/plugin.ts b/x-pack/plugins/fleet/server/plugin.ts index 61c3a83242c57..0fdc6ef651ed1 100644 --- a/x-pack/plugins/fleet/server/plugin.ts +++ b/x-pack/plugins/fleet/server/plugin.ts @@ -6,7 +6,6 @@ */ import type { Observable } from 'rxjs'; -import { first } from 'rxjs/operators'; import type { CoreSetup, CoreStart, @@ -110,6 +109,7 @@ export interface FleetAppContext { encryptedSavedObjectsSetup?: EncryptedSavedObjectsPluginSetup; security?: SecurityPluginStart; config$?: Observable; + configInitialValue: FleetConfigType; savedObjects: SavedObjectsServiceStart; isProductionMode: PluginInitializerContext['env']['mode']['prod']; kibanaVersion: PluginInitializerContext['env']['packageInfo']['version']; @@ -189,6 +189,7 @@ export class FleetPlugin implements AsyncPlugin { private licensing$!: Observable; private config$: Observable; + private configInitialValue: FleetConfigType; private cloud: CloudSetup | undefined; private logger: Logger | undefined; @@ -204,15 +205,15 @@ export class FleetPlugin this.kibanaVersion = this.initializerContext.env.packageInfo.version; this.kibanaBranch = this.initializerContext.env.packageInfo.branch; this.logger = this.initializerContext.logger.get(); + this.configInitialValue = this.initializerContext.config.get(); } - public async setup(core: CoreSetup, deps: FleetSetupDeps) { + public setup(core: CoreSetup, deps: FleetSetupDeps) { this.httpSetup = core.http; this.licensing$ = deps.licensing.license$; this.encryptedSavedObjectsSetup = deps.encryptedSavedObjects; this.cloud = deps.cloud; - - const config = await this.config$.pipe(first()).toPromise(); + const config = this.configInitialValue; registerSavedObjects(core.savedObjects, deps.encryptedSavedObjects); registerEncryptedSavedObjects(deps.encryptedSavedObjects); @@ -279,13 +280,14 @@ export class FleetPlugin } } - public async start(core: CoreStart, plugins: FleetStartDeps): Promise { - await appContextService.start({ + public start(core: CoreStart, plugins: FleetStartDeps): FleetStartContract { + appContextService.start({ elasticsearch: core.elasticsearch, data: plugins.data, encryptedSavedObjectsStart: plugins.encryptedSavedObjects, encryptedSavedObjectsSetup: this.encryptedSavedObjectsSetup, security: plugins.security, + configInitialValue: this.configInitialValue, config$: this.config$, savedObjects: core.savedObjects, isProductionMode: this.isProductionMode, diff --git a/x-pack/plugins/fleet/server/services/app_context.ts b/x-pack/plugins/fleet/server/services/app_context.ts index 954308a980861..82ec0aad52651 100644 --- a/x-pack/plugins/fleet/server/services/app_context.ts +++ b/x-pack/plugins/fleet/server/services/app_context.ts @@ -7,7 +7,6 @@ import type { Observable } from 'rxjs'; import { BehaviorSubject } from 'rxjs'; -import { first } from 'rxjs/operators'; import { kibanaPackageJson } from '@kbn/utils'; import type { KibanaRequest } from 'src/core/server'; import type { @@ -44,7 +43,7 @@ class AppContextService { private httpSetup?: HttpServiceSetup; private externalCallbacks: ExternalCallbacksStorage = new Map(); - public async start(appContext: FleetAppContext) { + public start(appContext: FleetAppContext) { this.data = appContext.data; this.esClient = appContext.elasticsearch.client.asInternalUser; this.encryptedSavedObjects = appContext.encryptedSavedObjectsStart?.getClient(); @@ -60,7 +59,7 @@ class AppContextService { if (appContext.config$) { this.config$ = appContext.config$; - const initialValue = await this.config$.pipe(first()).toPromise(); + const initialValue = appContext.configInitialValue; this.configSubject$ = new BehaviorSubject(initialValue); this.config$.subscribe(this.configSubject$); }