Skip to content

Commit

Permalink
[APM] Don't show deprecation notice in Kibana Upgrade Assistant for n…
Browse files Browse the repository at this point in the history
…on-apm users (#120945)

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
cauemarcondes and kibanamachine authored Dec 13, 2021
1 parent cbe06ea commit e78156c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
28 changes: 25 additions & 3 deletions x-pack/plugins/apm/server/deprecations/deprecations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ describe('getDeprecations', () => {
});
});

describe('when running on cloud with legacy apm-server', () => {
it('returns deprecations', async () => {
describe('when running on cloud without cloud agent policy', () => {
it('returns no deprecations', async () => {
const deprecationsCallback = getDeprecations({
branch: 'main',
cloudSetup: { isCloudEnabled: true } as unknown as CloudSetup,
Expand All @@ -39,6 +39,28 @@ describe('getDeprecations', () => {
} as unknown as APMRouteHandlerResources['plugins']['fleet'],
});
const deprecations = await deprecationsCallback(deprecationContext);
expect(deprecations).toEqual([]);
});
});

describe('when running on cloud with cloud agent policy and without apm integration', () => {
it('returns deprecations', async () => {
const deprecationsCallback = getDeprecations({
branch: 'main',
cloudSetup: { isCloudEnabled: true } as unknown as CloudSetup,
fleet: {
start: () => ({
agentPolicyService: {
get: () =>
({
id: 'foo',
package_policies: [''],
} as AgentPolicy),
},
}),
} as unknown as APMRouteHandlerResources['plugins']['fleet'],
});
const deprecations = await deprecationsCallback(deprecationContext);
expect(deprecations).not.toEqual([]);
// TODO: remove when docs support "main"
if (kibanaPackageJson.branch === 'main') {
Expand All @@ -50,7 +72,7 @@ describe('getDeprecations', () => {
});
});

describe('when running on cloud with fleet', () => {
describe('when running on cloud with cloud agent policy and apm integration', () => {
it('returns no deprecations', async () => {
const deprecationsCallback = getDeprecations({
branch: 'main',
Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/apm/server/deprecations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export function getDeprecations({
if (!fleet) {
return deprecations;
}
// TODO: remove when docs support "main"
const docBranch = branch === 'main' ? 'master' : branch;

const fleetPluginStart = await fleet.start();
const cloudAgentPolicy = await getCloudAgentPolicy({
Expand All @@ -39,12 +41,10 @@ export function getDeprecations({
});

const isCloudEnabled = !!cloudSetup?.isCloudEnabled;
const hasCloudAgentPolicy = !isEmpty(cloudAgentPolicy);
const hasAPMPackagePolicy = !isEmpty(getApmPackagePolicy(cloudAgentPolicy));

// TODO: remove when docs support "main"
const docBranch = branch === 'main' ? 'master' : branch;

if (isCloudEnabled && !hasAPMPackagePolicy) {
if (isCloudEnabled && hasCloudAgentPolicy && !hasAPMPackagePolicy) {
deprecations.push({
title: i18n.translate('xpack.apm.deprecations.legacyModeTitle', {
defaultMessage: 'APM Server running in legacy mode',
Expand Down

0 comments on commit e78156c

Please sign in to comment.