Skip to content
Open
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
276 changes: 112 additions & 164 deletions bun.lock

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions cli/src/commands/deploy/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ export const deployCommandMeta: CommandMeta = {
target: "diskSize",
group: "advanced",
},
{
name: "fs",
description: "Filesystem type (ext4 or zfs, default: zfs)",
type: "string",
target: "fs",
group: "advanced",
},
{
name: "image",
description: "OS image version (auto-selected if omitted)",
Expand Down Expand Up @@ -279,6 +286,7 @@ export const deployCommandSchema = z.object({
vcpu: z.string().optional(),
memory: z.string().optional(),
diskSize: z.string().optional(),
fs: z.enum(["ext4", "zfs"]).optional(),
image: z.string().optional(),
region: z.string().optional(),
nodeId: z.string().optional(),
Expand Down
54 changes: 54 additions & 0 deletions cli/src/commands/deploy/handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,60 @@ describe("buildProvisionPayload", () => {
});
});

describe("storage_fs handling", () => {
test("should include storage_fs in compose_file when fs is 'ext4'", () => {
const options = {
fs: "ext4",
};

const payload = buildProvisionPayload(
options,
defaultName,
defaultDockerCompose,
defaultEnvs,
defaultPrivacySettings,
);

expect(
(payload.compose_file as Record<string, unknown>).storage_fs,
).toBe("ext4");
});

test("should include storage_fs in compose_file when fs is 'zfs'", () => {
const options = {
fs: "zfs",
};

const payload = buildProvisionPayload(
options,
defaultName,
defaultDockerCompose,
defaultEnvs,
defaultPrivacySettings,
);

expect(
(payload.compose_file as Record<string, unknown>).storage_fs,
).toBe("zfs");
});

test("should not include storage_fs in compose_file when fs is not specified", () => {
const options = {};

const payload = buildProvisionPayload(
options,
defaultName,
defaultDockerCompose,
defaultEnvs,
defaultPrivacySettings,
);

expect(
"storage_fs" in (payload.compose_file as Record<string, unknown>),
).toBe(false);
});
});

describe("pre-launch script handling", () => {
test("should include pre_launch_script in compose_file when provided", () => {
const options = {};
Expand Down
5 changes: 5 additions & 0 deletions cli/src/commands/deploy/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ interface Options {
vcpu?: string;
memory?: string;
diskSize?: string;
fs?: string;
image?: string;
region?: string;
nodeId?: string;
Expand Down Expand Up @@ -633,6 +634,10 @@ export const buildProvisionPayload = (
composeFile.pre_launch_script = preLaunchScriptContent;
}

if (options.fs) {
composeFile.storage_fs = options.fs;
}

const payload: Record<string, unknown> = {
name: name,
compose_file: composeFile,
Comment on lines 634 to 643
Copy link

Choose a reason for hiding this comment

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

Bug: When updating a CVM via phala deploy --cvm-id, the --fs option is silently ignored because updateCvm doesn't update the app_compose.storage_fs field.
Severity: MEDIUM

Suggested Fix

In the updateCvm function, update the app_compose object with the filesystem option before sending the update request. Add the following code: if (validatedOptions.fs) { app_compose.storage_fs = validatedOptions.fs; }.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: cli/src/commands/deploy/handler.ts#L635-L644

Potential issue: The `updateCvm` function, used for updating existing CVMs, does not
propagate the `fs` option to the `app_compose` object before sending the update request.
While new deployments correctly handle this option by setting `composeFile.storage_fs`,
the update path is missing this logic. As a result, if a user attempts to change the
filesystem on an existing CVM using the `--fs` flag (e.g., `phala deploy --cvm-id <id>
--fs ext4`), the flag is silently ignored, and the filesystem remains unchanged,
contrary to user expectation.

Did we get this right? 👍 / 👎 to inform future reviews.

Expand Down
3 changes: 2 additions & 1 deletion js/src/actions/cvms/provision_cvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import { isValidHostname } from "../../utils/hostname";
* const provision = await provisionCvm(client, {
* name: 'my-app',
* node_id: 123, // Specific node
* kms: 'PHALA', // KMS type (PHALA, BASE, ETHERUEM)
* kms: 'PHALA', // KMS type (PHALA, BASE, ETHEREUM)
* disk_size: 40,
* image: 'dstack-0.5.5',
* compose_file: { /* ... *\/ },
Expand Down Expand Up @@ -215,6 +215,7 @@ export const ProvisionCvmRequestSchema = z
public_sysinfo: z.boolean().optional(),
gateway_enabled: z.boolean().optional(), // recommended
tproxy_enabled: z.boolean().optional(), // deprecated, for compatibility
storage_fs: z.enum(["ext4", "zfs"]).optional(),
})
.superRefine((data, ctx) => {
validateComposePayloadSize(data.docker_compose_file, data.pre_launch_script, ctx);
Expand Down
1 change: 1 addition & 0 deletions js/src/types/app_compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const LooseAppComposeSchema = z
public_logs: z.boolean().optional(),
public_sysinfo: z.boolean().optional(),
tproxy_enabled: z.boolean().optional(),
storage_fs: z.enum(["ext4", "zfs"]).optional(),
pre_launch_script: z.string().optional(),
env_pubkey: z.string().optional(),
salt: z.string().optional().nullable(),
Expand Down