From 095628ca843beff142d0005de6a8faed6127a3bd Mon Sep 17 00:00:00 2001 From: Andrew Ballantyne Date: Fri, 20 Sep 2024 12:46:26 -0400 Subject: [PATCH] Soft disable the biasMetrics feature flag --- backend/src/types.ts | 1 + backend/src/utils/resourceUtils.ts | 37 +++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/backend/src/types.ts b/backend/src/types.ts index 1e2c8a8c2e..460bd10d1c 100644 --- a/backend/src/types.ts +++ b/backend/src/types.ts @@ -61,6 +61,7 @@ export type DashboardConfig = K8sResourceCommon & { templateOrder?: string[]; templateDisablement?: string[]; }; + status?: object; // TODO: Remove when we Support Bias Metrics https://issues.redhat.com/browse/RHOAIENG-13084 }; export type ModelServerSize = { diff --git a/backend/src/utils/resourceUtils.ts b/backend/src/utils/resourceUtils.ts index c4ad6ac4ed..4e13524aed 100644 --- a/backend/src/utils/resourceUtils.ts +++ b/backend/src/utils/resourceUtils.ts @@ -64,9 +64,44 @@ const DASHBOARD_CONFIG = { }; const fetchDashboardCR = async (fastify: KubeFastifyInstance): Promise => { - return fetchOrCreateDashboardCR(fastify).then((dashboardCR) => [dashboardCR]); + return fetchOrCreateDashboardCR(fastify) + .then(softDisableBiasMetrics(fastify)) + .then((dashboardCR) => [dashboardCR]); }; +/** + * TODO: Support Bias Metrics https://issues.redhat.com/browse/RHOAIENG-13084 + * For RHOAI Only + * Always disable bias metrics until we can properly support the new UI flow. + * Note: This does no changes to the on-cluster value -- there can be a de-sync + * TODO: remove changes to DashboardConfig type + */ +const softDisableBiasMetrics = + (fastify: KubeFastifyInstance) => + (dashboardConfig: DashboardConfig): DashboardConfig => ({ + ...dashboardConfig, + spec: { + ...dashboardConfig.spec, + dashboardConfig: { + ...dashboardConfig.spec.dashboardConfig, + disableBiasMetrics: isRHOAI(fastify), + }, + }, + status: isRHOAI(fastify) + ? { + ...(dashboardConfig.status || {}), + conditions: [ + { + message: 'This feature flag state is being ignored', + reason: 'IgnoredFeatureFlag', + status: 'False', + type: 'disableBiasMetricsAvailable', + }, + ], + } + : dashboardConfig.status, + }); + const fetchOrCreateDashboardCR = async (fastify: KubeFastifyInstance): Promise => { return fastify.kube.customObjectsApi .getNamespacedCustomObject(