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] add version to all export types job params #106137

Merged

Conversation

tsullivan
Copy link
Member

@tsullivan tsullivan commented Jul 19, 2021

Summary

This PR adds a version field to the BaseParams interface that is extended by job params of all export types. This field is to allow future compatibility of automated reports.

Closes #104508

Other changes:

  • Adds getDecoratedJobParams to the ReportingAPIClient. This method adds the common fields: version and browserTimezone to the job params so that the applications do not have to provide those fields in their intergration.
    • This removes code that was repeated in a lot of places
  • Simplifies the API surface by not requiring the apps to provide browserTimezone. This was done as part of responding to review feedback: [Reporting] add version to all export types job params #106137 (review)
  • Simplifies internal Reporting UI code by only instantiating a single ReportingAPIClient for all the code
  • Cleaned up unused dependencies in the Reporting example app
  • Improved tests by removing some any and importing mock providers
  • Updated get_csv_panel_action.tsx to use the common API Client and access getDecoratedJobParams
  • Added FIXME comments where my editor hinted at deprecated dependencies
  • Adds unit tests for verifying POST URL is correct, and is automatically decorated with version and browserTimezone

Checklist

Delete any items that are not applicable to this PR.

@tsullivan tsullivan changed the title add version to csv params [Reporting] add version to csv_searchsource params Jul 19, 2021
@tsullivan tsullivan requested review from jloleysens, dokmic and a team July 19, 2021 17:36
@tsullivan tsullivan added release_note:skip Skip the PR/issue when compiling release notes Team:AppServices v7.15.0 v8.0.0 labels Jul 19, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServices)

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-reporting-services (Team:Reporting Services)

@tsullivan tsullivan added the technical debt Improvement of the software architecture and operational architecture label Jul 19, 2021
Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we shouldn't store csv searchsource version, but just general kibana version at which report was generated. any report will run into this problem as we are not using saved objects (if we will that would be handled for us) and possibly we'll need to run migrations.

searchsource also needs to implement persistable state service interface so we will be able to call migrations on it.

this should be done before 8.0 to prepare for saved object ids change

@tsullivan
Copy link
Member Author

@ppisljar thanks for the feedback. I have added commit de232ba to use the kibana version from packageInfo on the plugin init context.

@tsullivan tsullivan requested a review from ppisljar July 20, 2021 19:46
logger.debug(`Using SearchSource v${jobParams.version}`);
} else {
logger.warning(
`No version provided for SearchSource version. Assuming ${reporting.getKibanaVersion()}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we should not assume current version but the last version where reports didn't store the version (7.14)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ppisljar is it essential to drop the .0 from the version string? Currently I am sticking it on just as-is from context.env.packageInfo.version, which looks like 8.0.0 and 7.14.0, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think that's fine. better more than less :D

@@ -11,7 +11,8 @@ import type { BaseParams, BasePayload } from '../../types';
export type RawValue = string | object | null | undefined;

interface BaseParamsCSV {
browserTimezone: string;
browserTimezone: string; // used for formatting timestamps
version: string; // version of the last supported release in case it needs migration for forward-compatibility
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we rather put this on Report options and store it for every report type (inside enqueueJob?) and then make sure its sent over from client to server inside reporting_api_client createReportJob ?

i think we can make this a general implementation for all report types and its going to be simpler.

@@ -14,7 +14,7 @@ import { ReportingExampleApp } from './components/app';
export const renderApp = (
coreStart: CoreStart,
deps: Omit<StartDeps & SetupDeps, 'developerExamples'>,
{ appBasePath, element }: AppMountParameters
{ appBasePath, element }: AppMountParameters // FIXME: appBasePath is deprecated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth opening an issue for this, adding a blocker label to it and a version in which the appBasePath will be removed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public getReportingJobPath(exportType: string, jobParams: JobParams) {
const params = stringify({ jobParams: rison.encode(jobParams) });
public getReportingJobPath(exportType: string, jobParams: BaseParams) {
const risonObject: RisonObject = jobParams as Record<string, any>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this additional casting now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty much moving the casting down from the local type which was removed: interface JobParams

* Job Params are defined by the application, and on the client side, are decorated by the Reporting service.
* These are required for handling additional formatting or state migrations
*/
export type DecoratedBaseParams = BaseParams & {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the reason for adding DecoratedBaseParams instead of just adding browserTimezone and version to BaseParams ?

Copy link
Member Author

@tsullivan tsullivan Jul 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allowed the getJobParams functions of the various apps to be correctly typed in saying they return BaseParams.

Reporting has still has trouble spots in the code where apps can not really import the correct type that they want to, because those types are restricted to the reporting code, on the server side. It makes sense to focus on these issues later.

I've undone the addition of DecoratedBaseParams: 300ba45

* 2.0.
*/

import * as Rx from 'rxjs';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this moved from somewhere ?

Copy link
Member Author

@tsullivan tsullivan Jul 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These types were moved here from share_context_menu/register_csv_reporting.tsx and share_context_menu/register_pdf_png_reporting.tsx, to remove a lot of duplicated imports.

const job = {
objectType: 'immediate-search',
version: reporting.getKibanaVersion(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to provide the version here ? from my understanding:

  • version is provided from the client side (in the generate report url or when clicking the generate report in ui)
  • server checks if version is provided and if not fallbacks to 7.14.0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was because the job object gets passed directly to GenerateCSV, since this is an "immediate download" export - not a queued job. which had the parameter typed as JobParamsCSV and therefore needed the version.

This can be simplified by adding Omit<> around the type in the parameter: 300ba45

@tsullivan
Copy link
Member Author

@elasticmachine merge upstream

const {
home,
management,
licensing: { license$ },
licensing: { license$ }, // FIXME: 'license$' is deprecated
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code LGTM

@tsullivan
Copy link
Member Author

@elasticmachine merge upstream

@tsullivan tsullivan enabled auto-merge (squash) August 2, 2021 16:11
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
canvas 1.5MB 1.5MB -75.0B
reporting 68.4KB 68.3KB -157.0B
total -232.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
reporting 64.7KB 65.0KB +323.0B
Unknown metric groups

API count

id before after diff
reporting 133 140 +7

API count missing comments

id before after diff
reporting 132 139 +7

API count with any type

id before after diff
reporting 1 0 -1

Non-exported public API item count

id before after diff
reporting 14 15 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@tsullivan tsullivan merged commit 5e8b242 into elastic:master Aug 2, 2021
tsullivan added a commit to tsullivan/kibana that referenced this pull request Aug 2, 2021
* add version to csv params

* fix ts

* fix api tests

* use kibana version from packageInfo

* use kibana version from packageInfo

* clean up ide warnings

* utility to log and set a default params version

* fix baseparams ts

* update snapshot

* check version in enqueue job

* add temporary ts-ignore for canvas

* clarify comment

* fix hardcoded version in png_pdf_panel

* clarify the UNVERSIONED_VERSION variable with a comment

* fix canvas jest test

* fix ts in example app

* fix types

* send version param to canvas util for job params

* update jest snapshot

* Update utils.test.ts

* fix snapshot

* remove browserTimezone and version from integration boilerplate

* wip ensure version is always populated in job params inside of the service

* wip2

* wip3

* wip4

* wip5

* wip6

* update note

* update example plugin

* wip7

* improve tests

* fix dynamic job params

* better testing

* improve enqueue_job test

* more tests

* fix types

* fix types

* fix example ts

* simplify props

* fix test

* --wip-- [skip ci]

* consolidate baseparams back into one interface

* fix rison encoding of apiClient param

* clean up

* reorganize imports

* back out functional change

* fix 400 error in download csv

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
# Conflicts:
#	x-pack/plugins/reporting/common/types.ts
#	x-pack/plugins/reporting/public/share_context_menu/screen_capture_panel_content.tsx
#	x-pack/plugins/reporting/server/export_types/printable_pdf/create_job/index.ts
@tsullivan tsullivan deleted the reporting/csv-searchsource-version-param branch August 2, 2021 19:37
tsullivan added a commit that referenced this pull request Aug 3, 2021
#107448)

* [Reporting] add version to all export types job params (#106137)

* add version to csv params

* fix ts

* fix api tests

* use kibana version from packageInfo

* use kibana version from packageInfo

* clean up ide warnings

* utility to log and set a default params version

* fix baseparams ts

* update snapshot

* check version in enqueue job

* add temporary ts-ignore for canvas

* clarify comment

* fix hardcoded version in png_pdf_panel

* clarify the UNVERSIONED_VERSION variable with a comment

* fix canvas jest test

* fix ts in example app

* fix types

* send version param to canvas util for job params

* update jest snapshot

* Update utils.test.ts

* fix snapshot

* remove browserTimezone and version from integration boilerplate

* wip ensure version is always populated in job params inside of the service

* wip2

* wip3

* wip4

* wip5

* wip6

* update note

* update example plugin

* wip7

* improve tests

* fix dynamic job params

* better testing

* improve enqueue_job test

* more tests

* fix types

* fix types

* fix example ts

* simplify props

* fix test

* --wip-- [skip ci]

* consolidate baseparams back into one interface

* fix rison encoding of apiClient param

* clean up

* reorganize imports

* back out functional change

* fix 400 error in download csv

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
# Conflicts:
#	x-pack/plugins/reporting/common/types.ts
#	x-pack/plugins/reporting/public/share_context_menu/screen_capture_panel_content.tsx
#	x-pack/plugins/reporting/server/export_types/printable_pdf/create_job/index.ts

* fix 7.x
streamich pushed a commit to vadimkibana/kibana that referenced this pull request Aug 8, 2021
* add version to csv params

* fix ts

* fix api tests

* use kibana version from packageInfo

* use kibana version from packageInfo

* clean up ide warnings

* utility to log and set a default params version

* fix baseparams ts

* update snapshot

* check version in enqueue job

* add temporary ts-ignore for canvas

* clarify comment

* fix hardcoded version in png_pdf_panel

* clarify the UNVERSIONED_VERSION variable with a comment

* fix canvas jest test

* fix ts in example app

* fix types

* send version param to canvas util for job params

* update jest snapshot

* Update utils.test.ts

* fix snapshot

* remove browserTimezone and version from integration boilerplate

* wip ensure version is always populated in job params inside of the service

* wip2

* wip3

* wip4

* wip5

* wip6

* update note

* update example plugin

* wip7

* improve tests

* fix dynamic job params

* better testing

* improve enqueue_job test

* more tests

* fix types

* fix types

* fix example ts

* simplify props

* fix test

* --wip-- [skip ci]

* consolidate baseparams back into one interface

* fix rison encoding of apiClient param

* clean up

* reorganize imports

* back out functional change

* fix 400 error in download csv

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@sophiec20 sophiec20 added the (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead release_note:skip Skip the PR/issue when compiling release notes technical debt Improvement of the software architecture and operational architecture v7.15.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Reporting] Add version string to csv_searchsource reporting job parameters
8 participants