-
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
[Reporting] add version to all export types job params #106137
[Reporting] add version to all export types job params #106137
Conversation
Pinging @elastic/kibana-app-services (Team:AppServices) |
Pinging @elastic/kibana-reporting-services (Team:Reporting Services) |
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.
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
logger.debug(`Using SearchSource v${jobParams.version}`); | ||
} else { | ||
logger.warning( | ||
`No version provided for SearchSource version. Assuming ${reporting.getKibanaVersion()}` |
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.
here we should not assume current version but the last version where reports didn't store the version (7.14)
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.
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.
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.
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 |
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.
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 |
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.
worth opening an issue for this, adding a blocker label to it and a version in which the appBasePath will be removed
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.
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>; |
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.
why do we need this additional casting now?
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.
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 & { |
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.
whats the reason for adding DecoratedBaseParams
instead of just adding browserTimezone and version to BaseParams
?
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.
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'; |
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.
was this moved from somewhere ?
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.
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(), |
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.
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
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.
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
@elasticmachine merge upstream |
const { | ||
home, | ||
management, | ||
licensing: { license$ }, | ||
licensing: { license$ }, // FIXME: 'license$' is deprecated |
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.
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.
code LGTM
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Async chunks
Page load bundle
Unknown metric groupsAPI count
API count missing comments
API count with any type
Non-exported public API item count
History
To update your PR or re-run it, just comment with: |
* 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
#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
* 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>
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:
getDecoratedJobParams
to the ReportingAPIClient. This method adds the common fields:version
andbrowserTimezone
to the job params so that the applications do not have to provide those fields in their intergration.browserTimezone
. This was done as part of responding to review feedback: [Reporting] add version to all export types job params #106137 (review)ReportingAPIClient
for all the codeany
and importing mock providersget_csv_panel_action.tsx
to use the common API Client and accessgetDecoratedJobParams
FIXME
comments where my editor hinted at deprecated dependenciesChecklist
Delete any items that are not applicable to this PR.