Skip to content

Commit

Permalink
Add warnings to upgrade assistant for search sessions (#206998)
Browse files Browse the repository at this point in the history
## Summary

Part of #203925.
Resolves #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 <[email protected]>
Co-authored-by: Julia Rechkunova <[email protected]>
(cherry picked from commit b998946)

# Conflicts:
#	docs/upgrade-notes.asciidoc
  • Loading branch information
lukasolson committed Jan 29, 2025
1 parent cf61678 commit fd9fc91
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 15 deletions.
5 changes: 1 addition & 4 deletions docs/upgrade-notes.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2051,7 +2051,4 @@ To monitor endpoints, pages, and user journeys, go to **{observability}** -> **S
[float]
==== Elastic Security solution

NOTE: For the complete Elastic Security solution release information, refer to {security-guide}/release-notes.html[_Elastic Security Solution Release Notes_].



NOTE: For the complete Elastic Security solution release information, refer to {security-guide}/release-notes.html[_Elastic Security Solution Release Notes_].
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
]
`);
});
Expand Down Expand Up @@ -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.",
]
`);
});
Expand Down Expand Up @@ -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.",
]
`);
});
Expand Down
16 changes: 8 additions & 8 deletions src/platform/plugins/shared/data/server/config_deprecations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
];
10 changes: 10 additions & 0 deletions src/platform/plugins/shared/data/server/deprecations/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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,
},
}),
});
2 changes: 2 additions & 0 deletions src/platform/plugins/shared/data/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { BfetchServerSetup } from '@kbn/bfetch-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';
Expand Down Expand Up @@ -92,6 +93,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, {
bfetch,
Expand Down
1 change: 1 addition & 0 deletions src/platform/plugins/shared/data/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@kbn/safer-lodash-set",
"@kbn/esql-utils",
"@kbn/shared-ux-table-persist",
"@kbn/core-deprecations-common",
],
"exclude": [
"target/**/*",
Expand Down

0 comments on commit fd9fc91

Please sign in to comment.