Skip to content

Commit

Permalink
Merge pull request #1761 from DaoDaoNoCode/upstream-issue-1685
Browse files Browse the repository at this point in the history
Add shm to ServingRuntime volumes and volumeMounts
  • Loading branch information
openshift-merge-robot authored Sep 14, 2023
2 parents 99eeeae + 92113b8 commit c3b2b43
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 18 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
29 changes: 22 additions & 7 deletions 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,12 +79,27 @@ const assembleServingRuntime = (

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

updatedServingRuntime.spec.containers = servingRuntime.spec.containers.map((container) => ({
...container,
resources,
affinity,
tolerations,
}));
const volumes = updatedServingRuntime.spec.volumes || [];
if (!volumes.find((volume) => volume.name === 'shm')) {
volumes.push(getshmVolume('2Gi'));
}

updatedServingRuntime.spec.volumes = volumes;

updatedServingRuntime.spec.containers = servingRuntime.spec.containers.map((container) => {
const volumeMounts = container.volumeMounts || [];
if (!volumeMounts.find((volumeMount) => volumeMount.mountPath === '/dev/shm')) {
volumeMounts.push(getshmVolumeMount());
}

return {
...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 c3b2b43

Please sign in to comment.