Skip to content

Commit b0f47d5

Browse files
John Schulzelasticmachine
andauthored
[Ingest Manager] Kibana, not EPR, controls removable packages (#69761) (#69906)
* 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> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 0102fb8 commit b0f47d5

File tree

5 files changed

+212
-8
lines changed

5 files changed

+212
-8
lines changed

x-pack/plugins/ingest_manager/common/openapi/spec_oas3.json

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,198 @@
17121712
},
17131713
"success": true
17141714
}
1715+
},
1716+
"required-package": {
1717+
"value": {
1718+
"response": {
1719+
"format_version": "1.0.0",
1720+
"name": "endpoint",
1721+
"title": "Elastic Endpoint",
1722+
"version": "0.3.0",
1723+
"readme": "/package/endpoint/0.3.0/docs/README.md",
1724+
"license": "basic",
1725+
"description": "This is the Elastic Endpoint package.",
1726+
"type": "solution",
1727+
"categories": [
1728+
"security"
1729+
],
1730+
"release": "beta",
1731+
"requirement": {
1732+
"kibana": {
1733+
"versions": ">7.4.0"
1734+
}
1735+
},
1736+
"icons": [
1737+
{
1738+
"src": "/package/endpoint/0.3.0/img/logo-endpoint-64-color.svg",
1739+
"size": "16x16",
1740+
"type": "image/svg+xml"
1741+
}
1742+
],
1743+
"assets": {
1744+
"kibana": {
1745+
"dashboard": [
1746+
{
1747+
"pkgkey": "endpoint-0.3.0",
1748+
"service": "kibana",
1749+
"type": "dashboard",
1750+
"file": "826759f0-7074-11ea-9bc8-6b38f4d29a16.json",
1751+
"path": "endpoint-0.3.0/kibana/dashboard/826759f0-7074-11ea-9bc8-6b38f4d29a16.json"
1752+
}
1753+
],
1754+
"map": [
1755+
{
1756+
"pkgkey": "endpoint-0.3.0",
1757+
"service": "kibana",
1758+
"type": "map",
1759+
"file": "a3a3bd10-706b-11ea-9bc8-6b38f4d29a16.json",
1760+
"path": "endpoint-0.3.0/kibana/map/a3a3bd10-706b-11ea-9bc8-6b38f4d29a16.json"
1761+
}
1762+
],
1763+
"visualization": [
1764+
{
1765+
"pkgkey": "endpoint-0.3.0",
1766+
"service": "kibana",
1767+
"type": "visualization",
1768+
"file": "1cfceda0-728b-11ea-9bc8-6b38f4d29a16.json",
1769+
"path": "endpoint-0.3.0/kibana/visualization/1cfceda0-728b-11ea-9bc8-6b38f4d29a16.json"
1770+
},
1771+
{
1772+
"pkgkey": "endpoint-0.3.0",
1773+
"service": "kibana",
1774+
"type": "visualization",
1775+
"file": "1e525190-7074-11ea-9bc8-6b38f4d29a16.json",
1776+
"path": "endpoint-0.3.0/kibana/visualization/1e525190-7074-11ea-9bc8-6b38f4d29a16.json"
1777+
},
1778+
{
1779+
"pkgkey": "endpoint-0.3.0",
1780+
"service": "kibana",
1781+
"type": "visualization",
1782+
"file": "55387750-729c-11ea-9bc8-6b38f4d29a16.json",
1783+
"path": "endpoint-0.3.0/kibana/visualization/55387750-729c-11ea-9bc8-6b38f4d29a16.json"
1784+
},
1785+
{
1786+
"pkgkey": "endpoint-0.3.0",
1787+
"service": "kibana",
1788+
"type": "visualization",
1789+
"file": "92b1edc0-706a-11ea-9bc8-6b38f4d29a16.json",
1790+
"path": "endpoint-0.3.0/kibana/visualization/92b1edc0-706a-11ea-9bc8-6b38f4d29a16.json"
1791+
}
1792+
]
1793+
}
1794+
},
1795+
"datasets": [
1796+
{
1797+
"id": "endpoint",
1798+
"title": "Endpoint Events",
1799+
"release": "experimental",
1800+
"type": "events",
1801+
"package": "endpoint",
1802+
"path": "events"
1803+
},
1804+
{
1805+
"id": "endpoint.metadata",
1806+
"title": "Endpoint Metadata",
1807+
"release": "experimental",
1808+
"type": "metrics",
1809+
"package": "endpoint",
1810+
"path": "metadata"
1811+
},
1812+
{
1813+
"id": "endpoint.policy",
1814+
"title": "Endpoint Policy Response",
1815+
"release": "experimental",
1816+
"type": "metrics",
1817+
"package": "endpoint",
1818+
"path": "policy"
1819+
},
1820+
{
1821+
"id": "endpoint.telemetry",
1822+
"title": "Endpoint Telemetry",
1823+
"release": "experimental",
1824+
"type": "metrics",
1825+
"package": "endpoint",
1826+
"path": "telemetry"
1827+
}
1828+
],
1829+
"datasources": [
1830+
{
1831+
"name": "endpoint",
1832+
"title": "Endpoint data source",
1833+
"description": "Interact with the endpoint.",
1834+
"inputs": null,
1835+
"multiple": false
1836+
}
1837+
],
1838+
"download": "/epr/endpoint/endpoint-0.3.0.tar.gz",
1839+
"path": "/package/endpoint/0.3.0",
1840+
"latestVersion": "0.3.0",
1841+
"removable": false,
1842+
"status": "installed",
1843+
"savedObject": {
1844+
"id": "endpoint",
1845+
"type": "epm-packages",
1846+
"updated_at": "2020-06-23T21:44:59.319Z",
1847+
"version": "Wzk4LDFd",
1848+
"attributes": {
1849+
"installed": [
1850+
{
1851+
"id": "826759f0-7074-11ea-9bc8-6b38f4d29a16",
1852+
"type": "dashboard"
1853+
},
1854+
{
1855+
"id": "1cfceda0-728b-11ea-9bc8-6b38f4d29a16",
1856+
"type": "visualization"
1857+
},
1858+
{
1859+
"id": "1e525190-7074-11ea-9bc8-6b38f4d29a16",
1860+
"type": "visualization"
1861+
},
1862+
{
1863+
"id": "55387750-729c-11ea-9bc8-6b38f4d29a16",
1864+
"type": "visualization"
1865+
},
1866+
{
1867+
"id": "92b1edc0-706a-11ea-9bc8-6b38f4d29a16",
1868+
"type": "visualization"
1869+
},
1870+
{
1871+
"id": "a3a3bd10-706b-11ea-9bc8-6b38f4d29a16",
1872+
"type": "map"
1873+
},
1874+
{
1875+
"id": "events-endpoint",
1876+
"type": "index-template"
1877+
},
1878+
{
1879+
"id": "metrics-endpoint.metadata",
1880+
"type": "index-template"
1881+
},
1882+
{
1883+
"id": "metrics-endpoint.policy",
1884+
"type": "index-template"
1885+
},
1886+
{
1887+
"id": "metrics-endpoint.telemetry",
1888+
"type": "index-template"
1889+
}
1890+
],
1891+
"es_index_patterns": {
1892+
"events": "events-endpoint-*",
1893+
"metadata": "metrics-endpoint.metadata-*",
1894+
"policy": "metrics-endpoint.policy-*",
1895+
"telemetry": "metrics-endpoint.telemetry-*"
1896+
},
1897+
"name": "endpoint",
1898+
"version": "0.3.0",
1899+
"internal": false,
1900+
"removable": false
1901+
},
1902+
"references": []
1903+
}
1904+
},
1905+
"success": true
1906+
}
17151907
}
17161908
}
17171909
}
@@ -3822,6 +4014,9 @@
38224014
},
38234015
"path": {
38244016
"type": "string"
4017+
},
4018+
"removable": {
4019+
"type": "boolean"
38254020
}
38264021
},
38274022
"required": [

x-pack/plugins/ingest_manager/common/types/models/epm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export interface RegistryPackage {
5858
icons?: RegistryImage[];
5959
assets?: string[];
6060
internal?: boolean;
61-
removable?: boolean;
6261
format_version: string;
6362
datasets?: Dataset[];
6463
datasources?: RegistryDatasource[];
@@ -206,6 +205,7 @@ interface PackageAdditions {
206205
title: string;
207206
latestVersion: string;
208207
assets: AssetsGroupedByServiceByType;
208+
removable?: boolean;
209209
}
210210

211211
// Managers public HTTP response types

x-pack/plugins/ingest_manager/server/services/epm/packages/get.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { SavedObjectsClientContract } from 'src/core/server';
88
import { PACKAGES_SAVED_OBJECT_TYPE } from '../../../constants';
99
import { Installation, InstallationStatus, PackageInfo, KibanaAssetType } from '../../../types';
1010
import * as Registry from '../registry';
11-
import { createInstallableFrom } from './index';
11+
import { createInstallableFrom, isRequiredPackage } from './index';
1212

1313
export { fetchFile as getFile, SearchParams } from '../registry';
1414

@@ -79,17 +79,15 @@ export async function getPackageInfo(options: {
7979
getInstallationObject({ savedObjectsClient, pkgName }),
8080
Registry.fetchFindLatestPackage(pkgName),
8181
Registry.getArchiveInfo(pkgName, pkgVersion),
82-
] as const);
83-
// adding `as const` due to regression in TS 3.7.2
84-
// see https://github.com/microsoft/TypeScript/issues/34925#issuecomment-550021453
85-
// and https://github.com/microsoft/TypeScript/pull/33707#issuecomment-550718523
82+
]);
8683

8784
// add properties that aren't (or aren't yet) on Registry response
8885
const updated = {
8986
...item,
9087
latestVersion: latestPackage.version,
9188
title: item.title || nameAsTitle(item.name),
9289
assets: Registry.groupPathsByService(assets || []),
90+
removable: !isRequiredPackage(pkgName),
9391
};
9492
return createInstallableFrom(updated, savedObject);
9593
}

x-pack/plugins/ingest_manager/server/services/epm/packages/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ export {
2626
export { installKibanaAssets, installPackage, ensureInstalledPackage } from './install';
2727
export { removeInstallation } from './remove';
2828

29+
type RequiredPackage = 'system' | 'endpoint';
30+
const requiredPackages: Record<RequiredPackage, boolean> = {
31+
system: true,
32+
endpoint: true,
33+
};
34+
35+
export function isRequiredPackage(value: string): value is RequiredPackage {
36+
return value in requiredPackages;
37+
}
38+
2939
export class PackageNotInstalledError extends Error {
3040
constructor(pkgkey: string) {
3141
super(`${pkgkey} is not installed`);

x-pack/plugins/ingest_manager/server/services/epm/packages/install.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
import { installIndexPatterns } from '../kibana/index_pattern/install';
2020
import * as Registry from '../registry';
2121
import { getObject } from './get_objects';
22-
import { getInstallation, getInstallationObject } from './index';
22+
import { getInstallation, getInstallationObject, isRequiredPackage } from './index';
2323
import { installTemplates } from '../elasticsearch/template/install';
2424
import { generateESIndexPatterns } from '../elasticsearch/template/template';
2525
import { installPipelines } from '../elasticsearch/ingest_pipeline/install';
@@ -104,7 +104,8 @@ export async function installPackage(options: {
104104
throw Boom.badRequest('Cannot install or update to an out-of-date package');
105105

106106
const reinstall = pkgVersion === installedPkg?.attributes.version;
107-
const { internal = false, removable = true } = registryPackageInfo;
107+
const removable = !isRequiredPackage(pkgName);
108+
const { internal = false } = registryPackageInfo;
108109

109110
// delete the previous version's installation's SO kibana assets before installing new ones
110111
// in case some assets were removed in the new version

0 commit comments

Comments
 (0)