Skip to content

Commit

Permalink
Remove the KfDef CRD reliance
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewballantyne committed Jul 18, 2023
1 parent fffdd02 commit 35fef96
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions backend/src/utils/resourceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ const fetchSubscriptions = (fastify: KubeFastifyInstance): Promise<SubscriptionK
return fetchAll();
};

/** @deprecated -- we are moving away from KfDefs */
const fetchInstalledKfdefs = async (fastify: KubeFastifyInstance): Promise<KfDefApplication[]> => {
const customObjectsApi = fastify.kube.customObjectsApi;
const namespace = fastify.kube.namespace;
Expand All @@ -211,6 +212,16 @@ const fetchInstalledKfdefs = async (fastify: KubeFastifyInstance): Promise<KfDef
return acc;
}, [] as KfDefApplication[]);
} catch (e) {
const errorResponse = e.response.body;
if (errorResponse?.trim() === '404 page not found') {
// 404s like this are because the CRD does not exist
// If there were no resources, we would get an empty array
// This is not an error case, we are supporting the new Operator that does not use KfDefs
fastify.log.info('Detected no KfDef CRD installed -- suppressing issue pulling KfDef');
return [];
}

// Old flow, if it fails in other ways, we'll need to still handle a failed KfDef issue
fastify.log.error(e, 'failed to get kfdefs');
const error = createError(500, 'failed to get kfdefs');
error.explicitInternalServerError = true;
Expand Down

0 comments on commit 35fef96

Please sign in to comment.