Skip to content

Commit 0c33025

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). 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 6e5bd5e commit 0c33025

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

src/lib/nodes/create.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ function formatNodeDescription(
5656
* @returns Parsed count value
5757
* @throws CommanderError if invalid
5858
*/
59+
/**
60+
* Opt-in flag for InfiniBand-backed nodes. Gated behind the `infiniband-preview`
61+
* feature flag in `registerNodes`, so it is only added to `sf nodes create` for
62+
* accounts the server-side allowlist permits. The wire field is still in preview
63+
* (named `_preview_enable_infiniband`), so the option may change without notice.
64+
*/
65+
export const enableInfinibandOption = new Option(
66+
"--enable-infiniband",
67+
"Enable InfiniBand on the nodes (preview).",
68+
);
69+
5970
function validateCount(val: string): number {
6071
const parsed = Number.parseInt(val, 10);
6172
if (Number.isNaN(parsed) || parsed <= 0) {
@@ -240,7 +251,10 @@ Examples:\n
240251

241252
async function createNodesAction(
242253
names: typeof create.args,
243-
options: ReturnType<typeof create.opts> & { image?: string },
254+
options: ReturnType<typeof create.opts> & {
255+
image?: string;
256+
enableInfiniband?: boolean;
257+
},
244258
) {
245259
try {
246260
const client = await nodesClient();
@@ -274,6 +288,7 @@ async function createNodesAction(
274288
cloud_init_user_data: encodedUserData,
275289
image_id: options.image,
276290
node_type: isReserved ? "reserved" : "autoreserved",
291+
...(options.enableInfiniband ? { _preview_enable_infiniband: true } : {}),
277292
};
278293

279294
if (isReserved) {

src/lib/nodes/index.ts

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

4-
import create from "./create.ts";
4+
import { isFeatureEnabled } from "../posthog.ts";
5+
import create, { enableInfinibandOption } from "./create.ts";
56
import deleteCommand from "./delete.ts";
67
import extend from "./extend.ts";
78
import get from "./get.tsx";
@@ -13,7 +14,11 @@ import release from "./release.ts";
1314
import set from "./set.ts";
1415
import ssh from "./ssh.ts";
1516

16-
export function registerNodes(program: Command) {
17+
export async function registerNodes(program: Command) {
18+
if (await isFeatureEnabled("infiniband-preview")) {
19+
create.addOption(enableInfinibandOption);
20+
}
21+
1722
const nodes = program
1823
.command("nodes")
1924
.alias("node")

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)