Skip to content
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

Default to chromium and add deprecation warning for phantom. #21505

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/settings/reporting-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ Defaults to `3000` (3 seconds).
[[xpack-reporting-browser]]`xpack.reporting.capture.browser.type`::
Specifies the browser to use to capture screenshots. Valid options are `phantom`
and `chromium`. When `chromium` is set, the settings specified in the <<reporting-chromium-settings, Chromium settings>>
are respected.
Defaults to `phantom`.
are respected. This setting will be deprecated in 7.0, when Phantom support is removed.
Defaults to `chromium`.


[float]
[[reporting-chromium-settings]]
Expand Down
8 changes: 6 additions & 2 deletions x-pack/plugins/reporting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { config as appConfig } from './server/config/config';
import { checkLicenseFactory } from './server/lib/check_license';
import { validateConfig } from './server/lib/validate_config';
import { exportTypesRegistryFactory } from './server/lib/export_types_registry';
import { createBrowserDriverFactory, getDefaultBrowser, getDefaultChromiumSandboxDisabled } from './server/browsers';
import { PHANTOM, createBrowserDriverFactory, getDefaultBrowser, getDefaultChromiumSandboxDisabled } from './server/browsers';
import { logConfiguration } from './log_configuration';

import { getReportingUsageCollector } from './server/usage';
Expand Down Expand Up @@ -87,7 +87,7 @@ export const reporting = (kibana) => {
settleTime: Joi.number().integer().default(1000), //deprecated
concurrency: Joi.number().integer().default(appConfig.concurrency), //deprecated
browser: Joi.object({
type: Joi.any().valid('phantom', 'chromium').default(await getDefaultBrowser()),
type: Joi.any().valid('phantom', 'chromium').default(await getDefaultBrowser()), // TODO: remove support in 7.0
autoDownload: Joi.boolean().when('$dev', {
is: true,
then: Joi.default(true),
Expand Down Expand Up @@ -145,6 +145,10 @@ export const reporting = (kibana) => {
validateConfig(config, message => server.log(['reporting', 'warning'], message));
logConfiguration(config, message => server.log(['reporting', 'debug'], message));

if (config.get('xpack.reporting.capture.browser.type') === PHANTOM) {
server.log(['reporting', 'warning'], 'Phantom browser type for reporting will be deprecated starting in 7.0');
}

const { xpack_main: xpackMainPlugin } = server.plugins;

mirrorPluginStatus(xpackMainPlugin, this);
Expand Down
8 changes: 8 additions & 0 deletions x-pack/plugins/reporting/server/browsers/browser_types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export const PHANTOM = 'phantom';
export const CHROMIUM = 'chromium';
38 changes: 18 additions & 20 deletions x-pack/plugins/reporting/server/browsers/default_browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,28 @@
* you may not use this file except in compliance with the Elastic License.
*/

// import getosSync from 'getos';
// import { promisify } from 'bluebird';
import getosSync from 'getos';
import { promisify } from 'bluebird';
import { PHANTOM, CHROMIUM } from './browser_types';

// const getos = promisify(getosSync);
const getos = promisify(getosSync);

// Chromium is unsupported on RHEL/CentOS before 7.0
// const distroSupportsChromium = (distro, release) => {
// if (distro.toLowerCase() !== 'centos' && distro.toLowerCase () !== 'red hat linux') {
// return true;
// }
// const releaseNumber = parseInt(release, 10);
// return releaseNumber >= 7.0;
// };
// Chromium is unsupported on RHEL/CentOS before 7.0.
const distroSupportsChromium = (distro, release) => {
if (distro.toLowerCase() !== 'centos' && distro.toLowerCase () !== 'red hat linux') {
return true;
}
const releaseNumber = parseInt(release, 10);
return releaseNumber >= 7;
};


export async function getDefaultBrowser() {
return 'phantom';
const os = await getos();

// TODO: Switch to chromium once all the kinks are worked out
// const os = await getos();
//
// if (os.os === 'linux' && !distroSupportsChromium(os.dist, os.release)) {
// return 'phantom';
// } else {
// return 'chromium';
// }
if (os.os === 'linux' && !distroSupportsChromium(os.dist, os.release)) {
return PHANTOM;
} else {
return CHROMIUM;
}
}
1 change: 1 addition & 0 deletions x-pack/plugins/reporting/server/browsers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export { ensureAllBrowsersDownloaded } from './download';
export { createBrowserDriverFactory } from './create_browser_driver_factory';
export { getDefaultBrowser } from './default_browser';
export { getDefaultChromiumSandboxDisabled } from './default_chromium_sandbox_disabled';
export { PHANTOM, CHROMIUM } from './browser_types';