-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Fleet] Allow snake cased Kibana assets #77515
Conversation
Pinging @elastic/ingest-management (Team:Ingest Management) |
@elasticmachine merge upstream |
Thanks for tackling this! We generate the index patterns If a package now brings an index pattern with the same name, we run into conflicts. I think we should check for these reserved names, and either silently skip them or return an error. @neptunian @ruflin what do you think? |
There are 2 parts here:
It might even possible that we get this one day in the package-spec to disallow it. @ycombinator |
Ok I pushed a new commit that will just not install index-patterns if they are one of the Fleet reserved index patterns. Is there a way to completely bail in the middle of an install and roll back what has already been done? Throwing doesn't appear to work, which is good because the package will still install if there is an error, so not sure how to bail then. |
@crob611 Thanks for the PR! I'm still reviewing but a 👍 overall. The PR description and code are both clear. |
@elasticmachine merge upstream |
export type KibanaAssetReference = Pick<SavedObjectReference, 'id'> & { | ||
type: KibanaAssetType; | ||
}; | ||
export type KibanaAssetReference = Pick<SavedObjectReference, 'id' | 'type'>; |
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.
IIUC, SavedObjectReference['type']
is a string
vs a KibanaAssetType
. I'd like to keep as-is if we can. Was this causing an issue?
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.
@jfsiii KibanaAssetType
is now the type that matches file paths, which do not match to saved object types (index_pattern vs index-pattern).
Maybe we bring the KibanaSavedObjectsType
over into this file from the kibana/install file and use that type instead?
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.
@crob611 I'll re-read but that seems OK. We definitely want a name and type more refined than string
.
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.
@jfsiii OK just pushed a commit that adds a "KibanaSavedObjectType" and uses that type for KibanaAssetReference.
|
||
const resolvedAssets = await Promise.all(assetArrays); | ||
|
||
const result = {} as Record<KibanaAssetType, ArchiveAsset[]>; |
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.
Mind moving Record<KibanaAssetType, ArchiveAsset[]>
to the function return type?
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.
Can we remove the remove the as Record...
, leaving either const result = {}
or
const result = {} as Record<KibanaAssetType, ArchiveAsset[]>; | |
const result: Record<KibanaAssetType, ArchiveAsset[]> = {}; |
cc @neptunian for 👀 |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@neptunian @skh @ruflin any comments on this? I think we want it and I'd like to merge it soon to avoid conflicts with our pending changes. If you are 👍 on it, I'll merge. |
@elasticmachine merge upstream |
Use new `dataTypes` const which replaced `DataType` enum
Remove unused `indexPatternTypes` from outer scope
@crob611 I merged upstream master and fixed/caused some issues. I think it's good now, but I'll keep an eye on it |
fix (?) bad updates from before where new/correct value was used but result wasn't exported
💚 Build SucceededMetrics [docs]async chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
@jfsiii Looks like this is good to go now. You good with me merging and backporting? |
@crob611 I think so. It passes all tests and has been open for comment for some time. Let's merge before the changes @skh, @neptunian and I have begun make this even more challenging to merge. |
* master: (127 commits) [ILM] Fix breadcrumbs (elastic#82594) [UX]Swap env filter with percentile (elastic#82246) Add platform's missing READMEs (elastic#82268) [Discover] Adding uiMetric to track Visualize link click (elastic#82344) [Search] Add used index pattern name to the search agg error field (elastic#82604) improve client-side SO client get pooling (elastic#82603) [Security Solution] Unskips Overview tests (elastic#82459) Embeddables/migrations (elastic#82296) [Enterprise Search] Refactor product server route registrations to their own files/folders (elastic#82663) Moving reinstall function outside of promise.all (elastic#82672) Load choropleth layer correctly (elastic#82628) Master backport elastic#81233 (elastic#82642) [Fleet] Allow snake cased Kibana assets (elastic#77515) Reduce saved objects authorization checks (elastic#82204) [data.search] Add request handler context and asScoped pattern (elastic#80775) [ML] Fixes formatting of fields in index data visualizer (elastic#82593) Usage collector readme (elastic#82548) [Lens] Visualization validation and better error messages (elastic#81439) [ML] Add annotation markers to time series brush area to indicate annotations exist outside of selected range (elastic#81490) chore(NA): install microdnf in UBI docker build only (elastic#82611) ...
This reverts commit 1cd477a.
…" (elastic#82706)" This reverts commit bc05e79.
* master: Revert "[Fleet] Allow snake cased Kibana assets (elastic#77515)" (elastic#82706)
Friendly reminder: Looks like this PR hasn’t been backported yet. |
* Revert "Revert "[Fleet] Allow snake cased Kibana assets (elastic#77515)" (elastic#82706)" This reverts commit bc05e79. * Rename test index pattern
* Revert "Revert "[Fleet] Allow snake cased Kibana assets (#77515)" (#82706)" This reverts commit bc05e79. * Rename test index pattern Co-authored-by: Kibana Machine <[email protected]>
Friendly reminder: Looks like this PR hasn’t been backported yet. |
1 similar comment
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Summary
Closes #71633
This fixes installation of Kibana assets like
index-pattern
whose asset path in a package will be snake casedindex_pattern
.We will now also maintain a
kibanaAssetType
->savedObjectType
mapping. This is to make sure that any assets in an assets/kibana folder have the appropriate saved object type, since we can't just check againstkibanaAssetType
anymore.Finally, a mapping of
kibanaAssetType
->installFunction
. When wegetKibanaAssets
now, we get a map ofkibanaAssetType
->Array<archive>
, so we can act on thekibanaAssetType
. Currently, everything is just a saved object, but this is just setting up for the future in case there comes a time when an asset type is not just a simple saved object install, we can introduce new installer methods relatively easily.I don't think there are any existing packages with
index-pattern
folders, but if there are we will need to make sure that they get updated at the appropriate time. Should we include a fallback to catch those legacy cases?