Skip to content

Commit

Permalink
fix: disable selinux label when mounting the volume for the playground (
Browse files Browse the repository at this point in the history
#457)

Fixes #456

Signed-off-by: Jeff MAURY <[email protected]>
  • Loading branch information
jeffmaury authored Mar 7, 2024
1 parent b0ff03e commit e66da3d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/backend/src/managers/playground.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type { ImageInfo, TelemetryLogger, Webview } from '@podman-desktop/api';
import type { ModelInfo } from '@shared/src/models/IModelInfo';
import OpenAI from 'openai';
import { Stream } from 'openai/streaming';
import { DISABLE_SELINUX_LABEL_SECURITY_OPTION } from '../utils/utils';

const mocks = vi.hoisted(() => ({
postMessage: vi.fn(),
Expand Down Expand Up @@ -138,6 +139,7 @@ test('startPlayground should download image if not present then create container
Type: 'bind',
},
],
SecurityOpt: [DISABLE_SELINUX_LABEL_SECURITY_OPTION],
PortBindings: {
'8000/tcp': [
{
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/managers/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import type { PlaygroundState, PlaygroundStatus } from '@shared/src/models/IPlay
import type { ContainerRegistry } from '../registries/ContainerRegistry';
import type { PodmanConnection } from './podmanConnection';
import OpenAI from 'openai';
import { getDurationSecondsSince, timeout } from '../utils/utils';
import { DISABLE_SELINUX_LABEL_SECURITY_OPTION, getDurationSecondsSince, timeout } from '../utils/utils';
import type { ModelInfo } from '@shared/src/models/IModelInfo';

export const LABEL_MODEL_ID = 'ai-studio-model-id';
Expand Down Expand Up @@ -212,6 +212,7 @@ export class PlayGroundManager {
Type: 'bind',
},
],
SecurityOpt: [DISABLE_SELINUX_LABEL_SECURITY_OPTION],
PortBindings: {
'8000/tcp': [
{
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ export async function isEndpointAlive(endPoint: string): Promise<boolean> {
export function getDurationSecondsSince(startTimeMs: number) {
return Math.round((performance.now() - startTimeMs) / 1000);
}

export const DISABLE_SELINUX_LABEL_SECURITY_OPTION = 'label=disable';

0 comments on commit e66da3d

Please sign in to comment.