[Ingest Manager] Kibana, not EPR, controls removable packages (#69761)
* Kibana, not EPR, controls removable packages * Add 'removable' property to OpenAPI PackageInfo schema * Undo changes to example /packages API output Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
e1cc40ed75
commit
2685654cdc
|
@ -1712,6 +1712,198 @@
|
|||
},
|
||||
"success": true
|
||||
}
|
||||
},
|
||||
"required-package": {
|
||||
"value": {
|
||||
"response": {
|
||||
"format_version": "1.0.0",
|
||||
"name": "endpoint",
|
||||
"title": "Elastic Endpoint",
|
||||
"version": "0.3.0",
|
||||
"readme": "/package/endpoint/0.3.0/docs/README.md",
|
||||
"license": "basic",
|
||||
"description": "This is the Elastic Endpoint package.",
|
||||
"type": "solution",
|
||||
"categories": [
|
||||
"security"
|
||||
],
|
||||
"release": "beta",
|
||||
"requirement": {
|
||||
"kibana": {
|
||||
"versions": ">7.4.0"
|
||||
}
|
||||
},
|
||||
"icons": [
|
||||
{
|
||||
"src": "/package/endpoint/0.3.0/img/logo-endpoint-64-color.svg",
|
||||
"size": "16x16",
|
||||
"type": "image/svg+xml"
|
||||
}
|
||||
],
|
||||
"assets": {
|
||||
"kibana": {
|
||||
"dashboard": [
|
||||
{
|
||||
"pkgkey": "endpoint-0.3.0",
|
||||
"service": "kibana",
|
||||
"type": "dashboard",
|
||||
"file": "826759f0-7074-11ea-9bc8-6b38f4d29a16.json",
|
||||
"path": "endpoint-0.3.0/kibana/dashboard/826759f0-7074-11ea-9bc8-6b38f4d29a16.json"
|
||||
}
|
||||
],
|
||||
"map": [
|
||||
{
|
||||
"pkgkey": "endpoint-0.3.0",
|
||||
"service": "kibana",
|
||||
"type": "map",
|
||||
"file": "a3a3bd10-706b-11ea-9bc8-6b38f4d29a16.json",
|
||||
"path": "endpoint-0.3.0/kibana/map/a3a3bd10-706b-11ea-9bc8-6b38f4d29a16.json"
|
||||
}
|
||||
],
|
||||
"visualization": [
|
||||
{
|
||||
"pkgkey": "endpoint-0.3.0",
|
||||
"service": "kibana",
|
||||
"type": "visualization",
|
||||
"file": "1cfceda0-728b-11ea-9bc8-6b38f4d29a16.json",
|
||||
"path": "endpoint-0.3.0/kibana/visualization/1cfceda0-728b-11ea-9bc8-6b38f4d29a16.json"
|
||||
},
|
||||
{
|
||||
"pkgkey": "endpoint-0.3.0",
|
||||
"service": "kibana",
|
||||
"type": "visualization",
|
||||
"file": "1e525190-7074-11ea-9bc8-6b38f4d29a16.json",
|
||||
"path": "endpoint-0.3.0/kibana/visualization/1e525190-7074-11ea-9bc8-6b38f4d29a16.json"
|
||||
},
|
||||
{
|
||||
"pkgkey": "endpoint-0.3.0",
|
||||
"service": "kibana",
|
||||
"type": "visualization",
|
||||
"file": "55387750-729c-11ea-9bc8-6b38f4d29a16.json",
|
||||
"path": "endpoint-0.3.0/kibana/visualization/55387750-729c-11ea-9bc8-6b38f4d29a16.json"
|
||||
},
|
||||
{
|
||||
"pkgkey": "endpoint-0.3.0",
|
||||
"service": "kibana",
|
||||
"type": "visualization",
|
||||
"file": "92b1edc0-706a-11ea-9bc8-6b38f4d29a16.json",
|
||||
"path": "endpoint-0.3.0/kibana/visualization/92b1edc0-706a-11ea-9bc8-6b38f4d29a16.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"datasets": [
|
||||
{
|
||||
"id": "endpoint",
|
||||
"title": "Endpoint Events",
|
||||
"release": "experimental",
|
||||
"type": "events",
|
||||
"package": "endpoint",
|
||||
"path": "events"
|
||||
},
|
||||
{
|
||||
"id": "endpoint.metadata",
|
||||
"title": "Endpoint Metadata",
|
||||
"release": "experimental",
|
||||
"type": "metrics",
|
||||
"package": "endpoint",
|
||||
"path": "metadata"
|
||||
},
|
||||
{
|
||||
"id": "endpoint.policy",
|
||||
"title": "Endpoint Policy Response",
|
||||
"release": "experimental",
|
||||
"type": "metrics",
|
||||
"package": "endpoint",
|
||||
"path": "policy"
|
||||
},
|
||||
{
|
||||
"id": "endpoint.telemetry",
|
||||
"title": "Endpoint Telemetry",
|
||||
"release": "experimental",
|
||||
"type": "metrics",
|
||||
"package": "endpoint",
|
||||
"path": "telemetry"
|
||||
}
|
||||
],
|
||||
"datasources": [
|
||||
{
|
||||
"name": "endpoint",
|
||||
"title": "Endpoint data source",
|
||||
"description": "Interact with the endpoint.",
|
||||
"inputs": null,
|
||||
"multiple": false
|
||||
}
|
||||
],
|
||||
"download": "/epr/endpoint/endpoint-0.3.0.tar.gz",
|
||||
"path": "/package/endpoint/0.3.0",
|
||||
"latestVersion": "0.3.0",
|
||||
"removable": false,
|
||||
"status": "installed",
|
||||
"savedObject": {
|
||||
"id": "endpoint",
|
||||
"type": "epm-packages",
|
||||
"updated_at": "2020-06-23T21:44:59.319Z",
|
||||
"version": "Wzk4LDFd",
|
||||
"attributes": {
|
||||
"installed": [
|
||||
{
|
||||
"id": "826759f0-7074-11ea-9bc8-6b38f4d29a16",
|
||||
"type": "dashboard"
|
||||
},
|
||||
{
|
||||
"id": "1cfceda0-728b-11ea-9bc8-6b38f4d29a16",
|
||||
"type": "visualization"
|
||||
},
|
||||
{
|
||||
"id": "1e525190-7074-11ea-9bc8-6b38f4d29a16",
|
||||
"type": "visualization"
|
||||
},
|
||||
{
|
||||
"id": "55387750-729c-11ea-9bc8-6b38f4d29a16",
|
||||
"type": "visualization"
|
||||
},
|
||||
{
|
||||
"id": "92b1edc0-706a-11ea-9bc8-6b38f4d29a16",
|
||||
"type": "visualization"
|
||||
},
|
||||
{
|
||||
"id": "a3a3bd10-706b-11ea-9bc8-6b38f4d29a16",
|
||||
"type": "map"
|
||||
},
|
||||
{
|
||||
"id": "events-endpoint",
|
||||
"type": "index-template"
|
||||
},
|
||||
{
|
||||
"id": "metrics-endpoint.metadata",
|
||||
"type": "index-template"
|
||||
},
|
||||
{
|
||||
"id": "metrics-endpoint.policy",
|
||||
"type": "index-template"
|
||||
},
|
||||
{
|
||||
"id": "metrics-endpoint.telemetry",
|
||||
"type": "index-template"
|
||||
}
|
||||
],
|
||||
"es_index_patterns": {
|
||||
"events": "events-endpoint-*",
|
||||
"metadata": "metrics-endpoint.metadata-*",
|
||||
"policy": "metrics-endpoint.policy-*",
|
||||
"telemetry": "metrics-endpoint.telemetry-*"
|
||||
},
|
||||
"name": "endpoint",
|
||||
"version": "0.3.0",
|
||||
"internal": false,
|
||||
"removable": false
|
||||
},
|
||||
"references": []
|
||||
}
|
||||
},
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3822,6 +4014,9 @@
|
|||
},
|
||||
"path": {
|
||||
"type": "string"
|
||||
},
|
||||
"removable": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
|
|
@ -58,7 +58,6 @@ export interface RegistryPackage {
|
|||
icons?: RegistryImage[];
|
||||
assets?: string[];
|
||||
internal?: boolean;
|
||||
removable?: boolean;
|
||||
format_version: string;
|
||||
datasets?: Dataset[];
|
||||
datasources?: RegistryDatasource[];
|
||||
|
@ -206,6 +205,7 @@ interface PackageAdditions {
|
|||
title: string;
|
||||
latestVersion: string;
|
||||
assets: AssetsGroupedByServiceByType;
|
||||
removable?: boolean;
|
||||
}
|
||||
|
||||
// Managers public HTTP response types
|
||||
|
|
|
@ -8,7 +8,7 @@ import { SavedObjectsClientContract } from 'src/core/server';
|
|||
import { PACKAGES_SAVED_OBJECT_TYPE } from '../../../constants';
|
||||
import { Installation, InstallationStatus, PackageInfo, KibanaAssetType } from '../../../types';
|
||||
import * as Registry from '../registry';
|
||||
import { createInstallableFrom } from './index';
|
||||
import { createInstallableFrom, isRequiredPackage } from './index';
|
||||
|
||||
export { fetchFile as getFile, SearchParams } from '../registry';
|
||||
|
||||
|
@ -79,10 +79,7 @@ export async function getPackageInfo(options: {
|
|||
getInstallationObject({ savedObjectsClient, pkgName }),
|
||||
Registry.fetchFindLatestPackage(pkgName),
|
||||
Registry.getArchiveInfo(pkgName, pkgVersion),
|
||||
] as const);
|
||||
// adding `as const` due to regression in TS 3.7.2
|
||||
// see https://github.com/microsoft/TypeScript/issues/34925#issuecomment-550021453
|
||||
// and https://github.com/microsoft/TypeScript/pull/33707#issuecomment-550718523
|
||||
]);
|
||||
|
||||
// add properties that aren't (or aren't yet) on Registry response
|
||||
const updated = {
|
||||
|
@ -90,6 +87,7 @@ export async function getPackageInfo(options: {
|
|||
latestVersion: latestPackage.version,
|
||||
title: item.title || nameAsTitle(item.name),
|
||||
assets: Registry.groupPathsByService(assets || []),
|
||||
removable: !isRequiredPackage(pkgName),
|
||||
};
|
||||
return createInstallableFrom(updated, savedObject);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,16 @@ export {
|
|||
export { installKibanaAssets, installPackage, ensureInstalledPackage } from './install';
|
||||
export { removeInstallation } from './remove';
|
||||
|
||||
type RequiredPackage = 'system' | 'endpoint';
|
||||
const requiredPackages: Record<RequiredPackage, boolean> = {
|
||||
system: true,
|
||||
endpoint: true,
|
||||
};
|
||||
|
||||
export function isRequiredPackage(value: string): value is RequiredPackage {
|
||||
return value in requiredPackages;
|
||||
}
|
||||
|
||||
export class PackageNotInstalledError extends Error {
|
||||
constructor(pkgkey: string) {
|
||||
super(`${pkgkey} is not installed`);
|
||||
|
|
|
@ -19,7 +19,7 @@ import {
|
|||
import { installIndexPatterns } from '../kibana/index_pattern/install';
|
||||
import * as Registry from '../registry';
|
||||
import { getObject } from './get_objects';
|
||||
import { getInstallation, getInstallationObject } from './index';
|
||||
import { getInstallation, getInstallationObject, isRequiredPackage } from './index';
|
||||
import { installTemplates } from '../elasticsearch/template/install';
|
||||
import { generateESIndexPatterns } from '../elasticsearch/template/template';
|
||||
import { installPipelines } from '../elasticsearch/ingest_pipeline/install';
|
||||
|
@ -104,7 +104,8 @@ export async function installPackage(options: {
|
|||
throw Boom.badRequest('Cannot install or update to an out-of-date package');
|
||||
|
||||
const reinstall = pkgVersion === installedPkg?.attributes.version;
|
||||
const { internal = false, removable = true } = registryPackageInfo;
|
||||
const removable = !isRequiredPackage(pkgName);
|
||||
const { internal = false } = registryPackageInfo;
|
||||
|
||||
// delete the previous version's installation's SO kibana assets before installing new ones
|
||||
// in case some assets were removed in the new version
|
||||
|
|
Loading…
Reference in a new issue