From c51ac5070cc3ec9b4b2f760b10506255db8153fb Mon Sep 17 00:00:00 2001 From: Juntao Wang Date: Fri, 9 Feb 2024 10:07:41 -0700 Subject: [PATCH] Fix anaconda validation issue --- .../routes/api/validate-isv/validateISV.ts | 25 ++++++---- backend/src/types.ts | 17 ++++++- .../pages/exploreApplication/EnableModal.scss | 12 ----- .../exploreApplication/EnableVariable.tsx | 47 ++++++++++--------- 4 files changed, 57 insertions(+), 44 deletions(-) diff --git a/backend/src/routes/api/validate-isv/validateISV.ts b/backend/src/routes/api/validate-isv/validateISV.ts index d7cfc1a8d1..65c1b64f34 100644 --- a/backend/src/routes/api/validate-isv/validateISV.ts +++ b/backend/src/routes/api/validate-isv/validateISV.ts @@ -1,7 +1,7 @@ import { IncomingMessage } from 'http'; import { CoreV1Api, V1Secret, V1ConfigMap } from '@kubernetes/client-node'; import { FastifyRequest } from 'fastify'; -import { KubeFastifyInstance, OdhApplication } from '../../../types'; +import { CronJobKind, KubeFastifyInstance, OdhApplication } from '../../../types'; import { getApplication, updateApplications } from '../../../utils/resourceUtils'; import { getApplicationEnabledConfigMap } from '../../../utils/componentUtils'; @@ -86,9 +86,9 @@ export const runValidation = async ( const query = request.query as { [key: string]: string }; const appName = query?.appName; const stringData = JSON.parse(query?.values ?? ''); - const batchV1beta1Api = fastify.kube.batchV1beta1Api; const batchV1Api = fastify.kube.batchV1Api; const coreV1Api = fastify.kube.coreV1Api; + const customObjectsApi = fastify.kube.customObjectsApi; const appDef = getApplication(appName); const { enable } = appDef.spec; @@ -102,9 +102,9 @@ export const runValidation = async ( fastify.log.error(`Unable to create secret: ${e.response?.body?.message ?? e.message}`); }); - const cronJob = await batchV1beta1Api - .readNamespacedCronJob(cronjobName, namespace) - .then((res) => res.body) + const cronJob = await customObjectsApi + .getNamespacedCustomObject('batch', 'v1', namespace, 'cronjobs', cronjobName) + .then((res) => res.body as CronJobKind) .catch(() => { fastify.log.error(`validation cronjob does not exist`); }); @@ -120,13 +120,20 @@ export const runValidation = async ( const updateCronJobSuspension = async (suspend: boolean) => { try { - const updateCronJob = await batchV1beta1Api - .readNamespacedCronJob(cronjobName, namespace) - .then((res) => res.body); + const updateCronJob = await customObjectsApi + .getNamespacedCustomObject('batch', 'v1', namespace, 'cronjobs', cronjobName) + .then((res) => res.body as CronJobKind); // Flag the cronjob as no longer suspended updateCronJob.spec.suspend = suspend; - await batchV1beta1Api.replaceNamespacedCronJob(cronjobName, namespace, updateCronJob); + await customObjectsApi.replaceNamespacedCustomObject( + 'batch', + 'v1', + namespace, + 'cronjobs', + cronjobName, + updateCronJob, + ); } catch (e) { fastify.log.error( `failed to ${suspend ? 'suspend' : 'unsuspend'} cronjob: ${e.response.body.message}`, diff --git a/backend/src/types.ts b/backend/src/types.ts index ca6134ecd6..536c597c06 100644 --- a/backend/src/types.ts +++ b/backend/src/types.ts @@ -701,7 +701,6 @@ export type RecursivePartial = { [P in keyof T]?: RecursivePartial; }; - export type MachineAutoscaler = { spec: { maxReplicas: number; @@ -732,7 +731,6 @@ export type MachineSetList = { items: MachineSet[]; } & K8sResourceCommon; - export type DetectedAccelerators = { configured: boolean; available: { [key: string]: number }; @@ -970,3 +968,18 @@ export type SubscriptionStatusData = { installedCSV?: string; installPlanRefNamespace?: string; }; + +export type CronJobKind = { + spec: { + jobTemplate: { + spec: { + template: { + metadata: { + labels?: { [key: string]: string }; + }; + }; + }; + }; + suspend: boolean; + }; +} & K8sResourceCommon; diff --git a/frontend/src/pages/exploreApplication/EnableModal.scss b/frontend/src/pages/exploreApplication/EnableModal.scss index 1aebac7561..184966ee19 100644 --- a/frontend/src/pages/exploreApplication/EnableModal.scss +++ b/frontend/src/pages/exploreApplication/EnableModal.scss @@ -14,18 +14,6 @@ display: none; } } - &__variable-input { - max-width: calc(400px - var(--pf-v5-global--spacer--md)); - margin-right: var(--pf-v5-global--spacer--xl); - } - &__toggle-password-vis { - border: 1px solid var(--pf-v5-global--BorderColor--300); - border-radius: 0; - color: var(--pf-v5-global--Color--200) !important; - padding: 6px var(--pf-v5-global--spacer--sm) 5px; - position: relative; - right: 33px; - } .pf-v5-c-modal-box__title-text { text-overflow: initial; white-space: break-spaces; diff --git a/frontend/src/pages/exploreApplication/EnableVariable.tsx b/frontend/src/pages/exploreApplication/EnableVariable.tsx index 36a6ccddad..42c91eccf1 100644 --- a/frontend/src/pages/exploreApplication/EnableVariable.tsx +++ b/frontend/src/pages/exploreApplication/EnableVariable.tsx @@ -6,6 +6,8 @@ import { FormHelperText, HelperText, HelperTextItem, + InputGroup, + InputGroupItem, TextInput, TextInputTypes, } from '@patternfly/react-core'; @@ -26,32 +28,35 @@ const EnableVariable = React.forwardRef( return ( - updateValue(newValue)} - /> + + + updateValue(newValue)} + /> + + {inputType === TextInputTypes.password ? ( + + + + ) : null} + {helperText} - {inputType === TextInputTypes.password ? ( - - ) : null} ); },