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] Treat package upgrade errors during setup as non-blocking #94416

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@

export interface PostIngestSetupResponse {
isInitialized: boolean;
packageInstallUpgradeErrors?: any[];
}
18 changes: 14 additions & 4 deletions x-pack/plugins/fleet/server/routes/setup/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,18 @@ export const createFleetSetupHandler: RequestHandler<
try {
const soClient = context.core.savedObjects.client;
const esClient = context.core.elasticsearch.client.asCurrentUser;
await setupIngestManager(soClient, esClient);
const packageInstallUpgradeErrors = [];
try {
await setupIngestManager(soClient, esClient);
} catch (error) {
packageInstallUpgradeErrors.push(error);
}
await setupFleet(soClient, esClient, {
forceRecreate: request.body?.forceRecreate ?? false,
});

return response.ok({
body: { isInitialized: true },
body: { isInitialized: true, packageInstallUpgradeErrors },
});
} catch (error) {
return defaultIngestErrorHandler({ error, response });
Expand All @@ -81,8 +86,13 @@ export const FleetSetupHandler: RequestHandler = async (context, request, respon
const esClient = context.core.elasticsearch.client.asCurrentUser;

try {
const body: PostIngestSetupResponse = { isInitialized: true };
await setupIngestManager(soClient, esClient);
const packageInstallUpgradeErrors = [];
try {
await setupIngestManager(soClient, esClient);
} catch (error) {
packageInstallUpgradeErrors.push(error);
}
const body: PostIngestSetupResponse = { isInitialized: true, packageInstallUpgradeErrors };
return response.ok({
body,
});
Expand Down
6 changes: 5 additions & 1 deletion x-pack/plugins/fleet/server/services/epm/packages/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export async function removeInstallation(options: {
return installedAssets;
}

// TODO we have both deleteKibanaAssets and deleteKibanaSavedObjectsAssets (below)
function deleteKibanaAssets(
installedObjects: KibanaAssetReference[],
savedObjectsClient: SavedObjectsClientContract
Expand Down Expand Up @@ -135,6 +136,7 @@ async function deleteTemplate(esClient: ElasticsearchClient, name: string): Prom
}
}

// TODO we have both deleteKibanaSavedObjectsAssets and deleteKibanaAssets (above)
export async function deleteKibanaSavedObjectsAssets(
savedObjectsClient: SavedObjectsClientContract,
installedRefs: AssetReference[]
Expand All @@ -152,6 +154,8 @@ export async function deleteKibanaSavedObjectsAssets(
try {
await Promise.all(deletePromises);
} catch (err) {
logger.warn(err);
if (!savedObjectsClient.errors.isNotFoundError(err)) {
logger.error(err);
}
}
}