Skip to content

Commit

Permalink
Removes deprecated telemetry.url and telemetry.optInStatusUrl from te…
Browse files Browse the repository at this point in the history
…lemetry plugin config (#114737)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
TinaHeiligers and kibanamachine authored Oct 15, 2021
1 parent 07777b9 commit 22d07ed
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 415 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,30 @@ async function removeLogFile() {
// ignore errors if it doesn't exist
await fs.unlink(logFilePath).catch(() => void 0);
}
function sortByTypeAndId(a: { type: string; id: string }, b: { type: string; id: string }) {
return a.type.localeCompare(b.type) || a.id.localeCompare(b.id);
}

async function fetchDocuments(esClient: ElasticsearchClient, index: string) {
const { body } = await esClient.search<any>({
index,
body: {
query: {
match_all: {},
},
_source: ['type', 'id'],
},
});

return body.hits.hits
.map((h) => ({
...h._source,
id: h._id,
}))
.sort(sortByTypeAndId);
}

const assertMigratedDocuments = (arr: any[], target: any[]) => target.every((v) => arr.includes(v));

describe('migration v2', () => {
let esServer: kbnTestServer.TestElasticsearchUtils;
Expand Down Expand Up @@ -72,16 +96,11 @@ describe('migration v2', () => {
await new Promise((resolve) => setTimeout(resolve, 5000));

const esClient: ElasticsearchClient = esServer.es.getClient();
const migratedIndexResponse = await esClient.count({
index: targetIndex,
});
const oldIndexResponse = await esClient.count({
index: '.kibana_7.14.0_001',
});

// Use a >= comparison since once Kibana has started it might create new
// documents like telemetry tasks
expect(migratedIndexResponse.body.count).toBeGreaterThanOrEqual(oldIndexResponse.body.count);

// assert that the docs from the original index have been migrated rather than comparing a doc count after startup
const originalDocs = await fetchDocuments(esClient, '.kibana_7.14.0_001');
const migratedDocs = await fetchDocuments(esClient, targetIndex);
expect(assertMigratedDocuments(migratedDocs, originalDocs));
});

it('fails with a descriptive message when a single document exceeds maxBatchSizeBytes', async () => {
Expand Down
24 changes: 24 additions & 0 deletions src/core/server/ui_settings/saved_objects/migrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,28 @@ describe('ui_settings 8.0.0 migrations', () => {
migrationVersion: {},
});
});
test('removes telemetry:optIn and xPackMonitoring:allowReport from ui_settings', () => {
const doc = {
type: 'config',
id: '8.0.0',
attributes: {
buildNum: 9007199254740991,
'telemetry:optIn': false,
'xPackMonitoring:allowReport': false,
},
references: [],
updated_at: '2020-06-09T20:18:20.349Z',
migrationVersion: {},
};
expect(migration(doc)).toEqual({
type: 'config',
id: '8.0.0',
attributes: {
buildNum: 9007199254740991,
},
references: [],
updated_at: '2020-06-09T20:18:20.349Z',
migrationVersion: {},
});
});
});
5 changes: 4 additions & 1 deletion src/core/server/ui_settings/saved_objects/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,16 @@ export const migrations = {
'8.0.0': (doc: SavedObjectUnsanitizedDoc<any>): SavedObjectSanitizedDoc<any> => ({
...doc,
...(doc.attributes && {
// owner: Team:Geo
attributes: Object.keys(doc.attributes).reduce(
(acc, key) =>
[
// owner: Team:Geo
'visualization:regionmap:showWarnings',
'visualization:tileMap:WMSdefaults',
'visualization:tileMap:maxPrecision',
// owner: Team:Core
'telemetry:optIn',
'xPackMonitoring:allowReport',
].includes(key)
? {
...acc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ kibana_vars=(
telemetry.allowChangingOptInStatus
telemetry.enabled
telemetry.optIn
telemetry.optInStatusUrl
telemetry.sendUsageTo
telemetry.sendUsageFrom
tilemap.options.attribution
Expand Down
18 changes: 0 additions & 18 deletions src/plugins/telemetry/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,6 @@
* Side Public License, v 1.
*/

import { i18n } from '@kbn/i18n';

/**
* config options opt into telemetry
*/
export const CONFIG_TELEMETRY = 'telemetry:optIn';

/**
* config description for opting into telemetry
*/
export const getConfigTelemetryDesc = () => {
// Can't find where it's used but copying it over from the legacy code just in case...
return i18n.translate('telemetry.telemetryConfigDescription', {
defaultMessage:
'Help us improve the Elastic Stack by providing usage statistics for basic features. We will not share this data outside of Elastic.',
});
};

/**
* The amount of time, in milliseconds, to wait between reports when enabled.
* Currently 24 hours.
Expand Down
31 changes: 0 additions & 31 deletions src/plugins/telemetry/server/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import { schema, TypeOf, Type } from '@kbn/config-schema';
import { getConfigPath } from '@kbn/utils';
import { PluginConfigDescriptor } from 'kibana/server';
import { TELEMETRY_ENDPOINT } from '../../common/constants';
import { deprecateEndpointConfigs } from './deprecations';

const clusterEnvSchema: [Type<'prod'>, Type<'staging'>] = [
schema.literal('prod'),
Expand All @@ -36,34 +34,6 @@ const configSchema = schema.object({
schema.oneOf(clusterEnvSchema, { defaultValue: 'staging' }),
schema.oneOf(clusterEnvSchema, { defaultValue: 'prod' })
),
/**
* REMOVE IN 8.0 - INTERNAL CONFIG DEPRECATED IN 7.15
* REPLACED WITH `telemetry.sendUsageTo: staging | prod`
*/
url: schema.conditional(
schema.contextRef('dist'),
schema.literal(false), // Point to staging if it's not a distributable release
schema.string({
defaultValue: TELEMETRY_ENDPOINT.MAIN_CHANNEL.STAGING,
}),
schema.string({
defaultValue: TELEMETRY_ENDPOINT.MAIN_CHANNEL.PROD,
})
),
/**
* REMOVE IN 8.0 - INTERNAL CONFIG DEPRECATED IN 7.15
* REPLACED WITH `telemetry.sendUsageTo: staging | prod`
*/
optInStatusUrl: schema.conditional(
schema.contextRef('dist'),
schema.literal(false), // Point to staging if it's not a distributable release
schema.string({
defaultValue: TELEMETRY_ENDPOINT.OPT_IN_STATUS_CHANNEL.STAGING,
}),
schema.string({
defaultValue: TELEMETRY_ENDPOINT.OPT_IN_STATUS_CHANNEL.PROD,
})
),
sendUsageFrom: schema.oneOf([schema.literal('server'), schema.literal('browser')], {
defaultValue: 'server',
}),
Expand All @@ -81,5 +51,4 @@ export const config: PluginConfigDescriptor<TelemetryConfigType> = {
sendUsageFrom: true,
sendUsageTo: true,
},
deprecations: () => [deprecateEndpointConfigs],
};
197 changes: 0 additions & 197 deletions src/plugins/telemetry/server/config/deprecations.test.ts

This file was deleted.

Loading

0 comments on commit 22d07ed

Please sign in to comment.