Add warnings to upgrade assistant for search sessions (#206998)

## Summary

Part of https://github.com/elastic/kibana/issues/203925.
Resolves https://github.com/elastic/kibana/issues/205813.

Adds warning messages to the upgrade assistant if a cluster has
unexpired search sessions, since the feature is being disabled by
default and will have to be explicitly re-enabled to manage the
sessions.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Julia Rechkunova <julia.rechkunova@gmail.com>
This commit is contained in:
Lukas Olson 2025-01-28 15:13:53 -07:00 committed by GitHub
parent 71566f38dc
commit b998946003
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 139 additions and 11 deletions

View file

@ -320,4 +320,26 @@ Systems that use HTTP/1 or don't have TLS configured will get a deprecation warn
Verify that TLS is properly configured by enabling it and providing valid certificates in the settings. Test your system to ensure that connections are established securely over HTTP/2.
If your Kibana server is hosted behind a load balancer or reverse proxy we recommend testing your deployment configuration before upgrading to 9.0.
====
[discrete]
[[known-issue-206998]]
.Search sessions disabled by default (9.0.0)
[%collapsible]
====
*Details* +
Starting from version 9.0.0, search sessions are disabled by default. To view, manage, and restore search sessions, the feature needs to be explicitly re-enabled.
*Impact* +
Search sessions will be disabled unless they are explicitly enabled in config.yml.
*Action* +
If you would like to continue using, managing, and restoring search sessions in 9.0, you'll need to re-enable the feature in your kibana.yml configuration file. If not, no action is necessary.
To re-enable search sessions, add the following in your config.yml:
```
data.search.sessions.enabled: true
```
====

View file

@ -62,7 +62,7 @@ describe('Config Deprecations', () => {
expect(messages).toMatchInlineSnapshot(`
Array [
"Setting \\"xpack.data_enhanced.search.sessions\\" has been replaced by \\"data.search.sessions\\"",
"Configuring \\"data.search.sessions.enabled\\" is deprecated and will be removed in 9.0.0.",
"Configuring \\"data.search.sessions.enabled\\" is deprecated and will be removed in 9.1.0.",
]
`);
});
@ -103,7 +103,7 @@ describe('Config Deprecations', () => {
"You no longer need to configure \\"data.search.sessions.expireInterval\\".",
"You no longer need to configure \\"data.search.sessions.monitoringTaskTimeout\\".",
"You no longer need to configure \\"data.search.sessions.notTouchedInProgressTimeout\\".",
"Configuring \\"data.search.sessions.enabled\\" is deprecated and will be removed in 9.0.0.",
"Configuring \\"data.search.sessions.enabled\\" is deprecated and will be removed in 9.1.0.",
]
`);
});
@ -147,7 +147,7 @@ describe('Config Deprecations', () => {
"You no longer need to configure \\"data.search.sessions.expireInterval\\".",
"You no longer need to configure \\"data.search.sessions.monitoringTaskTimeout\\".",
"You no longer need to configure \\"data.search.sessions.notTouchedInProgressTimeout\\".",
"Configuring \\"data.search.sessions.enabled\\" is deprecated and will be removed in 9.0.0.",
"Configuring \\"data.search.sessions.enabled\\" is deprecated and will be removed in 9.1.0.",
]
`);
});

View file

@ -27,12 +27,12 @@ export const configDeprecationProvider: ConfigDeprecationProvider = ({
unusedFromRoot('data.search.sessions.notTouchedInProgressTimeout', { level }),
// Search sessions config deprecations
deprecateFromRoot('data.search.sessions.enabled', '9.0.0', { level }),
deprecateFromRoot('data.search.sessions.notTouchedTimeout', '9.0.0', { level }),
deprecateFromRoot('data.search.sessions.maxUpdateRetries', '9.0.0', { level }),
deprecateFromRoot('data.search.sessions.defaultExpiration', '9.0.0', { level }),
deprecateFromRoot('data.search.sessions.management.maxSessions', '9.0.0', { level }),
deprecateFromRoot('data.search.sessions.management.refreshInterval', '9.0.0', { level }),
deprecateFromRoot('data.search.sessions.management.refreshTimeout', '9.0.0', { level }),
deprecateFromRoot('data.search.sessions.management.expiresSoonWarning', '9.0.0', { level }),
deprecateFromRoot('data.search.sessions.enabled', '9.1.0', { level }),
deprecateFromRoot('data.search.sessions.notTouchedTimeout', '9.1.0', { level }),
deprecateFromRoot('data.search.sessions.maxUpdateRetries', '9.1.0', { level }),
deprecateFromRoot('data.search.sessions.defaultExpiration', '9.1.0', { level }),
deprecateFromRoot('data.search.sessions.management.maxSessions', '9.1.0', { level }),
deprecateFromRoot('data.search.sessions.management.refreshInterval', '9.1.0', { level }),
deprecateFromRoot('data.search.sessions.management.refreshTimeout', '9.1.0', { level }),
deprecateFromRoot('data.search.sessions.management.expiresSoonWarning', '9.1.0', { level }),
];

View file

@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export { createSearchSessionsDeprecationsConfig } from './search_sessions';

View file

@ -0,0 +1,93 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import type {
CoreSetup,
DeprecationsDetails,
GetDeprecationsContext,
RegisterDeprecationsConfig,
SavedObjectsFindResult,
} from '@kbn/core/server';
import { i18n } from '@kbn/i18n';
import type { DeprecationDetailsMessage } from '@kbn/core-deprecations-common';
import { SEARCH_SESSION_TYPE, SearchSessionSavedObjectAttributes } from '../../common';
type SearchSessionAttributes = Pick<
SearchSessionSavedObjectAttributes,
'name' | 'username' | 'expires'
>;
export const createSearchSessionsDeprecationsConfig: (
core: CoreSetup
) => RegisterDeprecationsConfig = (core: CoreSetup) => ({
getDeprecations: async (context: GetDeprecationsContext): Promise<DeprecationsDetails[]> => {
const searchSessionsLink = core.http.basePath.prepend('/app/management/kibana/search_sessions');
const [coreStart] = await core.getStartServices();
const savedObjectsClient = coreStart.savedObjects.getScopedClient(context.request, {
includedHiddenTypes: [SEARCH_SESSION_TYPE],
});
const results = await savedObjectsClient.find<SearchSessionAttributes>({
type: 'search-session',
perPage: 1000,
fields: ['name', 'username', 'expires'],
sortField: 'created',
sortOrder: 'desc',
namespaces: ['*'],
});
const searchSessions: Array<SavedObjectsFindResult<SearchSessionAttributes>> =
results.saved_objects.filter((so) => new Date(so.attributes.expires).getTime() > Date.now());
if (!searchSessions.length) {
return [];
}
return [
{
title: i18n.translate('data.deprecations.searchSessionsTitle', {
defaultMessage: 'Search sessions will be disabled by default',
}),
message: buildMessage({ searchSessions, searchSessionsLink }),
deprecationType: 'feature',
level: 'warning',
correctiveActions: {
manualSteps: [
i18n.translate('data.deprecations.searchSessions.manualStepOneMessage', {
defaultMessage: 'Navigate to Stack Management > Kibana > Search Sessions',
}),
i18n.translate('data.deprecations.searchSessions.manualStepTwoMessage', {
defaultMessage: 'Delete search sessions that have not expired',
}),
i18n.translate('data.deprecations.searchSessions.manualStepTwoMessage', {
defaultMessage:
'Alternatively, to continue using search sessions until 9.1, open the kibana.yml config file and add the following: "data.search.sessions.enabled: true"',
}),
],
},
},
];
},
});
const buildMessage = ({
searchSessions,
searchSessionsLink,
}: {
searchSessions: Array<SavedObjectsFindResult<SearchSessionAttributes>>;
searchSessionsLink: string;
}): DeprecationDetailsMessage => ({
type: 'markdown',
content: i18n.translate('data.deprecations.scriptedFieldsMessage', {
defaultMessage: `The search sessions feature is deprecated and is disabled by default in 9.0. You currently have {numberOfSearchSessions} active search session(s): [Manage Search Sessions]({searchSessionsLink})`,
values: {
numberOfSearchSessions: searchSessions.length,
searchSessionsLink,
},
}),
});

View file

@ -12,6 +12,7 @@ import { ExpressionsServerSetup } from '@kbn/expressions-plugin/server';
import { PluginStart as DataViewsServerPluginStart } from '@kbn/data-views-plugin/server';
import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/server';
import { FieldFormatsSetup, FieldFormatsStart } from '@kbn/field-formats-plugin/server';
import { createSearchSessionsDeprecationsConfig } from './deprecations';
import { ConfigSchema } from './config';
import type { ISearchSetup, ISearchStart } from './search';
import { DatatableUtilitiesService } from './datatable_utilities';
@ -90,6 +91,7 @@ export class DataServerPlugin
this.kqlTelemetryService.setup(core, { usageCollection });
core.uiSettings.register(getUiSettings(core.docLinks, this.config.enableUiSettingsValidations));
core.deprecations.registerDeprecations(createSearchSessionsDeprecationsConfig(core));
const searchSetup = this.searchService.setup(core, {
expressions,

View file

@ -54,6 +54,7 @@
"@kbn/safer-lodash-set",
"@kbn/esql-utils",
"@kbn/shared-ux-table-persist",
"@kbn/core-deprecations-common",
],
"exclude": [
"target/**/*",