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

[Reporting/Cloud] Soft disable reporting functionality on 1GB Kibanas #130651

Merged
merged 52 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
a07bee0
added callout about reporting on cloud
jloleysens Apr 12, 2022
e9a4c0c
slight rewording
jloleysens Apr 12, 2022
9eb4995
added functionality to disbale screenshotting on <2GB cloud instances
jloleysens Apr 12, 2022
de83c1f
added test and fixed public facing API to throw an observable error i…
jloleysens Apr 12, 2022
8b738e6
update reporting integration with new screenshotting error
jloleysens Apr 12, 2022
d8cbaf1
fix typo
jloleysens Apr 12, 2022
43e19dc
added specific error code to telemetry
jloleysens Apr 13, 2022
1e04b41
added positive test case
jloleysens Apr 13, 2022
26b64f9
Merge branch 'main' of github.com:elastic/kibana into reporting/soft-…
jloleysens Apr 13, 2022
3a5e1fe
updated mappings
jloleysens Apr 13, 2022
0ca062b
update jest test snapshots
jloleysens Apr 13, 2022
a0cfd75
update snapshot
jloleysens Apr 13, 2022
1027ed1
fix use of deprecated RxJS
jloleysens Apr 13, 2022
3878865
[revert this] added some logs for cloud
jloleysens Apr 13, 2022
67f3a91
also check for deploymentId
jloleysens Apr 14, 2022
9f5f60c
remove logs
jloleysens Apr 14, 2022
f6f5d46
Merge branch 'main' into reporting/soft-disable-server-side
kibanamachine Apr 14, 2022
03dbd84
removed logger being passed to system check function
jloleysens Apr 14, 2022
43cdce7
remove unused import
jloleysens Apr 14, 2022
83ebe1a
slight update to test
jloleysens Apr 14, 2022
1b7c5fb
added cloud min requirements link
jloleysens Apr 14, 2022
cd13819
add link to UI
jloleysens Apr 14, 2022
9a657f4
Merge branch 'main' of github.com:elastic/kibana into reporting/soft-…
jloleysens Apr 19, 2022
c642918
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Apr 19, 2022
a9f37f3
added todo comment
jloleysens Apr 14, 2022
ed5edf4
Merge branch 'main' into reporting/soft-disable-server-side
kibanamachine Apr 19, 2022
294873c
read mem limit from cgroup files
jloleysens Apr 19, 2022
53e4214
Merge branch 'main' into reporting/soft-disable-server-side
kibanamachine Apr 20, 2022
06f68a5
update jest
jloleysens Apr 20, 2022
94ae13e
tidy up and simplify some of the logic
jloleysens Apr 20, 2022
7d0487e
Merge branch 'main' into reportings/soft-disable
kibanamachine Apr 20, 2022
7ae3e39
[revert this] test with 1024
jloleysens Apr 20, 2022
d21e808
[revert this] added some logging again
jloleysens Apr 20, 2022
0dc497b
actually pass the cloud plugin to Screenshots :facepalm:
jloleysens Apr 20, 2022
ebdea21
[revert this] try and read instance data file instead
jloleysens Apr 21, 2022
2106f8e
Merge branch 'main' into reportings/soft-disable
kibanamachine Apr 21, 2022
5a5a9af
Revert "[revert this] try and read instance data file instead"
jloleysens Apr 21, 2022
a3ff5f6
Revert "[revert this] test with 1024"
jloleysens Apr 21, 2022
fc8bfc9
Revert "[revert this] added some logging again"
jloleysens Apr 21, 2022
6912d74
use injected environment variable to read instance size
jloleysens Apr 22, 2022
989485f
implement copy feedback
jloleysens Apr 22, 2022
bc17921
fix variable rename
jloleysens Apr 22, 2022
554a471
fix test
jloleysens Apr 22, 2022
ca7d907
fixed some copy
jloleysens Apr 22, 2022
866baa6
fix test code
jloleysens Apr 22, 2022
fe35f0c
remove unused i18n
jloleysens Apr 22, 2022
42e48f2
update snapshots
jloleysens Apr 22, 2022
d45a03e
Merge branch 'main' into reportings/soft-disable
kibanamachine Apr 25, 2022
acf924c
minor tidying up
jloleysens Apr 25, 2022
60d09e7
Merge branch 'main' into reportings/soft-disable
kibanamachine Apr 25, 2022
d206f67
Merge branch 'main' into reportings/soft-disable
kibanamachine Apr 28, 2022
5eb59e1
tighten up the copy
jloleysens Apr 28, 2022
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
3 changes: 3 additions & 0 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
monitorLogstash: `${ELASTIC_WEBSITE_URL}guide/en/logstash/${DOC_LINK_VERSION}/monitoring-with-metricbeat.html`,
troubleshootKibana: `${KIBANA_DOCS}monitor-troubleshooting.html`,
},
reporting: {
cloudMinimumRequirements: `${KIBANA_DOCS}reporting-getting-started.html#reporting-on-cloud-resource-requirements`,
},
security: {
apiKeyServiceSettings: `${ELASTICSEARCH_DOCS}security-settings.html#api-key-service-settings`,
clusterPrivileges: `${ELASTICSEARCH_DOCS}security-privileges.html#privileges-list-cluster`,
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ export interface DocLinks {
gdalTutorial: string;
}>;
readonly monitoring: Record<string, string>;
readonly reporting: Readonly<{
cloudMinimumRequirements: string;
}>;
readonly security: Readonly<{
apiKeyServiceSettings: string;
clusterPrivileges: string;
Expand Down
15 changes: 15 additions & 0 deletions x-pack/plugins/cloud/server/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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.
*/

// Best effort to get instance size from process.env
export function readInstanceSizeMb(): undefined | number {
const capacityString = process.env.CLOUD_KIBANA_CAPACITY;
if (capacityString) {
const instanceSizeMb = parseInt(capacityString, 10);
return isNaN(instanceSizeMb) ? undefined : instanceSizeMb;
}
}
5 changes: 4 additions & 1 deletion x-pack/plugins/cloud/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { getIsCloudEnabled } from '../common/is_cloud_enabled';
import { parseDeploymentIdFromDeploymentUrl } from './utils';
import { registerFullstoryRoute } from './routes/fullstory';
import { registerChatRoute } from './routes/chat';
import { readInstanceSizeMb } from './env';

interface PluginsSetup {
usageCollection?: UsageCollectionSetup;
Expand All @@ -24,6 +25,7 @@ export interface CloudSetup {
cloudId?: string;
deploymentId?: string;
isCloudEnabled: boolean;
instanceSizeMb?: number;
apm: {
url?: string;
secretToken?: string;
Expand All @@ -41,7 +43,7 @@ export class CloudPlugin implements Plugin<CloudSetup> {
this.isDev = this.context.env.mode.dev;
}

public setup(core: CoreSetup, { usageCollection, security }: PluginsSetup) {
public setup(core: CoreSetup, { usageCollection, security }: PluginsSetup): CloudSetup {
this.logger.debug('Setting up Cloud plugin');
const isCloudEnabled = getIsCloudEnabled(this.config.id);
registerCloudUsageCollector(usageCollection, { isCloudEnabled });
Expand All @@ -64,6 +66,7 @@ export class CloudPlugin implements Plugin<CloudSetup> {

return {
cloudId: this.config.id,
instanceSizeMb: readInstanceSizeMb(),
deploymentId: parseDeploymentIdFromDeploymentUrl(this.config.deployment_url),
isCloudEnabled,
apm: {
Expand Down
14 changes: 10 additions & 4 deletions x-pack/plugins/reporting/common/errors/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

import * as errors from '.';

describe('ReportingError', () => {
const { ReportingError: _, ...nonAbstractErrors } = errors;

describe('Reporting error', () => {
it('provides error code when stringified', () => {
expect(new errors.AuthenticationExpiredError() + '').toBe(
`ReportingError(code: authentication_expired_error)`
Expand All @@ -18,10 +20,14 @@ describe('ReportingError', () => {
`ReportingError(code: authentication_expired_error) "some details"`
);
});
it('has the expected code structure', () => {
const { ReportingError: _, ...nonAbstractErrors } = errors;
it('has the expected error code structure', () => {
Object.values(nonAbstractErrors).forEach((Ctor) => {
expect(Ctor.code).toMatch(/^[a-z_]+_error$/);
});
});
it('has the same error code values on static "code" and instance "code" properties', () => {
Object.values(nonAbstractErrors).forEach((Ctor) => {
expect(new Ctor().code).toMatch(/^[a-z_]+_error$/);
expect(Ctor.code).toBe(new Ctor().code);
});
});
});
62 changes: 53 additions & 9 deletions x-pack/plugins/reporting/common/errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export abstract class ReportingError extends Error {
*
* @note Convention for codes: lower-case, snake-case and end in `_error`.
*/
public abstract code: string;
public abstract get code(): string;

constructor(public details?: string) {
super();
Expand All @@ -38,22 +38,34 @@ export abstract class ReportingError extends Error {
* access token expired.
*/
export class AuthenticationExpiredError extends ReportingError {
code = 'authentication_expired_error';
static code = 'authentication_expired_error' as const;
public get code(): string {
return AuthenticationExpiredError.code;
}
}

export class QueueTimeoutError extends ReportingError {
code = 'queue_timeout_error';
static code = 'queue_timeout_error' as const;
public get code(): string {
return QueueTimeoutError.code;
}
}

/**
* An unknown error has occurred. See details.
*/
export class UnknownError extends ReportingError {
code = 'unknown_error';
static code = 'unknown_error' as const;
public get code(): string {
return UnknownError.code;
}
}

export class PdfWorkerOutOfMemoryError extends ReportingError {
code = 'pdf_worker_out_of_memory_error';
static code = 'pdf_worker_out_of_memory_error' as const;
public get code(): string {
return PdfWorkerOutOfMemoryError.code;
}

details = i18n.translate('xpack.reporting.common.pdfWorkerOutOfMemoryErrorMessage', {
defaultMessage:
Expand All @@ -70,7 +82,10 @@ export class PdfWorkerOutOfMemoryError extends ReportingError {
}

export class BrowserCouldNotLaunchError extends ReportingError {
code = 'browser_could_not_launch_error';
static code = 'browser_could_not_launch_error' as const;
public get code(): string {
return BrowserCouldNotLaunchError.code;
}

details = i18n.translate('xpack.reporting.common.browserCouldNotLaunchErrorMessage', {
defaultMessage: 'Cannot generate screenshots because the browser did not launch.',
Expand All @@ -86,13 +101,42 @@ export class BrowserCouldNotLaunchError extends ReportingError {
}

export class BrowserUnexpectedlyClosedError extends ReportingError {
code = 'browser_unexpectedly_closed_error';
static code = 'browser_unexpectedly_closed_error' as const;
public get code(): string {
return BrowserUnexpectedlyClosedError.code;
}
}

export class BrowserScreenshotError extends ReportingError {
code = 'browser_screenshot_error';
static code = 'browser_screenshot_error' as const;
public get code(): string {
return BrowserScreenshotError.code;
}
}

export class KibanaShuttingDownError extends ReportingError {
code = 'kibana_shutting_down_error';
static code = 'kibana_shutting_down_error' as const;
public get code(): string {
return KibanaShuttingDownError.code;
}
}

/**
* Special error case that should only occur on Cloud when trying to generate
* a report on a Kibana instance that is too small to be running Chromium.
*/
export class VisualReportingSoftDisabledError extends ReportingError {
static code = 'visual_reporting_soft_disabled_error' as const;
public get code(): string {
return VisualReportingSoftDisabledError.code;
}

details = i18n.translate('xpack.reporting.common.cloud.insufficientSystemMemoryError', {
defaultMessage:
'This report cannot be generated because Kibana does not have sufficient memory.',
});

public override get message() {
return this.details;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
BrowserUnexpectedlyClosedError,
BrowserScreenshotError,
PdfWorkerOutOfMemoryError,
VisualReportingSoftDisabledError,
} from '.';

export function mapToReportingError(error: unknown): ReportingError {
Expand All @@ -28,6 +29,8 @@ export function mapToReportingError(error: unknown): ReportingError {
return new BrowserCouldNotLaunchError();
case error instanceof errors.PdfWorkerOutOfMemoryError:
return new PdfWorkerOutOfMemoryError();
case error instanceof errors.InsufficientMemoryAvailableOnCloudError:
return new VisualReportingSoftDisabledError();
}
return new UnknownError();
}
1 change: 1 addition & 0 deletions x-pack/plugins/reporting/common/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export interface JobSummary {
status: JobStatus;
jobtype: ReportSource['jobtype'];
title: ReportSource['payload']['title'];
errorCode?: ReportOutput['error_code'];
maxSizeReached: TaskRunResult['max_size_reached'];
csvContainsFormulas: TaskRunResult['csv_contains_formulas'];
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions x-pack/plugins/reporting/public/lib/job.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export class Job {

public locatorParams?: BaseParamsV2['locatorParams'];

public error_code?: ReportOutput['error_code'];

constructor(report: ReportApiJSON) {
this.id = report.id;
this.index = report.index;
Expand Down Expand Up @@ -90,6 +92,7 @@ export class Job {
this.csv_contains_formulas = report.output?.csv_contains_formulas;
this.max_size_reached = report.output?.max_size_reached;
this.warnings = report.output?.warnings;
this.error_code = report.output?.error_code;
this.locatorParams = (report.payload as BaseParamsV2).locatorParams;
this.metrics = report.metrics;
}
Expand Down
Loading