-
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] Use updated saved object resolver #113641
Conversation
3c8b2dc
to
0763c9f
Compare
@@ -21,10 +21,12 @@ export const createJobFnFactory: CreateJobFnFactory< | |||
); | |||
|
|||
const savedObjectsClient = context.core.savedObjects.client; | |||
const indexPatternSavedObject = (await savedObjectsClient.get( | |||
const { | |||
saved_object: { attributes: indexPatternSavedObject }, |
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.
you should check if you got the object
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.
what happens if you request an object which doesnt exist, or if you get into conflict
scenario? https://www.elastic.co/guide/en/kibana/master/sharing-saved-objects.html#sharing-saved-objects-step-3
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.
@@ -21,10 +21,12 @@ export const createJobFnFactory: CreateJobFnFactory< | |||
); | |||
|
|||
const savedObjectsClient = context.core.savedObjects.client; |
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.
actually, we shouldnt be using saved objects client here. we should use data.indexPatterns service. can you please update that ?
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.
The problem is that the context.core
is a setup contract that doesn't have the data plugin instance. I can work that around, but this is a deprecated job type that should be removed in 8.0. And the issue is labeled as v8.0.0
only. Fixing that here will produce extra work with removing that later without any impact on the final result.
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.
ok if we are removing this in 8.0 then its ok. (cc @tsullivan are we sure its gonna get removed in 8.0?)
the problem with this approach is that you need to know internals of data views (index patterns), like how are they stored etc. Any change on index patterns will break your logic and its hard to detect that. Saved objects should be loaded only by their owners and nobody else.
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.
export_types/csv
is not being removed in 8.0. The code isn't accessible through the UI, but we know from telemetry data that users are still generating these exports using automation that was set up in an older version. So we don't want their automation to immediately break once they upgrade. Once the removal won't affect many users we will do it.
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.
Alright, then I guess we should use the data plugin here instead. And correct the warning saying that it will be removed in 8.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.
@ppisljar @tsullivan I've updated the factory to reuse the data plugin. Could you please take another look?
0e3dfd1
to
1829cf2
Compare
|
||
return { | ||
isDeprecated: true, | ||
indexPatternSavedObject, | ||
indexPatternSavedObject: omitBy( |
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 not just pass dataView in ?
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 am afraid that's not going to work. We put it here to serialize and deserialize that later.
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.
you should only store data view id then, and load it again later using data view apis
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 makes total sense, thanks. I've fixed that.
const fieldFormatMap = JSON.parse(indexPatternSavedObject.attributes.fieldFormatMap); | ||
Object.keys(fieldFormatMap).forEach((fieldName) => { | ||
const formatConfig: FieldFormatConfig = fieldFormatMap[fieldName]; | ||
if (_.has(indexPatternSavedObject, 'fieldFormatMap')) { |
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 whole function is pretty much constructing what's already available on data views.
if you don't convert dataview to your indexPatternSavedObject
(which you shouldn't) then you can just use
dataView.fieldFormatMap
or even better use provided functions on the dataview:
dataview.getFormatterForField(field)
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.
That comes from the ES document as a plain object. In the job factory, I tried to gather all the data we used previously and store that in a similar way.
@elasticmachine merge upstream |
2b925c2
to
8e2d47e
Compare
…eprecated CSV export type
8e2d47e
to
07cee74
Compare
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Public APIs missing comments
History
To update your PR or re-run it, just comment with: |
I just wanted to check on the status of this, it's blocking #114408 |
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
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.
LGTM
* Update deprecated PDF job factory to use updated saved object resolver * Reuse data plugin service to gather index pattern attributes in the deprecated CSV export type
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Summary
Resolves #112565.
Checklist