Skip to content

Commit 1a73b5d

Browse files
[Search] serverless: add in_trial config value (elastic#232703)
## Summary Adding an explicit boolean `in_trial` config value for serverless projects to set. This will be used for the context of the feature flag service in lieu of the `trial_end_date` used for cloud hosted. ### Checklist - [ ] ~Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)~ - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent d5b2df7 commit 1a73b5d

10 files changed

Lines changed: 64 additions & 1 deletion

File tree

src/platform/test/plugin_functional/test_suites/core_plugins/rendering.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
259259
'xpack.cloud.serverless.project_type (observability?|security?|search?|chat?)',
260260
'xpack.cloud.serverless.product_tier (never|complete?|essentials?|search_ai_lake?|logs_essentials?)',
261261
'xpack.cloud.serverless.orchestrator_target (string?)',
262+
'xpack.cloud.serverless.in_trial (boolean?)',
262263
'xpack.cloud.onboarding.default_solution (string?)',
263264
'xpack.contentConnectors.ui.enabled (boolean?)',
264265
'xpack.discoverEnhanced.actions.exploreDataInChart.enabled (boolean?)',

x-pack/platform/plugins/private/cloud_integrations/cloud_experiments/common/metadata_service/initialize_metadata.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export function initializeMetadata({
4646
organizationKey: cloud.organizationId,
4747
trial_end_date: cloud.trialEndDate,
4848
is_elastic_staff: cloud.isElasticStaffOwned,
49+
in_trial: cloud.serverless?.organizationInTrial,
4950
});
5051

5152
// Update the client's contexts when we get any updates in the metadata.

x-pack/platform/plugins/private/cloud_integrations/cloud_experiments/common/metadata_service/metadata_service.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,20 @@ describe('MetadataService', () => {
104104
});
105105
})
106106
);
107+
108+
test('accepts inTrial from cloud serverless config', async () => {
109+
metadataService.setup({
110+
...initialMetadata,
111+
in_trial: true,
112+
});
113+
await expect(firstValueFrom(metadataService.userMetadata$)).resolves.toStrictEqual({
114+
...multiContextFormat,
115+
organization: {
116+
...multiContextFormat.organization,
117+
in_trial: true,
118+
},
119+
});
120+
});
107121
});
108122

109123
describe('start', () => {

x-pack/platform/plugins/shared/cloud/public/plugin.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export interface CloudConfigType {
4747
project_type?: KibanaSolution;
4848
product_tier?: KibanaProductTier;
4949
orchestrator_target?: string;
50+
in_trial?: boolean;
5051
};
5152
}
5253

@@ -124,6 +125,7 @@ export class CloudPlugin implements Plugin<CloudSetup> {
124125
// It is exposed for informational purposes (telemetry and feature flags). Do not use it for feature-gating.
125126
// Use `core.pricing` when checking if a feature is available for the current product tier.
126127
productTier: this.config.serverless?.product_tier,
128+
organizationInTrial: this.config.serverless?.in_trial,
127129
},
128130
registerCloudService: (contextProvider) => {
129131
this.contextProviders.push(contextProvider);
@@ -182,6 +184,7 @@ export class CloudPlugin implements Plugin<CloudSetup> {
182184
projectId: this.config.serverless?.project_id,
183185
projectName: this.config.serverless?.project_name,
184186
projectType: this.config.serverless?.project_type,
187+
organizationInTrial: this.config.serverless?.in_trial,
185188
},
186189
performanceUrl,
187190
usersAndRolesUrl,

x-pack/platform/plugins/shared/cloud/public/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ export interface CloudStart {
9090
* Will always be present if `isServerlessEnabled` is `true`
9191
*/
9292
projectType?: KibanaSolution;
93+
/**
94+
* Whether the serverless project belongs to an organization currently in trial.
95+
*/
96+
organizationInTrial?: boolean;
9397
};
9498
}
9599

@@ -231,6 +235,10 @@ export interface CloudSetup {
231235
* Will always be present if `isServerlessEnabled` is `true`
232236
*/
233237
orchestratorTarget?: string;
238+
/**
239+
* Whether the serverless project belongs to an organization currently in trial.
240+
*/
241+
organizationInTrial?: boolean;
234242
};
235243
}
236244

x-pack/platform/plugins/shared/cloud/server/__snapshots__/plugin.test.ts.snap

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/platform/plugins/shared/cloud/server/collectors/cloud_usage_collector.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,26 @@ describe('createCloudUsageCollector', () => {
6969
});
7070
});
7171

72+
it('return inTrial true if inTrial is provided', async () => {
73+
const collector = createCloudUsageCollector(usageCollection, {
74+
isCloudEnabled: true,
75+
organizationInTrial: true,
76+
} as CloudUsageCollectorConfig);
77+
78+
expect(await collector.fetch(collectorFetchContext)).toStrictEqual({
79+
isCloudEnabled: true,
80+
isElasticStaffOwned: undefined,
81+
organizationId: undefined,
82+
trialEndDate: undefined,
83+
inTrial: true,
84+
deploymentId: undefined,
85+
projectId: undefined,
86+
projectType: undefined,
87+
productTier: undefined,
88+
orchestratorTarget: undefined,
89+
});
90+
});
91+
7292
it('pass-through properties are copied as expected', async () => {
7393
const collector = createCloudUsageCollector(usageCollection, {
7494
isCloudEnabled: true,
@@ -80,6 +100,7 @@ describe('createCloudUsageCollector', () => {
80100
projectType: 'security',
81101
productTier: 'complete',
82102
orchestratorTarget: 'canary',
103+
organizationInTrial: undefined,
83104
});
84105

85106
expect(await collector.fetch(collectorFetchContext)).toStrictEqual({

x-pack/platform/plugins/shared/cloud/server/collectors/cloud_usage_collector.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface CloudUsageCollectorConfig {
1818
projectType: string | undefined;
1919
productTier: string | undefined;
2020
orchestratorTarget: string | undefined;
21+
organizationInTrial: boolean | undefined;
2122
}
2223

2324
interface CloudUsage {
@@ -47,6 +48,7 @@ export function createCloudUsageCollector(
4748
projectType,
4849
productTier,
4950
orchestratorTarget,
51+
organizationInTrial,
5052
} = config;
5153
const trialEndDateMs = trialEndDate ? new Date(trialEndDate).getTime() : undefined;
5254
return usageCollection.makeUsageCollector<CloudUsage>({
@@ -99,7 +101,11 @@ export function createCloudUsageCollector(
99101
isElasticStaffOwned,
100102
organizationId,
101103
trialEndDate,
102-
...(trialEndDateMs ? { inTrial: Date.now() <= trialEndDateMs } : {}),
104+
...(organizationInTrial
105+
? { inTrial: true }
106+
: trialEndDateMs
107+
? { inTrial: Date.now() <= trialEndDateMs }
108+
: {}),
103109
deploymentId,
104110
projectId,
105111
projectType,

x-pack/platform/plugins/shared/cloud/server/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const configSchema = schema.object({
101101
),
102102
product_tier: schema.maybe(createProductTiersSchema()),
103103
orchestrator_target: schema.maybe(schema.string()),
104+
in_trial: schema.maybe(schema.boolean()),
104105
},
105106
// avoid future chicken-and-egg situation with the component populating the config
106107
{ unknowns: 'ignore' }
@@ -133,6 +134,7 @@ export const config: PluginConfigDescriptor<CloudConfigType> = {
133134
project_type: true,
134135
product_tier: true,
135136
orchestrator_target: true,
137+
in_trial: true,
136138
},
137139
onboarding: {
138140
default_solution: true,

x-pack/platform/plugins/shared/cloud/server/plugin.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ export interface CloudSetup {
161161
* Will always be present if `isServerlessEnabled` is `true`
162162
*/
163163
orchestratorTarget?: string;
164+
/**
165+
* Whether the serverless project belongs to an organization currently in trial.
166+
*/
167+
organizationInTrial?: boolean;
164168
};
165169
}
166170

@@ -216,6 +220,7 @@ export class CloudPlugin implements Plugin<CloudSetup, CloudStart> {
216220
projectType,
217221
productTier,
218222
orchestratorTarget,
223+
organizationInTrial: this.config.serverless?.in_trial,
219224
});
220225
const basePath = core.http.basePath.serverBasePath;
221226
core.http.resources.register(
@@ -374,6 +379,7 @@ export class CloudPlugin implements Plugin<CloudSetup, CloudStart> {
374379
// It is exposed for informational purposes (telemetry and feature flags). Do not use it for feature-gating.
375380
// Use `core.pricing` when checking if a feature is available for the current product tier.
376381
productTier,
382+
organizationInTrial: this.config.serverless?.in_trial,
377383
},
378384
};
379385
}

0 commit comments

Comments
 (0)