Skip to content

Commit

Permalink
fix: secret deletion and deploy button links in empty state
Browse files Browse the repository at this point in the history
Signed-off-by: Olga Lavtar <olavtar@redhat.com>
  • Loading branch information
olavtar committed Sep 26, 2024
1 parent 063d974 commit fee4da2
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import DeleteModal from '~/pages/projects/components/DeleteModal';
import { InferenceServiceKind, ServingRuntimeKind } from '~/k8sTypes';
import { deleteInferenceService, deletePvc, deleteServingRuntime } from '~/api';
import { deleteInferenceService, deletePvc, deleteSecret, deleteServingRuntime } from '~/api';
import { getDisplayNameFromK8sResource } from '~/concepts/k8s/utils';
import { byName, ProjectsContext } from '~/concepts/projects/ProjectsContext';
import { isProjectNIMSupported } from '~/pages/modelServing/screens/projects/nimUtils';
Expand Down Expand Up @@ -48,6 +48,14 @@ const DeleteInferenceServiceModal: React.FC<DeleteInferenceServiceModalProps> =
const pvcName = servingRuntime?.spec.volumes?.find(
(vol) => vol.persistentVolumeClaim?.claimName,
)?.persistentVolumeClaim?.claimName;
const containerWithEnv = servingRuntime?.spec.containers.find(
(container) =>
container.env && container.env.some((env) => env.valueFrom?.secretKeyRef?.name),
);
const nimSecretName = containerWithEnv?.env?.find(
(env) => env.valueFrom?.secretKeyRef?.name,
)?.valueFrom?.secretKeyRef?.name;
const imagePullSecretName = servingRuntime?.spec.imagePullSecrets[0]?.name;
Promise.all([
deleteInferenceService(
inferenceService.metadata.name,
Expand All @@ -64,6 +72,12 @@ const DeleteInferenceServiceModal: React.FC<DeleteInferenceServiceModalProps> =
...(isKServeNIMEnabled && pvcName
? [deletePvc(pvcName, inferenceService.metadata.namespace)]
: []),
...(isKServeNIMEnabled && project
? [
deleteSecret(project.metadata.name, nimSecretName),
deleteSecret(project.metadata.name, imagePullSecretName),
]
: []),
])

.then(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import EmptyNIMModelServingCard from '~/pages/modelServing/screens/projects/Empt
import { useIsNIMAvailable } from '~/pages/modelServing/screens/projects/useIsNIMAvailable';
import { isProjectNIMSupported } from '~/pages/modelServing/screens/projects/nimUtils';
import { useDashboardNamespace } from '~/redux/selectors';
import DeployNIMServiceModal from '~/pages/modelServing/screens/projects/NIMServiceModal/DeployNIMServiceModal';
import ManageServingRuntimeModal from './ServingRuntimeModal/ManageServingRuntimeModal';
import ModelMeshServingRuntimeTable from './ModelMeshSection/ServingRuntimeTable';
import ModelServingPlatformButtonAction from './ModelServingPlatformButtonAction';
Expand Down Expand Up @@ -275,6 +276,15 @@ const ModelServingPlatform: React.FC = () => {
onSubmit(submit);
}}
/>
{isNIMAvailable && (
<DeployNIMServiceModal
isOpen={platformSelected === ServingRuntimePlatform.SINGLE}
projectContext={{ currentProject, dataConnections }}
onClose={(submit: boolean) => {
onSubmit(submit);
}}
/>
)}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const DeployNIMServiceModal: React.FC<DeployNIMServiceModalProps> = ({
const [actionInProgress, setActionInProgress] = React.useState(false);
const [error, setError] = React.useState<Error | undefined>();
const [alertVisible, setAlertVisible] = React.useState(true);
const [pvcSize, setPvcSize] = React.useState<string>('');
const [pvcSize, setPvcSize] = React.useState<string>('30Gi');

React.useEffect(() => {
if (currentProjectName && isOpen) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const NIMModelListSection: React.FC<NIMModelListSectionProps> = ({
return (
<FormGroup label="NVIDIA NIM" fieldId="nim-model-list-selection" isRequired>
<SimpleSelect
isScrollable
isFullWidth
isDisabled={isEditing || options.length === 0}
id="nim-model-list-selection"
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/modelServing/screens/projects/nimUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ const getNIMSecretData = async (secretName: string): Promise<SecretKind> => {
throw new Error(`Error fetching secret: ${response.statusText}`);
}
const secretData = await response.json();
return secretData;
return secretData.body;
} catch (error) {
throw new Error(`Failed to fetch secret: ${secretName}.`);
}
};
export const getNIMData = async (isNGC: boolean): Promise<Record<string, string> | undefined> => {
const nimSecretData = isNGC
const nimSecretData: SecretKind = isNGC
? await getNIMSecretData(NIM_NGC_SECRET_NAME)
: await getNIMSecretData(NIM_SECRET_NAME);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import AddModelFooter from '~/pages/projects/screens/detail/overview/serverModel
import { InferenceServiceKind } from '~/k8sTypes';
import { ProjectSectionID } from '~/pages/projects/screens/detail/types';
import ModelServingContextProvider from '~/pages/modelServing/ModelServingContext';
import { isProjectNIMSupported } from '~/pages/modelServing/screens/projects/nimUtils';
import DeployedModelsCard from './DeployedModelsCard';

interface DeployedModelsSectionProps {
Expand All @@ -53,6 +54,8 @@ const DeployedModelsSection: React.FC<DeployedModelsSectionProps> = ({ isMultiPl
);
const [deployedModels, setDeployedModels] = React.useState<InferenceServiceKind[]>([]);

const isKServeNIMEnabled = isProjectNIMSupported(currentProject);

React.useEffect(() => {
if (!inferenceServicesLoaded || !modelServersLoaded) {
return;
Expand Down Expand Up @@ -176,7 +179,7 @@ const DeployedModelsSection: React.FC<DeployedModelsSectionProps> = ({ isMultiPl
</TextContent>
)}
</CardBody>
{!platformError ? <AddModelFooter /> : null}
{!platformError ? <AddModelFooter isNIM={isKServeNIMEnabled} /> : null}
</OverviewCard>
);
}
Expand Down

0 comments on commit fee4da2

Please sign in to comment.