Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warnings to upgrade assistant for search sessions #206998

Merged
merged 14 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/upgrade-notes.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,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 has been disabled by default (9.0.0)
[%collapsible]
====
*Details* +
Starting from version 9.0.0, search sessions has been 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 them in your kibana.yml configuration file. If not, no action is necessary.
jughosta marked this conversation as resolved.
Show resolved Hide resolved

To re-enable search sessions, add the following in your config.yml:

```
data.search.sessions.enabled: true
```
====
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,132 @@
/*
* 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 [coreStart] = await core.getStartServices();
const savedObjectsClient = coreStart.savedObjects.getScopedClient(context.request, {
includedHiddenTypes: [SEARCH_SESSION_TYPE],
});
const finder = savedObjectsClient.createPointInTimeFinder<SearchSessionAttributes>({
type: 'search-session',
perPage: 1000,
fields: ['name', 'username', 'expires'],
namespaces: ['*'],
});

const searchSessions: Array<SavedObjectsFindResult<SearchSessionAttributes>> = [];

for await (const response of finder.find()) {
jughosta marked this conversation as resolved.
Show resolved Hide resolved
searchSessions.push(
...response.saved_objects.filter(
(so) => new Date(so.attributes.expires).getTime() > Date.now()
)
);
}

if (!searchSessions.length) {
return [];
}

return [
{
title: i18n.translate('data.deprecations.searchSessionsTitle', {
defaultMessage: 'Found active search sessions',
jughosta marked this conversation as resolved.
Show resolved Hide resolved
}),
message: buildMessage({ searchSessions }),
deprecationType: 'feature',
level: 'warning',
correctiveActions: {
manualSteps: [
i18n.translate('data.deprecations.searchSessions.manualStepOneMessage', {
defaultMessage: 'Open the kibana.yml config file.',
}),
i18n.translate('data.deprecations.searchSessions.manualStepTwoMessage', {
defaultMessage: 'Add the following: "data.search.sessions.enabled: true"',
jughosta marked this conversation as resolved.
Show resolved Hide resolved
}),
i18n.translate('data.deprecations.searchSessions.manualStepTwoMessage', {
defaultMessage:
'Alternatively, if you do not want to keep these search sessions after upgrade, navigate to Stack Management > Search Sessions and delete any sessions that have not expired.',
}),
],
},
},
];
},
});

const searchSessionIdLabel = i18n.translate(
'data.deprecations.searchSessions.searchSessionIdLabel',
{
defaultMessage: 'ID',
}
);

const searchSessionNameLabel = i18n.translate(
'data.deprecations.searchSessions.searchSessionNameLabel',
{
defaultMessage: 'Name',
}
);

const searchSessionUserLabel = i18n.translate(
'data.deprecations.searchSessions.searchSessionUserLabel',
{
defaultMessage: 'User',
}
);

const searchSessionSpacesLabel = i18n.translate(
'data.deprecations.searchSessions.searchSessionSpacesLabel',
{
defaultMessage: 'Spaces',
}
);

const buildSearchSessionsListEntry = (
so: SavedObjectsFindResult<SearchSessionAttributes>
) => `- **${searchSessionIdLabel}:** ${so.id}
- **${searchSessionNameLabel}:** ${so.attributes.name}
- **${searchSessionUserLabel}:** ${so.attributes.username}
- **${searchSessionSpacesLabel}:** ${so.namespaces?.join(', ')}`;

const buildMessage = ({
searchSessions,
}: {
searchSessions: Array<SavedObjectsFindResult<SearchSessionAttributes>>;
}): DeprecationDetailsMessage => ({
type: 'markdown',
content: i18n.translate('data.deprecations.scriptedFieldsMessage', {
defaultMessage: `The search sessions feature is deprecated and will be disabled by default in 9.0. You currently have {numberOfSearchSessions} active search session(s). If you would like to continue using, managing, and restoring search sessions in 9.0, you'll need to re-enable them in your kibana.yml configuration file. If not, no action is necessary.
jughosta marked this conversation as resolved.
Show resolved Hide resolved
The following is a list of all active search sessions and their associated spaces:
{searchSessionsList}`,
values: {
numberOfSearchSessions: searchSessions.length,
searchSessionsList: searchSessions.map(buildSearchSessionsListEntry).join('\n'),
},
}),
});
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 @@ -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';
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/platform/plugins/shared/data/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"@kbn/search-types",
"@kbn/safer-lodash-set",
"@kbn/esql-utils",
"@kbn/shared-ux-table-persist"
"@kbn/shared-ux-table-persist",
"@kbn/core-deprecations-common"
],
"exclude": [
"target/**/*",
Expand Down