Skip to content

Commit 2e7a5b6

Browse files
[SLO] Migrate composite SLO to Kibana feature flags (elastic#271130)
## Summary - Replace `xpack.slo.experimental.compositeSlo.enabled` with `slo.compositeSloEnabled` (Kibana Feature Flags). - Keep composite SO/routes/resources unconditional; gate API handlers, UI, and summary task at runtime. - Update Scout configs and unit tests for FF gating. Requires companion PR in `kibana-feature-flags` for `slo.compositeSloEnabled`. Closes elastic#270358 ## Test plan - [ ] `node scripts/jest x-pack/solutions/observability/plugins/slo` - [ ] Scout (stateful): `node scripts/scout run-tests --arch stateful --domain classic --serverConfigSet composite_slo --config x-pack/solutions/observability/plugins/slo/test/scout_composite_slo/api/playwright.config.ts` - [ ] Scout (serverless): same with `--arch serverless --domain observability_complete` Made with [Cursor](https://cursor.com) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
1 parent fa61b2b commit 2e7a5b6

39 files changed

Lines changed: 485 additions & 179 deletions

src/platform/packages/shared/kbn-scout/src/servers/configs/config_sets/composite_slo/serverless/observability_complete.serverless.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const servers: ScoutServerConfig = {
1616
...obltServerlessConfig.kbnTestServer,
1717
serverArgs: [
1818
...obltServerlessConfig.kbnTestServer.serverArgs,
19-
'--xpack.slo.experimental.compositeSlo.enabled=true',
19+
'--feature_flags.overrides.slo.compositeSloEnabled=true',
2020
],
2121
},
2222
};

src/platform/packages/shared/kbn-scout/src/servers/configs/config_sets/composite_slo/stateful/classic.stateful.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const servers: ScoutServerConfig = {
1616
...defaultConfig.kbnTestServer,
1717
serverArgs: [
1818
...defaultConfig.kbnTestServer.serverArgs,
19-
'--xpack.slo.experimental.compositeSlo.enabled=true',
19+
'--feature_flags.overrides.slo.compositeSloEnabled=true',
2020
],
2121
},
2222
};

x-pack/solutions/observability/plugins/slo/common/config.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@ export const configSchema = schema.object({
1313
tempSummaryCleanupTaskEnabled: schema.boolean({ defaultValue: true }),
1414
healthScanTaskEnabled: schema.boolean({ defaultValue: true }),
1515
staleInstancesCleanupTaskEnabled: schema.boolean({ defaultValue: false }),
16-
compositeSloSummaryTaskEnabled: schema.boolean({ defaultValue: false }),
16+
compositeSloSummaryTaskEnabled: schema.boolean({ defaultValue: true }),
1717
enabled: schema.boolean({ defaultValue: true }),
1818
experimental: schema.maybe(
1919
schema.object({
2020
ruleFormV2: schema.object({
2121
enabled: schema.boolean({ defaultValue: false }),
2222
}),
23-
compositeSlo: schema.object({
24-
enabled: schema.boolean({ defaultValue: false }),
25-
}),
2623
})
2724
),
2825
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
export const SLO_COMPOSITE_ENABLED = 'slo.compositeSloEnabled';

x-pack/solutions/observability/plugins/slo/moon.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ dependsOn:
136136
- '@kbn/agent-builder-browser'
137137
- '@kbn/core-analytics-browser'
138138
- '@kbn/inspector-plugin'
139+
- '@kbn/core-feature-flags-server'
139140
tags:
140141
- plugin
141142
- prod

x-pack/solutions/observability/plugins/slo/public/application.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import ReactDOM from 'react-dom';
2424
import type { ExperimentalFeatures } from '../common/config';
2525
import { PluginContext } from './context/plugin_context';
2626
import { InspectedSloClientProvider } from './components/inspect/inspected_slo_client_provider';
27-
import { usePluginContext } from './hooks/use_plugin_context';
27+
import { useCompositeSloEnabled } from './hooks/use_composite_slo_enabled';
2828
import { getRoutes } from './routes/routes';
2929
import type { SLOPublicPluginsStart, SLORepositoryClient } from './types';
3030
import type { ISloTelemetryClient } from './services/telemetry';
@@ -151,8 +151,8 @@ export const renderApp = ({
151151
};
152152

153153
function App() {
154-
const { experimentalFeatures } = usePluginContext();
155-
const routes = getRoutes(experimentalFeatures);
154+
const isCompositeSloEnabled = useCompositeSloEnabled();
155+
const routes = getRoutes(isCompositeSloEnabled);
156156

157157
return (
158158
<Routes enableExecutionContextTracking={true}>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { SLO_COMPOSITE_ENABLED } from '../../common/feature_flags';
9+
import { useKibana } from './use_kibana';
10+
11+
export function useCompositeSloEnabled(): boolean {
12+
const {
13+
services: { featureFlags },
14+
} = useKibana();
15+
16+
return featureFlags.getBooleanValue(SLO_COMPOSITE_ENABLED, false);
17+
}

x-pack/solutions/observability/plugins/slo/public/pages/composite_slo_edit/composite_slo_edit.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { paths } from '@kbn/slo-shared-plugin/common/locators/paths';
1212
import React, { useEffect } from 'react';
1313
import { useParams } from 'react-router-dom';
1414
import { HeaderMenu } from '../../components/header_menu/header_menu';
15+
import { useCompositeSloEnabled } from '../../hooks/use_composite_slo_enabled';
1516
import { useKibana } from '../../hooks/use_kibana';
1617
import { useLicense } from '../../hooks/use_license';
1718
import { usePermissions } from '../../hooks/use_permissions';
@@ -33,23 +34,24 @@ export function CompositeSloEditPage() {
3334
useFetchCompositeSlo(compositeSloId);
3435

3536
const { data: permissions } = usePermissions();
36-
const { ObservabilityPageTemplate, experimentalFeatures } = usePluginContext();
37+
const { ObservabilityPageTemplate } = usePluginContext();
3738
const { hasAtLeast } = useLicense();
3839
const hasRightLicense = hasAtLeast('platinum');
40+
const isCompositeSloEnabled = useCompositeSloEnabled();
3941

4042
useEffect(() => {
4143
if (
4244
hasRightLicense === false ||
4345
permissions?.hasAllReadRequested === false ||
44-
!experimentalFeatures?.compositeSlo?.enabled
46+
!isCompositeSloEnabled
4547
) {
4648
navigateToUrl(basePath.prepend(paths.slos));
4749
}
4850

4951
if (permissions?.hasAllWriteRequested === false) {
5052
navigateToUrl(basePath.prepend(paths.slos));
5153
}
52-
}, [hasRightLicense, permissions, navigateToUrl, basePath, experimentalFeatures]);
54+
}, [hasRightLicense, permissions, navigateToUrl, basePath, isCompositeSloEnabled]);
5355

5456
useBreadcrumbs(
5557
[

x-pack/solutions/observability/plugins/slo/public/pages/slos/components/common/create_slo_btn.test.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jest.mock('../../../../hooks/use_kibana');
1919
jest.mock('../../../../hooks/use_permissions');
2020
jest.mock('../../../../hooks/use_fetch_slo_templates');
2121
jest.mock('../../../../hooks/use_fetch_slo_template_tags');
22+
jest.mock('../../../../hooks/use_composite_slo_enabled', () => ({
23+
useCompositeSloEnabled: jest.fn().mockReturnValue(false),
24+
}));
2225

2326
const mockNavigateToUrl = jest.fn();
2427
const useKibanaMock = useKibana as jest.Mock;

x-pack/solutions/observability/plugins/slo/public/pages/slos/components/common/create_slo_btn.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { EuiButton, EuiContextMenuItem, EuiContextMenuPanel, EuiPopover } from '
99
import { i18n } from '@kbn/i18n';
1010
import { paths } from '@kbn/slo-shared-plugin/common/locators/paths';
1111
import React, { useCallback, useMemo, useState } from 'react';
12+
import { useCompositeSloEnabled } from '../../../../hooks/use_composite_slo_enabled';
1213
import { useKibana } from '../../../../hooks/use_kibana';
1314
import { usePermissions } from '../../../../hooks/use_permissions';
14-
import { usePluginContext } from '../../../../hooks/use_plugin_context';
1515
import { SloTemplatesFlyout } from '../../../../components/slo/slo_templates/slo_templates_flyout';
1616

1717
export function CreateSloBtn() {
@@ -20,13 +20,12 @@ export function CreateSloBtn() {
2020
http: { basePath },
2121
} = useKibana().services;
2222

23-
const { experimentalFeatures } = usePluginContext();
2423
const { data: permissions } = usePermissions();
2524
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
2625
const [isFlyoutOpen, setIsFlyoutOpen] = useState(false);
2726

2827
const isDisabled = !permissions?.hasAllWriteRequested;
29-
const isCompositeSloEnabled = experimentalFeatures?.compositeSlo?.enabled === true;
28+
const isCompositeSloEnabled = useCompositeSloEnabled();
3029

3130
const handleClickCreateSlo = useCallback(() => {
3231
setIsPopoverOpen(false);

0 commit comments

Comments
 (0)