Skip to content

Commit

Permalink
Add shm to ServingRuntime volumes and volumeMounts
Browse files Browse the repository at this point in the history
  • Loading branch information
DaoDaoNoCode committed Sep 6, 2023
1 parent 6ee8280 commit 1aa1077
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
2 changes: 2 additions & 0 deletions backend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,10 @@ export type ServingRuntime = K8sResourceCommon & {
image: string;
name: string;
resources: ContainerResources;
volumeMounts?: VolumeMount[];
}[];
supportedModelFormats: SupportedModelFormats[];
replicas: number;
volumes?: Volume[];
};
};
12 changes: 1 addition & 11 deletions frontend/src/api/k8s/notebooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,7 @@ import {
} from '~/concepts/pipelines/elyra/utils';
import { createRoleBinding } from '~/api';
import { Volume, VolumeMount } from '~/types';
import { assemblePodSpecOptions } from './utils';

const getshmVolumeMount = (): VolumeMount => ({
name: 'shm',
mountPath: '/dev/shm',
});

const getshmVolume = (): Volume => ({
name: 'shm',
emptyDir: { medium: 'Memory' },
});
import { assemblePodSpecOptions, getshmVolume, getshmVolumeMount } from './utils';

const assembleNotebook = (
data: StartNotebookData,
Expand Down
15 changes: 14 additions & 1 deletion frontend/src/api/k8s/servingRuntimes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { getModelServingRuntimeName } from '~/pages/modelServing/utils';
import { getDisplayNameFromK8sResource, translateDisplayNameForK8s } from '~/pages/projects/utils';
import { applyK8sAPIOptions } from '~/api/apiMergeUtils';
import { getModelServingProjects } from './projects';
import { assemblePodSpecOptions } from './utils';
import { assemblePodSpecOptions, getshmVolume, getshmVolumeMount } from './utils';

const assembleServingRuntime = (
data: CreatingServingRuntimeObject,
Expand Down Expand Up @@ -79,11 +79,24 @@ const assembleServingRuntime = (

const { affinity, tolerations, resources } = assemblePodSpecOptions(resourceSettings, gpus);

const volumes = updatedServingRuntime.spec.volumes || [];
// Can we assume there is only 1 container per serving runtime for now?
const volumeMounts = updatedServingRuntime.spec.containers?.[0].volumeMounts || [];
if (!volumes.find((volume) => volume.name === 'shm')) {
volumes.push(getshmVolume('2Gi'));
}
if (!volumeMounts.find((volumeMount) => volumeMount.name === 'shm')) {
volumeMounts.push(getshmVolumeMount());
}

updatedServingRuntime.spec.volumes = volumes;

updatedServingRuntime.spec.containers = servingRuntime.spec.containers.map((container) => ({
...container,
resources,
affinity,
tolerations,
volumeMounts,
}));

return updatedServingRuntime;
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/api/k8s/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
PodToleration,
TolerationSettings,
ContainerResourceAttributes,
VolumeMount,
Volume,
} from '~/types';
import { determineTolerations } from '~/utilities/tolerations';

Expand Down Expand Up @@ -54,3 +56,13 @@ export const assemblePodSpecOptions = (
const tolerations = determineTolerations(gpus > 0, tolerationSettings);
return { affinity, tolerations, resources };
};

export const getshmVolumeMount = (): VolumeMount => ({
name: 'shm',
mountPath: '/dev/shm',
});

export const getshmVolume = (sizeLimit?: string): Volume => ({
name: 'shm',
emptyDir: { medium: 'Memory', ...(sizeLimit && { sizeLimit }) },
});
3 changes: 3 additions & 0 deletions frontend/src/k8sTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
TolerationSettings,
ImageStreamStatusTagItem,
ImageStreamStatusTagCondition,
VolumeMount,
} from './types';
import { ServingRuntimeSize } from './pages/modelServing/screens/types';

Expand Down Expand Up @@ -327,9 +328,11 @@ export type ServingRuntimeKind = K8sResourceCommon & {
image: string;
name: string;
resources: ContainerResources;
volumeMounts?: VolumeMount[];
}[];
supportedModelFormats: SupportedModelFormats[];
replicas: number;
volumes?: Volume[];
};
};

Expand Down

0 comments on commit 1aa1077

Please sign in to comment.