[Serverless][Index Management] Hide Storage size column in Data streams (#169280)

Fixes https://github.com/elastic/kibana/issues/167654

## Summary

This PR removes the Storage size column in Data stream in serverless as
the data stream stats API on serverless doesn't currently return the
storage size.

### How to test:

Verify that the column is not displayed in serverless:

1. Start Es with `yarn es serverless` and Kibana with `yarn
serverless-{es/oblt/security}`
2. Go to Stack Management -> Index Management -> Data Streams
3. Switch on the "Include stats" toggle
4. Verify that the "Storage size" column is not shown in the table.

Verify that the column is displayed in stateful:

1. Start Es with `yarn es snapshot` and Kibana with `yarn start`
2. Go to Stack Management -> Index Management -> Data Streams
3. Switch on the "Include stats" toggle
4. Verify that the "Storage size" column is shown in the table.


<!---
### Checklist

Delete any items that are not applicable to this PR.

- [ ] 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/packages/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
- [ ] [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
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] 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 renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces&mdash;unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes&mdash;Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
-->
This commit is contained in:
Elena Stoeva 2023-10-23 18:05:23 +01:00 committed by GitHub
parent 320eff2870
commit 6a6b83e60c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 62 additions and 10 deletions

View file

@ -44,6 +44,8 @@ xpack.index_management.enableLegacyTemplates: false
xpack.index_management.enableIndexStats: false
# Only limited index settings can be edited
xpack.index_management.editableIndexSettings: limited
# Disable Storage size column in the Data streams table from Index Management UI
xpack.index_management.enableDataStreamsStorageColumn: false
# Keep deeplinks visible so that they are shown in the sidenav
dev_tools.deeplinks.navLinkStatus: visible

View file

@ -267,6 +267,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
'xpack.index_management.enableLegacyTemplates (any)',
'xpack.index_management.enableIndexStats (any)',
'xpack.index_management.editableIndexSettings (any)',
'xpack.index_management.enableDataStreamsStorageColumn (any)',
'xpack.infra.sources.default.fields.message (array)',
/**
* Feature flags bellow are conditional based on traditional/serverless offering

View file

@ -83,6 +83,7 @@ const appDependencies = {
enableIndexActions: true,
enableIndexStats: true,
editableIndexSettings: 'all',
enableDataStreamsStorageColumn: true,
},
} as any;

View file

@ -255,6 +255,35 @@ describe('Data Streams tab', () => {
]);
});
test('hides Storage size column from stats if enableDataStreamsStorageColumn===false', async () => {
testBed = await setup(httpSetup, {
config: {
enableDataStreamsStorageColumn: false,
},
});
const { actions, component, table } = testBed;
await act(async () => {
actions.goToDataStreamsList();
});
component.update();
// Switching the stats on
await act(async () => {
actions.clickIncludeStatsSwitch();
});
component.update();
// The table renders with the stats columns except the Storage size column
const { tableCellsValues } = table.getMetaData('dataStreamTable');
expect(tableCellsValues).toEqual([
['', 'dataStream1', 'green', 'December 31st, 1969 7:00:00 PM', '1', '7d', 'Delete'],
['', 'dataStream2', 'green', 'December 31st, 1969 7:00:00 PM', '1', '7d', 'Delete'],
]);
});
test('clicking the indices count navigates to the backing indices', async () => {
const { table, actions } = testBed;
await actions.clickIndicesAt(0);

View file

@ -54,6 +54,7 @@ export interface AppDependencies {
enableLegacyTemplates: boolean;
enableIndexStats: boolean;
editableIndexSettings: 'all' | 'limited';
enableDataStreamsStorageColumn: boolean;
};
history: ScopedHistory;
setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs'];

View file

@ -18,6 +18,7 @@ import {
} from '@elastic/eui';
import { ScopedHistory } from '@kbn/core/public';
import { useAppContext } from '../../../../app_context';
import { DataStream } from '../../../../../../common/types';
import { getLifecycleValue } from '../../../../lib/data_streams';
import { UseRequestResponse, reactRouterNavigate } from '../../../../../shared_imports';
@ -46,6 +47,7 @@ export const DataStreamTable: React.FunctionComponent<Props> = ({
}) => {
const [selection, setSelection] = useState<DataStream[]>([]);
const [dataStreamsToDelete, setDataStreamsToDelete] = useState<string[]>([]);
const { config } = useAppContext();
const columns: Array<EuiBasicTableColumn<DataStream>> = [];
@ -99,16 +101,18 @@ export const DataStreamTable: React.FunctionComponent<Props> = ({
}),
});
columns.push({
field: 'storageSizeBytes',
name: i18n.translate('xpack.idxMgmt.dataStreamList.table.storageSizeColumnTitle', {
defaultMessage: 'Storage size',
}),
truncateText: true,
sortable: true,
render: (storageSizeBytes: DataStream['storageSizeBytes'], dataStream: DataStream) =>
dataStream.storageSize,
});
if (config.enableDataStreamsStorageColumn) {
columns.push({
field: 'storageSizeBytes',
name: i18n.translate('xpack.idxMgmt.dataStreamList.table.storageSizeColumnTitle', {
defaultMessage: 'Storage size',
}),
truncateText: true,
sortable: true,
render: (storageSizeBytes: DataStream['storageSizeBytes'], dataStream: DataStream) =>
dataStream.storageSize,
});
}
}
columns.push({

View file

@ -42,6 +42,7 @@ export class IndexMgmtUIPlugin {
enableLegacyTemplates,
enableIndexStats,
editableIndexSettings,
enableDataStreamsStorageColumn,
} = this.ctx.config.get<ClientConfigType>();
if (isIndexManagementUiEnabled) {
@ -52,6 +53,7 @@ export class IndexMgmtUIPlugin {
enableLegacyTemplates: enableLegacyTemplates ?? true,
enableIndexStats: enableIndexStats ?? true,
editableIndexSettings: editableIndexSettings ?? 'all',
enableDataStreamsStorageColumn: enableDataStreamsStorageColumn ?? true,
};
management.sections.section.data.registerApp({
id: PLUGIN.id,

View file

@ -36,4 +36,5 @@ export interface ClientConfigType {
enableLegacyTemplates?: boolean;
enableIndexStats?: boolean;
editableIndexSettings?: 'all' | 'limited';
enableDataStreamsStorageColumn?: boolean;
}

View file

@ -47,6 +47,11 @@ const schemaLatest = schema.object(
defaultValue: 'all',
}),
}),
enableDataStreamsStorageColumn: offeringBasedSchema({
// The Storage size column in Data streams is disabled in serverless; refer to the serverless.yml file as the source of truth
// We take this approach in order to have a central place (serverless.yml) for serverless config across Kibana
serverless: schema.boolean({ defaultValue: true }),
}),
},
{ defaultValue: undefined }
);
@ -58,6 +63,7 @@ const configLatest: PluginConfigDescriptor<IndexManagementConfig> = {
enableLegacyTemplates: true,
enableIndexStats: true,
editableIndexSettings: true,
enableDataStreamsStorageColumn: true,
},
schema: schemaLatest,
deprecations: ({ unused }) => [unused('dev.enableIndexDetailsPage', { level: 'warning' })],

View file

@ -56,6 +56,7 @@ export class IndexMgmtServerPlugin implements Plugin<IndexManagementPluginSetup,
isSecurityEnabled: () => security !== undefined && security.license.isEnabled(),
isLegacyTemplatesEnabled: this.config.enableLegacyTemplates,
isIndexStatsEnabled: this.config.enableIndexStats,
isDataStreamsStorageColumnEnabled: this.config.enableDataStreamsStorageColumn,
},
indexDataEnricher: this.indexDataEnricher,
lib: {

View file

@ -48,6 +48,7 @@ describe('GET privileges', () => {
isSecurityEnabled: () => true,
isLegacyTemplatesEnabled: true,
isIndexStatsEnabled: true,
isDataStreamsStorageColumnEnabled: true,
},
indexDataEnricher: mockedIndexDataEnricher,
lib: {
@ -116,6 +117,7 @@ describe('GET privileges', () => {
isSecurityEnabled: () => false,
isLegacyTemplatesEnabled: true,
isIndexStatsEnabled: true,
isDataStreamsStorageColumnEnabled: true,
},
indexDataEnricher: mockedIndexDataEnricher,
lib: {

View file

@ -14,6 +14,7 @@ export const routeDependencies: Omit<RouteDependencies, 'router'> = {
isSecurityEnabled: jest.fn().mockReturnValue(true),
isLegacyTemplatesEnabled: true,
isIndexStatsEnabled: true,
isDataStreamsStorageColumnEnabled: true,
},
indexDataEnricher: new IndexDataEnricher(),
lib: {

View file

@ -25,6 +25,7 @@ export interface RouteDependencies {
isSecurityEnabled: () => boolean;
isLegacyTemplatesEnabled: boolean;
isIndexStatsEnabled: boolean;
isDataStreamsStorageColumnEnabled: boolean;
};
indexDataEnricher: IndexDataEnricher;
lib: {