-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM] Show APM Server stand-alone mode in Kibana Upgrade Assistant (c…
…loud-only) (#113567) (#113778) Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Cauê Marcondes <[email protected]>
- Loading branch information
1 parent
d33e519
commit b47f88a
Showing
3 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
x-pack/plugins/apm/server/deprecations/deprecations.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { GetDeprecationsContext } from '../../../../../src/core/server'; | ||
import { CloudSetup } from '../../../cloud/server'; | ||
import { getDeprecations } from './'; | ||
import { APMRouteHandlerResources } from '../'; | ||
import { AgentPolicy } from '../../../fleet/common'; | ||
|
||
const deprecationContext = { | ||
esClient: {}, | ||
savedObjectsClient: {}, | ||
} as GetDeprecationsContext; | ||
|
||
describe('getDeprecations', () => { | ||
describe('when fleet is disabled', () => { | ||
it('returns no deprecations', async () => { | ||
const deprecationsCallback = getDeprecations({}); | ||
const deprecations = await deprecationsCallback(deprecationContext); | ||
expect(deprecations).toEqual([]); | ||
}); | ||
}); | ||
|
||
describe('when running on cloud with legacy apm-server', () => { | ||
it('returns deprecations', async () => { | ||
const deprecationsCallback = getDeprecations({ | ||
cloudSetup: { isCloudEnabled: true } as unknown as CloudSetup, | ||
fleet: { | ||
start: () => ({ | ||
agentPolicyService: { get: () => undefined }, | ||
}), | ||
} as unknown as APMRouteHandlerResources['plugins']['fleet'], | ||
}); | ||
const deprecations = await deprecationsCallback(deprecationContext); | ||
expect(deprecations).not.toEqual([]); | ||
}); | ||
}); | ||
|
||
describe('when running on cloud with fleet', () => { | ||
it('returns no deprecations', async () => { | ||
const deprecationsCallback = getDeprecations({ | ||
cloudSetup: { isCloudEnabled: true } as unknown as CloudSetup, | ||
fleet: { | ||
start: () => ({ | ||
agentPolicyService: { get: () => ({ id: 'foo' } as AgentPolicy) }, | ||
}), | ||
} as unknown as APMRouteHandlerResources['plugins']['fleet'], | ||
}); | ||
const deprecations = await deprecationsCallback(deprecationContext); | ||
expect(deprecations).toEqual([]); | ||
}); | ||
}); | ||
|
||
describe('when running on prem', () => { | ||
it('returns no deprecations', async () => { | ||
const deprecationsCallback = getDeprecations({ | ||
cloudSetup: { isCloudEnabled: false } as unknown as CloudSetup, | ||
fleet: { | ||
start: () => ({ agentPolicyService: { get: () => undefined } }), | ||
} as unknown as APMRouteHandlerResources['plugins']['fleet'], | ||
}); | ||
const deprecations = await deprecationsCallback(deprecationContext); | ||
expect(deprecations).toEqual([]); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { GetDeprecationsContext, DeprecationsDetails } from 'src/core/server'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { isEmpty } from 'lodash'; | ||
import { CloudSetup } from '../../../cloud/server'; | ||
import { getCloudAgentPolicy } from '../lib/fleet/get_cloud_apm_package_policy'; | ||
import { APMRouteHandlerResources } from '../'; | ||
|
||
export function getDeprecations({ | ||
cloudSetup, | ||
fleet, | ||
}: { | ||
cloudSetup?: CloudSetup; | ||
fleet?: APMRouteHandlerResources['plugins']['fleet']; | ||
}) { | ||
return async ({ | ||
savedObjectsClient, | ||
}: GetDeprecationsContext): Promise<DeprecationsDetails[]> => { | ||
const deprecations: DeprecationsDetails[] = []; | ||
if (!fleet) { | ||
return deprecations; | ||
} | ||
|
||
const fleetPluginStart = await fleet.start(); | ||
const cloudAgentPolicy = await getCloudAgentPolicy({ | ||
fleetPluginStart, | ||
savedObjectsClient, | ||
}); | ||
|
||
const isCloudEnabled = !!cloudSetup?.isCloudEnabled; | ||
|
||
const hasCloudAgentPolicy = !isEmpty(cloudAgentPolicy); | ||
|
||
if (isCloudEnabled && !hasCloudAgentPolicy) { | ||
deprecations.push({ | ||
title: i18n.translate('xpack.apm.deprecations.legacyModeTitle', { | ||
defaultMessage: 'APM Server running in legacy mode', | ||
}), | ||
message: i18n.translate('xpack.apm.deprecations.message', { | ||
defaultMessage: | ||
'Running the APM Server binary directly is considered a legacy option and is deprecated since 7.16. Switch to APM Server managed by an Elastic Agent instead. Read our documentation to learn more.', | ||
}), | ||
documentationUrl: | ||
'https://www.elastic.co/guide/en/apm/server/current/apm-integration.html', | ||
level: 'warning', | ||
correctiveActions: { | ||
manualSteps: [ | ||
i18n.translate('xpack.apm.deprecations.steps.apm', { | ||
defaultMessage: 'Navigate to Observability/APM', | ||
}), | ||
i18n.translate('xpack.apm.deprecations.steps.settings', { | ||
defaultMessage: 'Click on "Settings"', | ||
}), | ||
i18n.translate('xpack.apm.deprecations.steps.schema', { | ||
defaultMessage: 'Select "Schema" tab', | ||
}), | ||
i18n.translate('xpack.apm.deprecations.steps.switch', { | ||
defaultMessage: | ||
'Click "Switch to data streams". You will be guided through the process', | ||
}), | ||
], | ||
}, | ||
}); | ||
} | ||
|
||
return deprecations; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters