Skip to content

Commit b620823

Browse files
feat(nodes): add feature-flag-gated --enable-infiniband to sf nodes create
The option is only mounted when the user's account has the `infiniband-preview` flag enabled (checked via the existing posthog/ feature-flag helper) and forwarded to the create factory. When enabled, it shows up in `sf nodes create --help` and forwards `_preview_enable_infiniband: true` to the nodes SDK, exposing the InfiniBand preview surface in the sfcompute/sfcompute API. Generated with [Indent](https://indent.com) Co-Authored-By: Indent <noreply@indent.com>
1 parent f60fb3e commit b620823

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

src/lib/nodes/create.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ function validateCount(val: string): number {
6868
return parsed;
6969
}
7070

71-
export function createCreateCommand() {
71+
export function createCreateCommand({
72+
enableInfiniband,
73+
}: {
74+
enableInfiniband: boolean;
75+
}) {
7276
const create = new Command("create")
7377
.description("Create reserved or auto reserved nodes")
7478
.showHelpAfterError()
@@ -240,12 +244,22 @@ Examples:\n
240244
)
241245
.action(createNodesAction);
242246

247+
if (enableInfiniband) {
248+
create.addOption(
249+
new Option(
250+
"--enable-infiniband",
251+
"Enable InfiniBand passthrough on the node VMs.",
252+
),
253+
);
254+
}
255+
243256
return create;
244257

245258
async function createNodesAction(
246259
names: typeof create.args,
247260
options: ReturnType<typeof create.opts> & {
248261
image?: string;
262+
enableInfiniband?: boolean;
249263
},
250264
) {
251265
try {
@@ -282,6 +296,9 @@ Examples:\n
282296
cloud_init_user_data: encodedUserData,
283297
image_id: options.image,
284298
node_type: isReserved ? "reserved" : "autoreserved",
299+
...(options.enableInfiniband
300+
? { _preview_enable_infiniband: true }
301+
: {}),
285302
};
286303

287304
if (isReserved) {

src/lib/nodes/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import console from "node:console";
22
import type { Command } from "@commander-js/extra-typings";
33

4+
import { isFeatureEnabled } from "../posthog.ts";
45
import { createCreateCommand } from "./create.ts";
56
import deleteCommand from "./delete.ts";
67
import extend from "./extend.ts";
@@ -14,14 +15,16 @@ import set from "./set.ts";
1415
import ssh from "./ssh.ts";
1516

1617
export async function registerNodes(program: Command) {
18+
const enableInfiniband = await isFeatureEnabled("infiniband-preview");
19+
1720
const nodes = program
1821
.command("nodes")
1922
.alias("node")
2023
.showHelpAfterError()
2124
.description("Manage compute nodes")
2225
.addCommand(list)
2326
.addCommand(get)
24-
.addCommand(createCreateCommand())
27+
.addCommand(createCreateCommand({ enableInfiniband }))
2528
.addCommand(extend)
2629
.addCommand(release)
2730
.addCommand(deleteCommand)

src/lib/posthog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const trackEvent = ({
6262
}
6363
};
6464

65-
type FeatureFlags = "procurements" | "zones";
65+
type FeatureFlags = "procurements" | "zones" | "infiniband-preview";
6666

6767
/**
6868
* Checks if a feature is enabled for the current user.

0 commit comments

Comments
 (0)