Revert "[APM] Add index.fast_refresh to .apm-custom-link" (#163142)

Reverts elastic/kibana#159674

The Elasticsearch team has changed their guidance about `fast_refresh`
and want this setting to be applied from within an Elasticsearch plugin
This commit is contained in:
Miriam 2023-08-08 08:34:48 +01:00 committed by GitHub
parent 0d49c8a214
commit adb9573cb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 7 additions and 45 deletions

View file

@ -39,7 +39,6 @@ xpack.apm.featureFlags.infraUiAvailable: false
xpack.apm.featureFlags.migrationToFleetAvailable: false
xpack.apm.featureFlags.sourcemapApiAvailable: false
xpack.apm.featureFlags.storageExplorerAvailable: false
xpack.apm.featureFlags.fastRefreshAvailable: true
# Specify in telemetry the project type
telemetry.labels.serverless: observability

View file

@ -187,7 +187,6 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
'xpack.apm.latestAgentVersionsUrl (string)',
'xpack.apm.featureFlags.agentConfigurationAvailable (any)',
'xpack.apm.featureFlags.configurableIndicesAvailable (any)',
'xpack.apm.featureFlags.fastRefreshAvailable (any)',
'xpack.apm.featureFlags.infrastructureTabAvailable (any)',
'xpack.apm.featureFlags.infraUiAvailable (any)',
'xpack.apm.featureFlags.migrationToFleetAvailable (any)',

View file

@ -16,7 +16,6 @@ export enum ApmFeatureFlagName {
MigrationToFleetAvailable = 'migrationToFleetAvailable',
SourcemapApiAvailable = 'sourcemapApiAvailable',
StorageExplorerAvailable = 'storageExplorerAvailable',
FastRefreshAvailable = 'fastRefreshAvailable',
}
const apmFeatureFlagMap = {
@ -48,10 +47,6 @@ const apmFeatureFlagMap = {
default: true,
type: t.boolean,
},
[ApmFeatureFlagName.FastRefreshAvailable]: {
default: false,
type: t.boolean,
},
};
type ApmFeatureFlagMap = typeof apmFeatureFlagMap;

View file

@ -79,7 +79,6 @@ const mockConfig: ConfigSchema = {
migrationToFleetAvailable: true,
sourcemapApiAvailable: true,
storageExplorerAvailable: true,
fastRefreshAvailable: false,
},
serverless: { enabled: false },
};

View file

@ -24,7 +24,6 @@ export interface ConfigSchema {
migrationToFleetAvailable: boolean;
sourcemapApiAvailable: boolean;
storageExplorerAvailable: boolean;
fastRefreshAvailable: boolean;
};
serverless: {
enabled: boolean;

View file

@ -23,15 +23,6 @@ const disabledOnServerless = schema.conditional(
schema.oneOf([schema.literal(true)], { defaultValue: true })
);
const enabledOnServerless = schema.conditional(
schema.contextRef('serverless'),
true,
schema.boolean({
defaultValue: true,
}),
schema.oneOf([schema.literal(false)], { defaultValue: false })
);
// All options should be documented in the APM configuration settings: https://github.com/elastic/kibana/blob/main/docs/settings/apm-settings.asciidoc
// and be included on cloud allow list unless there are specific reasons not to
const configSchema = schema.object({
@ -97,7 +88,6 @@ const configSchema = schema.object({
migrationToFleetAvailable: disabledOnServerless,
sourcemapApiAvailable: disabledOnServerless,
storageExplorerAvailable: disabledOnServerless,
fastRefreshAvailable: enabledOnServerless,
}),
serverless: schema.object({
enabled: schema.conditional(

View file

@ -277,7 +277,6 @@ export class APMPlugin
const logger = this.logger;
const client = core.elasticsearch.client.asInternalUser;
const { featureFlags } = this.currentConfig;
// create .apm-agent-configuration index without blocking start lifecycle
createApmAgentConfigurationIndex({ client, logger }).catch((e) => {
@ -286,7 +285,7 @@ export class APMPlugin
});
// create .apm-custom-link index without blocking start lifecycle
createApmCustomLinkIndex({ client, logger, featureFlags }).catch((e) => {
createApmCustomLinkIndex({ client, logger }).catch((e) => {
logger.error('Failed to create .apm-custom-link index');
logger.error(e);
});

View file

@ -12,29 +12,19 @@ import {
Mappings,
} from '@kbn/observability-plugin/server';
import { APM_CUSTOM_LINK_INDEX } from '../apm_indices/get_apm_indices';
import { ApmFeatureFlags } from '../../../../common/apm_feature_flags';
export const createApmCustomLinkIndex = async ({
client,
logger,
featureFlags,
}: {
client: ElasticsearchClient;
logger: Logger;
featureFlags: ApmFeatureFlags;
}) => {
return createOrUpdateIndex({
index: APM_CUSTOM_LINK_INDEX,
client,
logger,
mappings,
settings: featureFlags.fastRefreshAvailable
? {
index: {
fast_refresh: true,
},
}
: {},
});
};

View file

@ -34,9 +34,9 @@ export function createAnnotationsClient(params: {
const initIndex = () =>
createOrUpdateIndex({
index,
mappings,
client: esClient,
logger,
mappings,
});
function ensureGoldLicense<T extends (...args: any[]) => any>(fn: T): T {

View file

@ -7,23 +7,18 @@
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import pRetry from 'p-retry';
import { Logger, ElasticsearchClient } from '@kbn/core/server';
import { merge } from 'lodash';
export type Mappings = Required<estypes.IndicesCreateRequest>['body']['mappings'] &
Required<estypes.IndicesPutMappingRequest>['body'];
type IndexSettings = Required<estypes.IndicesPutSettingsRequest>['body']['settings'];
export async function createOrUpdateIndex({
index,
mappings,
settings,
client,
logger,
}: {
index: string;
mappings: Mappings;
settings?: IndexSettings;
client: ElasticsearchClient;
logger: Logger;
}) {
@ -49,7 +44,6 @@ export async function createOrUpdateIndex({
index,
client,
mappings,
settings,
});
if (!result.acknowledged) {
@ -70,28 +64,26 @@ export async function createOrUpdateIndex({
}
}
async function createNewIndex({
function createNewIndex({
index,
client,
mappings,
settings,
}: {
index: string;
client: ElasticsearchClient;
mappings: Required<estypes.IndicesCreateRequest>['body']['mappings'];
settings: Required<estypes.IndicesPutSettingsRequest>['body']['settings'];
}) {
return await client.indices.create({
return client.indices.create({
index,
body: {
// auto_expand_replicas: Allows cluster to not have replicas for this index
settings: merge({ index: { auto_expand_replicas: '0-1' } }, settings),
settings: { index: { auto_expand_replicas: '0-1' } },
mappings,
},
});
}
async function updateExistingIndex({
function updateExistingIndex({
index,
client,
mappings,
@ -100,7 +92,7 @@ async function updateExistingIndex({
client: ElasticsearchClient;
mappings: estypes.IndicesPutMappingRequest['body'];
}) {
return await client.indices.putMapping({
return client.indices.putMapping({
index,
body: mappings,
});