Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable selinux label when mounting the volume for the playground #457

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the implication of this security option ? Why does it is required ? I cannot really understand the link with applehv from the documentation https://docs.podman.io/en/v4.6.1/markdown/options/security-opt.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The volumes are not readable if this option is not set on Linux and applehv. Inspired from containers/podman#3683

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we might want to include this option on windows or we don't care ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is set for all platforms, I prefer to have a single general flow

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';