Skip to content
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] Don't error on missing package_assets value #91744

Merged
merged 3 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/common/types/models/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export type PackageInfo =
export interface Installation extends SavedObjectAttributes {
installed_kibana: KibanaAssetReference[];
installed_es: EsAssetReference[];
package_assets: PackageAssetReference[];
package_assets?: PackageAssetReference[];
es_index_patterns: Record<string, string>;
name: string;
version: string;
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/fleet/server/services/epm/archive/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ export async function archiveEntryToESDocument(opts: {

export async function removeArchiveEntries(opts: {
savedObjectsClient: SavedObjectsClientContract;
refs: PackageAssetReference[];
refs?: PackageAssetReference[];
}) {
const { savedObjectsClient, refs } = opts;
if (!refs) return;
const results = await Promise.all(
refs.map((ref) => savedObjectsClient.delete(ASSETS_SAVED_OBJECT_TYPE, ref.id))
);
Expand Down
8 changes: 6 additions & 2 deletions x-pack/plugins/fleet/server/services/epm/packages/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { PACKAGES_SAVED_OBJECT_TYPE } from '../../../constants';
import { ArchivePackage, RegistryPackage, EpmPackageAdditions } from '../../../../common/types';
import { Installation, PackageInfo, KibanaAssetType } from '../../../types';
import { IngestManagerError } from '../../../errors';
import * as Registry from '../registry';
import { createInstallableFrom, isRequiredPackage } from './index';
import { getEsPackage } from '../archive/storage';
Expand Down Expand Up @@ -185,7 +186,8 @@ export async function getPackageFromSource(options: {
name: pkgName,
version: pkgVersion,
});
if (!res) {

if (!res && installedPkg.package_assets) {
res = await getEsPackage(
pkgName,
pkgVersion,
Expand All @@ -207,7 +209,9 @@ export async function getPackageFromSource(options: {
// else package is not installed or installed and missing from cache and storage and installed from registry
res = await Registry.getRegistryPackage(pkgName, pkgVersion);
}
if (!res) throw new Error(`package info for ${pkgName}-${pkgVersion} does not exist`);
if (!res) {
throw new IngestManagerError(`package info for ${pkgName}-${pkgVersion} does not exist`);
}
return {
paths: res.paths,
packageInfo: res.packageInfo,
Expand Down