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

[8.0] remove kibana.index config property #112773

Merged
merged 39 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8b51e51
remove kibana config
pgayvallet Sep 22, 2021
dc8f78b
remove kibanaConfig usages
pgayvallet Sep 22, 2021
c766a2b
prettier fix
pgayvallet Sep 22, 2021
5791071
fix some globalConfig.kibana.index access
pgayvallet Sep 22, 2021
954217f
fix xpack_legacy globalConfig usage
pgayvallet Sep 22, 2021
19c916d
fix home globalConfig usage
pgayvallet Sep 22, 2021
d2af27d
fix canvas globalConfig usage
pgayvallet Sep 22, 2021
dfddcc8
fix action globalConfig usage
pgayvallet Sep 22, 2021
43eb4fc
fix (all?) remaining usages
pgayvallet Sep 22, 2021
d4e6ef7
fix more plugins
pgayvallet Sep 22, 2021
c2409c1
fix more plugins bis
pgayvallet Sep 22, 2021
6dc9a7d
yet more usages
pgayvallet Sep 22, 2021
0632b83
fix ml usages
pgayvallet Sep 22, 2021
bedf656
fix security_solution
pgayvallet Sep 22, 2021
bb48eb0
fix lens
pgayvallet Sep 22, 2021
9920a84
fix monitoring
pgayvallet Sep 23, 2021
d72fe95
remove from settings docs
pgayvallet Sep 23, 2021
566f266
Merge remote-tracking branch 'upstream/master' into kbn-101964-remove…
pgayvallet Sep 23, 2021
057d9e4
Merge remote-tracking branch 'upstream/master' into kbn-101964-remove…
pgayvallet Sep 23, 2021
fecb83b
move doc update
pgayvallet Sep 23, 2021
c6470cd
fix unit tests
pgayvallet Sep 23, 2021
7efd28c
update generated doc
pgayvallet Sep 23, 2021
723312d
improve test
pgayvallet Sep 23, 2021
235aa73
Merge remote-tracking branch 'upstream/master' into kbn-101964-remove…
pgayvallet Sep 27, 2021
a098cd2
Merge remote-tracking branch 'upstream/master' into kbn-101964-remove…
pgayvallet Sep 28, 2021
f068d13
Merge remote-tracking branch 'upstream/master' into kbn-101964-remove…
pgayvallet Sep 30, 2021
c46ae22
Merge remote-tracking branch 'upstream/master' into kbn-101964-remove…
pgayvallet Oct 4, 2021
4d443c4
Merge remote-tracking branch 'upstream/master' into kbn-101964-remove…
pgayvallet Oct 6, 2021
627ea46
Merge remote-tracking branch 'upstream/master' into kbn-101964-remove…
pgayvallet Oct 11, 2021
3fdb550
Merge remote-tracking branch 'upstream/master' into kbn-101964-remove…
pgayvallet Oct 18, 2021
1c01ac6
adapt new usage in security_solution
pgayvallet Oct 18, 2021
2888c5e
Merge remote-tracking branch 'upstream/master' into kbn-101964-remove…
pgayvallet Oct 18, 2021
df11842
Merge remote-tracking branch 'upstream/master' into kbn-101964-remove…
pgayvallet Oct 19, 2021
7e95da3
Merge remote-tracking branch 'upstream/master' into kbn-101964-remove…
pgayvallet Oct 21, 2021
72ed91a
fix security_solution config
pgayvallet Oct 21, 2021
277a3ad
fix createConfig, again
pgayvallet Oct 21, 2021
f2c38d4
fix mock config
pgayvallet Oct 21, 2021
ee793e6
Merge remote-tracking branch 'upstream/master' into kbn-101964-remove…
pgayvallet Oct 25, 2021
f112393
Merge remote-tracking branch 'upstream/master' into kbn-101964-remove…
pgayvallet Oct 25, 2021
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
4 changes: 0 additions & 4 deletions config/kibana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
# The URLs of the Elasticsearch instances to use for all your queries.
#elasticsearch.hosts: ["http://localhost:9200"]

# Kibana uses an index in Elasticsearch to store saved searches, visualizations and
# dashboards. Kibana creates a new index if the index doesn't already exist.
#kibana.index: ".kibana"

# If your Elasticsearch is protected with basic authentication, these settings provide
# the username and password that the Kibana server uses to perform maintenance on the Kibana
# index at startup. Your Kibana users still need to authenticate with Elasticsearch, which
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsServiceSetup](./kibana-plugin-core-server.savedobjectsservicesetup.md) &gt; [getKibanaIndex](./kibana-plugin-core-server.savedobjectsservicesetup.getkibanaindex.md)

## SavedObjectsServiceSetup.getKibanaIndex property

Returns the default index used for saved objects.

<b>Signature:</b>

```typescript
getKibanaIndex: () => string;
```
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class Plugin() {
| Property | Type | Description |
| --- | --- | --- |
| [addClientWrapper](./kibana-plugin-core-server.savedobjectsservicesetup.addclientwrapper.md) | <code>(priority: number, id: string, factory: SavedObjectsClientWrapperFactory) =&gt; void</code> | Add a [client wrapper factory](./kibana-plugin-core-server.savedobjectsclientwrapperfactory.md) with the given priority. |
| [getKibanaIndex](./kibana-plugin-core-server.savedobjectsservicesetup.getkibanaindex.md) | <code>() =&gt; string</code> | Returns the default index used for saved objects. |
| [registerType](./kibana-plugin-core-server.savedobjectsservicesetup.registertype.md) | <code>&lt;Attributes = any&gt;(type: SavedObjectsType&lt;Attributes&gt;) =&gt; void</code> | Register a [savedObjects type](./kibana-plugin-core-server.savedobjectstype.md) definition.<!-- -->See the [mappings format](./kibana-plugin-core-server.savedobjectstypemappingdefinition.md) and [migration format](./kibana-plugin-core-server.savedobjectmigrationmap.md) for more details about these. |
| [setClientFactoryProvider](./kibana-plugin-core-server.savedobjectsservicesetup.setclientfactoryprovider.md) | <code>(clientFactoryProvider: SavedObjectsClientFactoryProvider) =&gt; void</code> | Set the default [factory provider](./kibana-plugin-core-server.savedobjectsclientfactoryprovider.md) for creating Saved Objects clients. Only one provider can be set, subsequent calls to this method will fail. |

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

```typescript
export declare type SharedGlobalConfig = RecursiveReadonly<{
kibana: Pick<KibanaConfigType, typeof SharedGlobalConfigKeys.kibana[number]>;
elasticsearch: Pick<ElasticsearchConfigType, typeof SharedGlobalConfigKeys.elasticsearch[number]>;
path: Pick<PathConfigType, typeof SharedGlobalConfigKeys.path[number]>;
savedObjects: Pick<SavedObjectsConfigType, typeof SharedGlobalConfigKeys.savedObjects[number]>;
Expand Down
12 changes: 0 additions & 12 deletions docs/setup/settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -285,18 +285,6 @@ is an alternative to `elasticsearch.username` and `elasticsearch.password`.
| `interpreter.enableInVisualize`
| Enables use of interpreter in Visualize. *Default: `true`*

|[[kibana-index]] `kibana.index:`
| deprecated:[7.11.0,This setting will be removed in 8.0.] Multitenancy by
changing `kibana.index` will not be supported starting in 8.0. See
https://ela.st/kbn-remove-legacy-multitenancy[8.0 Breaking Changes] for more
details.
+
{kib} uses an index in {es} to store saved searches, visualizations, and
dashboards. {kib} creates a new index if the index doesn’t already exist. If
you configure a custom index, the name must be lowercase, and conform to the
{es} {ref}/indices-create-index.html[index name limitations].
*Default: `".kibana"`*

| `data.autocomplete.valueSuggestions.timeout:` {ess-icon}
| Time in milliseconds to wait for autocomplete suggestions from {es}.
This value must be a whole number greater than zero. *Default: `"1000"`*
Expand Down
4 changes: 2 additions & 2 deletions docs/setup/upgrade/upgrade-migrations.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ WARNING: The following instructions assumes {kib} is using the default index nam

Saved objects are stored in two indices:

* `.kibana_{kibana_version}_001`, or if the `kibana.index` configuration setting is set `.{kibana.index}_{kibana_version}_001`. E.g. for Kibana v7.12.0 `.kibana_7.12.0_001`.
* `.kibana_task_manager_{kibana_version}_001`, or if the `xpack.tasks.index` configuration setting is set `.{xpack.tasks.index}_{kibana_version}_001` E.g. for Kibana v7.12.0 `.kibana_task_manager_7.12.0_001`.
* `.kibana_{kibana_version}_001`, e.g. for Kibana v7.12.0 `.kibana_7.12.0_001`.
* `.kibana_task_manager_{kibana_version}_001`, e.g. for Kibana v7.12.0 `.kibana_task_manager_7.12.0_001`.

The index aliases `.kibana` and `.kibana_task_manager` will always point to
the most up-to-date saved object indices.
Expand Down
1 change: 0 additions & 1 deletion src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import { Action } from 'history';
import { ApiResponse } from '@elastic/elasticsearch/lib/Transport';
import Boom from '@hapi/boom';
import { ConfigDeprecationProvider } from '@kbn/config';
import { ConfigPath } from '@kbn/config';
import { DetailedPeerCertificate } from 'tls';
import { EnvironmentMode } from '@kbn/config';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { mockCoreContext } from '../core_context.mock';
import { config as RawElasticsearchConfig } from '../elasticsearch/elasticsearch_config';
import { config as RawHttpConfig } from '../http/http_config';
import { config as RawLoggingConfig } from '../logging/logging_config';
import { config as RawKibanaConfig } from '../kibana_config';
import { savedObjectsConfig as RawSavedObjectsConfig } from '../saved_objects/saved_objects_config';
import { httpServiceMock } from '../http/http_service.mock';
import { metricsServiceMock } from '../metrics/metrics_service.mock';
Expand All @@ -40,8 +39,6 @@ describe('CoreUsageDataService', () => {
return new BehaviorSubject(RawLoggingConfig.schema.validate({}));
} else if (path === 'savedObjects') {
return new BehaviorSubject(RawSavedObjectsConfig.schema.validate({}));
} else if (path === 'kibana') {
return new BehaviorSubject(RawKibanaConfig.schema.validate({}));
}
return new BehaviorSubject({});
};
Expand Down
34 changes: 7 additions & 27 deletions src/core/server/core_usage_data/core_usage_data_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import type {
} from './types';
import { isConfigured } from './is_configured';
import { ElasticsearchServiceStart } from '../elasticsearch';
import { KibanaConfigType } from '../kibana_config';
import { coreUsageStatsType } from './core_usage_stats';
import { LEGACY_URL_ALIAS_TYPE } from '../saved_objects/object_types';
import { CORE_USAGE_STATS_TYPE } from './constants';
Expand All @@ -56,6 +55,8 @@ export interface StartDeps {
exposedConfigsToUsage: ExposedConfigsToUsage;
}

const kibanaIndex = '.kibana';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the savedObjects service depends on coreUsageData, and not the other way around, so we can't easily use the new getKibanaIndex API from within the coreUsageData service. Had to hardcode the value here, unfortunately.

Could eventually expose this constant from src/core/saved_objects and import it there, it would probably be slightly better, but OTOH this will likely not change, and this code is only internal to core, so it would be not impact API consumers if we need to refactor it in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we have a circular dependency here?
savedObjects.setup depends on InternalCoreUsageDataSetup
coreUsageData.start depends on InternalSavedObjectsServiceStart
We will have to fix it eventually.

Could eventually expose this constant from src/core/saved_objects and import it there, it would probably be slightly better,

Since coreUsageData.start has access to InternalSavedObjectsServiceStart we can expose getKibanaIndex via start contract as well


/**
* Because users can configure their Saved Object to any arbitrary index name,
* we need to map customized index names back to a "standard" index name.
Expand All @@ -74,19 +75,6 @@ const kibanaOrTaskManagerIndex = (index: string, kibanaConfigIndex: string) => {
return index === kibanaConfigIndex ? '.kibana' : '.kibana_task_manager';
};

/**
* This is incredibly hacky... The config service doesn't allow you to determine
* whether or not a config value has been changed from the default value, and the
* default value is defined in legacy code.
*
* This will be going away in 8.0, so please look away for a few months
*
* @param index The `kibana.index` setting from the `kibana.yml`
*/
const isCustomIndex = (index: string) => {
return index !== '.kibana';
};

export class CoreUsageDataService
implements CoreService<InternalCoreUsageDataSetup, CoreUsageDataStart>
{
Expand All @@ -98,7 +86,6 @@ export class CoreUsageDataService
private soConfig?: SavedObjectsConfigType;
private stop$: Subject<void>;
private opsMetrics?: OpsMetrics;
private kibanaConfig?: KibanaConfigType;
private coreUsageStatsClient?: CoreUsageStatsClient;
private deprecatedConfigPaths: ChangedDeprecatedPaths = { set: [], unset: [] };
private incrementUsageCounter: CoreIncrementUsageCounter = () => {}; // Initially set to noop
Expand Down Expand Up @@ -133,8 +120,8 @@ export class CoreUsageDataService
.getTypeRegistry()
.getAllTypes()
.reduce((acc, type) => {
const index = type.indexPattern ?? this.kibanaConfig!.index;
return index != null ? acc.add(index) : acc;
const index = type.indexPattern ?? kibanaIndex;
return acc.add(index);
}, new Set<string>())
.values()
).map((index) => {
Expand All @@ -150,7 +137,7 @@ export class CoreUsageDataService
.then(({ body }) => {
const stats = body[0];
return {
alias: kibanaOrTaskManagerIndex(index, this.kibanaConfig!.index),
alias: kibanaOrTaskManagerIndex(index, kibanaIndex),
docsCount: stats['docs.count'] ? parseInt(stats['docs.count'], 10) : 0,
docsDeleted: stats['docs.deleted'] ? parseInt(stats['docs.deleted'], 10) : 0,
storeSizeBytes: stats['store.size'] ? parseInt(stats['store.size'], 10) : 0,
Expand All @@ -167,7 +154,7 @@ export class CoreUsageDataService
// Note: this agg can be changed to use `savedObjectsRepository.find` in the future after `filters` is supported.
// See src/core/server/saved_objects/service/lib/aggregations/aggs_types/bucket_aggs.ts for supported aggregations.
const { body: resp } = await elasticsearch.client.asInternalUser.search({
index: this.kibanaConfig!.index,
index: kibanaIndex,
body: {
track_total_hits: true,
query: { match: { type: LEGACY_URL_ALIAS_TYPE } },
Expand Down Expand Up @@ -313,7 +300,7 @@ export class CoreUsageDataService
},

savedObjects: {
customIndex: isCustomIndex(this.kibanaConfig!.index),
customIndex: false,
maxImportPayloadBytes: this.soConfig.maxImportPayloadBytes.getValueInBytes(),
maxImportExportSize: this.soConfig.maxImportExportSize,
},
Expand Down Expand Up @@ -472,13 +459,6 @@ export class CoreUsageDataService
this.soConfig = config;
});

this.configService
.atPath<KibanaConfigType>('kibana')
.pipe(takeUntil(this.stop$))
.subscribe((config) => {
this.kibanaConfig = config;
});

changedDeprecatedConfigPath$
.pipe(takeUntil(this.stop$))
.subscribe((deprecatedConfigPaths) => (this.deprecatedConfigPaths = deprecatedConfigPaths));
Expand Down
42 changes: 0 additions & 42 deletions src/core/server/kibana_config.test.ts

This file was deleted.

51 changes: 0 additions & 51 deletions src/core/server/kibana_config.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/core/server/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ type MockedPluginInitializerConfig<T> = jest.Mocked<PluginInitializerContext<T>[

export function pluginInitializerContextConfigMock<T>(config: T) {
const globalConfig: SharedGlobalConfig = {
kibana: {
index: '.kibana-tests',
},
elasticsearch: {
shardTimeout: duration('30s'),
requestTimeout: duration('30s'),
Expand Down
6 changes: 0 additions & 6 deletions src/core/server/plugins/legacy_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ describe('Legacy config', () => {
const legacyConfig = getGlobalConfig(configService);

expect(legacyConfig).toStrictEqual({
kibana: {
index: '.kibana',
},
elasticsearch: {
shardTimeout: duration(30, 's'),
requestTimeout: duration(30, 's'),
Expand All @@ -62,9 +59,6 @@ describe('Legacy config', () => {
const legacyConfig = await getGlobalConfig$(configService).pipe(take(1)).toPromise();

expect(legacyConfig).toStrictEqual({
kibana: {
index: '.kibana',
},
elasticsearch: {
shardTimeout: duration(30, 's'),
requestTimeout: duration(30, 's'),
Expand Down
9 changes: 1 addition & 8 deletions src/core/server/plugins/legacy_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,22 @@ import { pick, deepFreeze } from '@kbn/std';
import { IConfigService } from '@kbn/config';

import { SharedGlobalConfig, SharedGlobalConfigKeys } from './types';
import { KibanaConfigType, config as kibanaConfig } from '../kibana_config';
import {
ElasticsearchConfigType,
config as elasticsearchConfig,
} from '../elasticsearch/elasticsearch_config';
import { SavedObjectsConfigType, savedObjectsConfig } from '../saved_objects/saved_objects_config';

const createGlobalConfig = ({
kibana,
elasticsearch,
path,
savedObjects,
}: {
kibana: KibanaConfigType;
elasticsearch: ElasticsearchConfigType;
path: PathConfigType;
savedObjects: SavedObjectsConfigType;
}): SharedGlobalConfig => {
return deepFreeze({
kibana: pick(kibana, SharedGlobalConfigKeys.kibana),
elasticsearch: pick(elasticsearch, SharedGlobalConfigKeys.elasticsearch),
path: pick(path, SharedGlobalConfigKeys.path),
savedObjects: pick(savedObjects, SharedGlobalConfigKeys.savedObjects),
Expand All @@ -41,7 +37,6 @@ const createGlobalConfig = ({

export const getGlobalConfig = (configService: IConfigService): SharedGlobalConfig => {
return createGlobalConfig({
kibana: configService.atPathSync<KibanaConfigType>(kibanaConfig.path),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we can remove other props from getGlobalConfig$ or remove the legacy config completely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't remove the legacy config completely without additional changes. I know at least reporting uses it to access path.data. We should expose a new core API to replace these usages, but I don't think we want to do it in current PR. I will open a follow-up issue to handle the other props of the global config.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 not in the current PR, for sure

elasticsearch: configService.atPathSync<ElasticsearchConfigType>(elasticsearchConfig.path),
path: configService.atPathSync<PathConfigType>(pathConfig.path),
savedObjects: configService.atPathSync<SavedObjectsConfigType>(savedObjectsConfig.path),
Expand All @@ -50,15 +45,13 @@ export const getGlobalConfig = (configService: IConfigService): SharedGlobalConf

export const getGlobalConfig$ = (configService: IConfigService): Observable<SharedGlobalConfig> => {
return combineLatest([
configService.atPath<KibanaConfigType>(kibanaConfig.path),
configService.atPath<ElasticsearchConfigType>(elasticsearchConfig.path),
configService.atPath<PathConfigType>(pathConfig.path),
configService.atPath<SavedObjectsConfigType>(savedObjectsConfig.path),
]).pipe(
map(
([kibana, elasticsearch, path, savedObjects]) =>
([elasticsearch, path, savedObjects]) =>
createGlobalConfig({
kibana,
elasticsearch,
path,
savedObjects,
Expand Down
3 changes: 0 additions & 3 deletions src/core/server/plugins/plugin_context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ describe('createPluginInitializerContext', () => {
.pipe(first())
.toPromise();
expect(configObject).toStrictEqual({
kibana: {
index: '.kibana',
},
elasticsearch: {
shardTimeout: duration(30, 's'),
requestTimeout: duration(30, 's'),
Expand Down
1 change: 1 addition & 0 deletions src/core/server/plugins/plugin_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export function createPluginSetupContext<TPlugin, TPluginDependencies>(
setClientFactoryProvider: deps.savedObjects.setClientFactoryProvider,
addClientWrapper: deps.savedObjects.addClientWrapper,
registerType: deps.savedObjects.registerType,
getKibanaIndex: deps.savedObjects.getKibanaIndex,
},
status: {
core$: deps.status.core$,
Expand Down
Loading