Skip to content

Commit

Permalink
Merge pull request #2492 from DaoDaoNoCode/jira-rhoaieng-1800
Browse files Browse the repository at this point in the history
Fix anaconda validation issue
  • Loading branch information
openshift-merge-bot[bot] authored Feb 9, 2024
2 parents db514fb + c51ac50 commit ea16972
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 44 deletions.
25 changes: 16 additions & 9 deletions backend/src/routes/api/validate-isv/validateISV.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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;

Expand All @@ -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`);
});
Expand All @@ -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}`,
Expand Down
17 changes: 15 additions & 2 deletions backend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@ export type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>;
};


export type MachineAutoscaler = {
spec: {
maxReplicas: number;
Expand Down Expand Up @@ -732,7 +731,6 @@ export type MachineSetList = {
items: MachineSet[];
} & K8sResourceCommon;


export type DetectedAccelerators = {
configured: boolean;
available: { [key: string]: number };
Expand Down Expand Up @@ -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;
12 changes: 0 additions & 12 deletions frontend/src/pages/exploreApplication/EnableModal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
47 changes: 26 additions & 21 deletions frontend/src/pages/exploreApplication/EnableVariable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
FormHelperText,
HelperText,
HelperTextItem,
InputGroup,
InputGroupItem,
TextInput,
TextInputTypes,
} from '@patternfly/react-core';
Expand All @@ -26,32 +28,35 @@ const EnableVariable = React.forwardRef<HTMLInputElement, EnableVariableProps>(

return (
<FormGroup fieldId={label} label={label}>
<TextInput
id={label}
className="odh-enable-modal__variable-input"
data-id={label}
ref={ref}
isDisabled={validationInProgress}
type={
inputType === TextInputTypes.password && showPassword ? TextInputTypes.text : inputType
}
value={value || ''}
onChange={(e, newValue) => updateValue(newValue)}
/>
<InputGroup>
<InputGroupItem isFill>
<TextInput
id={label}
data-id={label}
ref={ref}
isDisabled={validationInProgress}
type={
inputType === TextInputTypes.password && showPassword
? TextInputTypes.text
: inputType
}
value={value || ''}
onChange={(e, newValue) => updateValue(newValue)}
/>
</InputGroupItem>
{inputType === TextInputTypes.password ? (
<InputGroupItem>
<Button variant={ButtonVariant.link} onClick={() => setShowPassword(!showPassword)}>
{showPassword ? <EyeSlashIcon /> : <EyeIcon />}
</Button>
</InputGroupItem>
) : null}
</InputGroup>
<FormHelperText>
<HelperText>
<HelperTextItem>{helperText}</HelperTextItem>
</HelperText>
</FormHelperText>
{inputType === TextInputTypes.password ? (
<Button
className="odh-enable-modal__toggle-password-vis"
variant={ButtonVariant.link}
onClick={() => setShowPassword(!showPassword)}
>
{showPassword ? <EyeSlashIcon /> : <EyeIcon />}
</Button>
) : null}
</FormGroup>
);
},
Expand Down

0 comments on commit ea16972

Please sign in to comment.