-
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
[Ingest Manager] Better handling of package installation problems #66541
Changes from all commits
85398b7
3b5926a
dcf36dc
0092b2f
d6b4c49
9ff1e60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import Boom from 'boom'; | ||
import { Dataset, RegistryPackage, ElasticsearchAssetType, TemplateRef } from '../../../../types'; | ||
import { CallESAsCurrentUser } from '../../../../types'; | ||
import { Field, loadFieldsFromYaml, processFields } from '../../fields/field'; | ||
|
@@ -20,8 +21,8 @@ export const installTemplates = async ( | |
// install any pre-built index template assets, | ||
// atm, this is only the base package's global index templates | ||
// Install component templates first, as they are used by the index templates | ||
installPreBuiltComponentTemplates(pkgName, pkgVersion, callCluster); | ||
installPreBuiltTemplates(pkgName, pkgVersion, callCluster); | ||
await installPreBuiltComponentTemplates(pkgName, pkgVersion, callCluster); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we do this two operation concurently inside a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The second depends on the first being completed, so we can't do them concurrently. |
||
await installPreBuiltTemplates(pkgName, pkgVersion, callCluster); | ||
|
||
// build templates per dataset from yml files | ||
const datasets = registryPackage.datasets; | ||
|
@@ -53,16 +54,7 @@ const installPreBuiltTemplates = async ( | |
pkgVersion, | ||
(entry: Registry.ArchiveEntry) => isTemplate(entry) | ||
); | ||
// templatePaths.forEach(async path => { | ||
// const { file } = Registry.pathParts(path); | ||
// const templateName = file.substr(0, file.lastIndexOf('.')); | ||
// const content = JSON.parse(Registry.getAsset(path).toString('utf8')); | ||
// await callCluster('indices.putTemplate', { | ||
// name: templateName, | ||
// body: content, | ||
// }); | ||
// }); | ||
templatePaths.forEach(async path => { | ||
const templateInstallPromises = templatePaths.map(async path => { | ||
const { file } = Registry.pathParts(path); | ||
const templateName = file.substr(0, file.lastIndexOf('.')); | ||
const content = JSON.parse(Registry.getAsset(path).toString('utf8')); | ||
|
@@ -91,8 +83,15 @@ const installPreBuiltTemplates = async ( | |
// The existing convenience endpoint `indices.putTemplate` only sends to _template, | ||
// which does not support v2 templates. | ||
// See src/core/server/elasticsearch/api_types.ts for available endpoints. | ||
await callCluster('transport.request', callClusterParams); | ||
return callCluster('transport.request', callClusterParams); | ||
}); | ||
try { | ||
return await Promise.all(templateInstallPromises); | ||
} catch (e) { | ||
throw new Boom(`Error installing prebuilt index templates ${e.message}`, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to start to introduce our domain errors and avoid using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer to start with that in changes that don't go into 7.8 to keep the changes smaller. |
||
statusCode: 400, | ||
}); | ||
} | ||
}; | ||
|
||
const installPreBuiltComponentTemplates = async ( | ||
|
@@ -105,7 +104,7 @@ const installPreBuiltComponentTemplates = async ( | |
pkgVersion, | ||
(entry: Registry.ArchiveEntry) => isComponentTemplate(entry) | ||
); | ||
templatePaths.forEach(async path => { | ||
const templateInstallPromises = templatePaths.map(async path => { | ||
const { file } = Registry.pathParts(path); | ||
const templateName = file.substr(0, file.lastIndexOf('.')); | ||
const content = JSON.parse(Registry.getAsset(path).toString('utf8')); | ||
|
@@ -124,8 +123,15 @@ const installPreBuiltComponentTemplates = async ( | |
// This uses the catch-all endpoint 'transport.request' because there is no | ||
// convenience endpoint for component templates yet. | ||
// See src/core/server/elasticsearch/api_types.ts for available endpoints. | ||
await callCluster('transport.request', callClusterParams); | ||
return callCluster('transport.request', callClusterParams); | ||
}); | ||
try { | ||
return await Promise.all(templateInstallPromises); | ||
} catch (e) { | ||
throw new Boom(`Error installing prebuilt component templates ${e.message}`, { | ||
statusCode: 400, | ||
}); | ||
} | ||
}; | ||
|
||
const isTemplate = ({ path }: Registry.ArchiveEntry) => { | ||
|
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.
@neptunian This gives us a stack trace from the handler that's actually pointing at the real location the error occurred. I only added this here for "unknown" errors.