-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
add deprecation warning for legacy 3rd party plugins #62401
Changes from 1 commit
d585216
6ce5512
af3bfd3
78c988e
ed81722
74096de
3eb0382
442a9ea
4cfab7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { loggerMock } from '../../logging/logger.mock'; | ||
import { logLegacyThirdPartyPluginDeprecationWarning } from './log_legacy_plugins_warning'; | ||
import { LegacyPluginSpec } from '../types'; | ||
|
||
const createPluginSpec = ({ id, path }: { id: string; path: string }): LegacyPluginSpec => { | ||
return { | ||
getId: () => id, | ||
getExpectedKibanaVersion: () => 'kibana', | ||
getConfigPrefix: () => 'plugin.config', | ||
getDeprecationsProvider: () => undefined, | ||
getPack: () => ({ | ||
getPath: () => path, | ||
}), | ||
}; | ||
}; | ||
|
||
describe('logLegacyThirdPartyPluginDeprecationWarning', () => { | ||
let log: ReturnType<typeof loggerMock.create>; | ||
|
||
beforeEach(() => { | ||
log = loggerMock.create(); | ||
}); | ||
|
||
it('logs warning for third party plugins', () => { | ||
logLegacyThirdPartyPluginDeprecationWarning({ | ||
specs: [createPluginSpec({ id: 'plugin', path: '/some-external-path' })], | ||
log, | ||
}); | ||
expect(log.warn).toHaveBeenCalledTimes(1); | ||
expect(log.warn.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"Some installed third party plugin(s) [plugin] are using the legacy plugin format and will no longer work after version 8.0. Please refer to https://github.com/elastic/kibana/blob/master/docs/migration/migrate_8_0.asciidoc for a list of breaking changes and https://github.com/elastic/kibana/blob/master/src/core/MIGRATION.md for documentation on how to migrate legacy plugins.", | ||
] | ||
`); | ||
}); | ||
|
||
it('lists all the deprecated plugins and only log once', () => { | ||
logLegacyThirdPartyPluginDeprecationWarning({ | ||
specs: [ | ||
createPluginSpec({ id: 'pluginA', path: '/abs/path/to/pluginA' }), | ||
createPluginSpec({ id: 'pluginB', path: '/abs/path/to/pluginB' }), | ||
createPluginSpec({ id: 'pluginC', path: '/abs/path/to/pluginC' }), | ||
], | ||
log, | ||
}); | ||
expect(log.warn).toHaveBeenCalledTimes(1); | ||
expect(log.warn.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"Some installed third party plugin(s) [pluginA, pluginB, pluginC] are using the legacy plugin format and will no longer work after version 8.0. Please refer to https://github.com/elastic/kibana/blob/master/docs/migration/migrate_8_0.asciidoc for a list of breaking changes and https://github.com/elastic/kibana/blob/master/src/core/MIGRATION.md for documentation on how to migrate legacy plugins.", | ||
] | ||
`); | ||
}); | ||
|
||
it('does not log warning for internal legacy plugins', () => { | ||
logLegacyThirdPartyPluginDeprecationWarning({ | ||
specs: [ | ||
createPluginSpec({ | ||
id: 'plugin', | ||
path: '/absolute/path/to/kibana/src/legacy/core_plugins', | ||
}), | ||
createPluginSpec({ | ||
id: 'plugin', | ||
path: '/absolute/path/to/kibana/x-pack', | ||
}), | ||
], | ||
log, | ||
}); | ||
|
||
expect(log.warn).not.toHaveBeenCalled(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,52 @@ | ||||||||||||||||
/* | ||||||||||||||||
* Licensed to Elasticsearch B.V. under one or more contributor | ||||||||||||||||
* license agreements. See the NOTICE file distributed with | ||||||||||||||||
* this work for additional information regarding copyright | ||||||||||||||||
* ownership. Elasticsearch B.V. licenses this file to you under | ||||||||||||||||
* the Apache License, Version 2.0 (the "License"); you may | ||||||||||||||||
* not use this file except in compliance with the License. | ||||||||||||||||
* You may obtain a copy of the License at | ||||||||||||||||
* | ||||||||||||||||
* http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||
* | ||||||||||||||||
* Unless required by applicable law or agreed to in writing, | ||||||||||||||||
* software distributed under the License is distributed on an | ||||||||||||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||||||||||||||
* KIND, either express or implied. See the License for the | ||||||||||||||||
* specific language governing permissions and limitations | ||||||||||||||||
* under the License. | ||||||||||||||||
*/ | ||||||||||||||||
|
||||||||||||||||
import { Logger } from '../../logging'; | ||||||||||||||||
import { LegacyPluginSpec } from '../types'; | ||||||||||||||||
|
||||||||||||||||
const internalPaths = ['/src/legacy/core_plugins', '/x-pack']; | ||||||||||||||||
|
||||||||||||||||
const breakingChangesUrl = | ||||||||||||||||
'https://github.com/elastic/kibana/blob/master/docs/migration/migrate_8_0.asciidoc'; | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's use the actual published doc page: https://www.elastic.co/guide/en/kibana/master/breaking-changes-8.0.html |
||||||||||||||||
const migrationGuideUrl = 'https://github.com/elastic/kibana/blob/master/src/core/MIGRATION.md'; | ||||||||||||||||
|
||||||||||||||||
export const logLegacyThirdPartyPluginDeprecationWarning = ({ | ||||||||||||||||
specs, | ||||||||||||||||
log, | ||||||||||||||||
}: { | ||||||||||||||||
specs: LegacyPluginSpec[]; | ||||||||||||||||
log: Logger; | ||||||||||||||||
}) => { | ||||||||||||||||
const thirdPartySpecs = specs.filter(isThirdPartyPluginSpec); | ||||||||||||||||
if (thirdPartySpecs.length > 0) { | ||||||||||||||||
const pluginIds = thirdPartySpecs.map(spec => spec.getId()); | ||||||||||||||||
log.warn( | ||||||||||||||||
`Some installed third party plugin(s) [${pluginIds.join( | ||||||||||||||||
', ' | ||||||||||||||||
)}] are using the legacy plugin format and will no longer work after version 8.0. ` + | ||||||||||||||||
`Please refer to ${breakingChangesUrl} for a list of breaking changes ` + | ||||||||||||||||
`and ${migrationGuideUrl} for documentation on how to migrate legacy plugins.` | ||||||||||||||||
); | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that we want to add link to documentation and that cause the message to be quite big, I thought only logging the warning once with all the plugin ids was better. Input welcome on the actual message. Are these two links enough, or do you see any to add? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should state There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally we would know which version we plan to drop support at, but realistically I guess this is a reasonable change to protect us. Will do. Apart from that, do you see anything to change/add in the message? |
||||||||||||||||
} | ||||||||||||||||
}; | ||||||||||||||||
|
||||||||||||||||
const isThirdPartyPluginSpec = (spec: LegacyPluginSpec): boolean => { | ||||||||||||||||
const pluginPath = spec.getPack().getPath(); | ||||||||||||||||
return !internalPaths.some(internalPath => pluginPath.indexOf(internalPath) > -1); | ||||||||||||||||
}; | ||||||||||||||||
Comment on lines
+49
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, this is not the most solid piece of software I ever crafted, but as Tell me if we think this is not sufficient and if this should be improved. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could probably get around using kbnDevUtils by simply doing: const rootPath = Path.resolve(Path.join(__dirname, '..', '..', '..', '..', '..')) Also we may want to make the xpack path more specific There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
TBH, I'm not a big fan of relative resolves, as they are imho very fragile to refactoring. If we think this detection implementation is not good enough, I would maybe lean to still use
That would be great, except there is technically only ONE xpack Lines 36 to 42 in 982c0da
We don't have any information on the plugins this pack loads. I can change the xpack check to a regexp check to WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good point on the brittleness of refactoring. Though it's unlikely we'll refactor or move any of this legacy code in the near future, let's not create this situation if avoidable. My main reason for not using Given those two points, let's just keep what you have.
I forgot about the x-pack mega plugin pattern in legacy. I'm leaning towards just leaving as-is. There is only one plugin in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can use const { fromRoot } = require('../../core/server/utils');
fromRoot() to get absolute path to the root
Why we cannot reach out their codeowners directly? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I also check for disabled plugins (
disabledPluginSpecs
) ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want plugin authors to update their code. They don't disable their plugins likely.