@exla/rudder 4.1.2 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cloud/README.md +337 -0
- package/cloud/host/90-rudder.conf +10 -0
- package/cloud/host/rudder-home-apply-update +66 -0
- package/cloud/host/rudder-home-start +37 -0
- package/cloud/host/rudder-home-update.path +9 -0
- package/cloud/host/rudder-home-update.service +9 -0
- package/cloud/host/rudder-home.service +17 -0
- package/cloud/host/rudder-host-setup +65 -0
- package/cloud/package.json +37 -0
- package/dist/cloud-host.d.ts +26 -0
- package/dist/cloud-host.js +229 -0
- package/dist/cloud-host.js.map +1 -0
- package/dist/cloud.js +11 -0
- package/dist/cloud.js.map +1 -1
- package/dist/home-scratch.d.ts +1 -0
- package/dist/home-scratch.js +23 -0
- package/dist/home-scratch.js.map +1 -0
- package/dist/native/darwin-arm64/native-manifest.json +3 -3
- package/dist/native/darwin-arm64/rudder-native +0 -0
- package/dist/native/linux-x64/native-manifest.json +3 -3
- package/dist/native/linux-x64/rudder-native +0 -0
- package/dist/run-manager.js +2 -1
- package/dist/run-manager.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// `rudder cloud host <ssh-target>`: run the Rudder Cloud home on any Linux host
|
|
2
|
+
// with Docker (a bare-metal box, a cloud VM) instead of a Fly machine. The
|
|
3
|
+
// host side is cloud/host/ (setup script, start and update scripts, systemd
|
|
4
|
+
// units); the control plane side is cloud/src/home-host.ts.
|
|
5
|
+
//
|
|
6
|
+
// 1. copy cloud/host to the host and run rudder-host-setup (Docker, rsync,
|
|
7
|
+
// sysctls, the data disk at /srv/workspace, the units)
|
|
8
|
+
// 2. check the host can pull the current worker image
|
|
9
|
+
// 3. POST /api/rudder/home/host {kind:"external"}: the control plane rotates
|
|
10
|
+
// the worker token (the Fly machine's stops working) and returns the env
|
|
11
|
+
// bundle once
|
|
12
|
+
// 4. write it to /etc/rudder/home.env (0600) over ssh stdin, never argv, and
|
|
13
|
+
// the image to /etc/rudder/image, then start rudder-home.service
|
|
14
|
+
//
|
|
15
|
+
// Moving the disk is the operator's step (--copy-from-fly prints it): the home
|
|
16
|
+
// on the new host starts from whatever /srv/workspace holds.
|
|
17
|
+
import { spawn } from "node:child_process";
|
|
18
|
+
import { randomBytes } from "node:crypto";
|
|
19
|
+
import fs from "node:fs";
|
|
20
|
+
import path from "node:path";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
const USAGE = "Usage: rudder cloud host <ssh-target> [--data-disk /dev/X] [--hostname <name>] [--skip-setup] [--copy-from-fly] [--yes]";
|
|
23
|
+
// The files rudder-host-setup installs; it must sit beside them.
|
|
24
|
+
export const HOST_FILES = [
|
|
25
|
+
"rudder-host-setup",
|
|
26
|
+
"rudder-home-start",
|
|
27
|
+
"rudder-home-apply-update",
|
|
28
|
+
"rudder-home.service",
|
|
29
|
+
"rudder-home-update.service",
|
|
30
|
+
"rudder-home-update.path",
|
|
31
|
+
"90-rudder.conf",
|
|
32
|
+
];
|
|
33
|
+
// The same shape cloud/worker/home-host.mjs and rudder-home-apply-update accept.
|
|
34
|
+
export function validImage(value) {
|
|
35
|
+
return typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._/:@-]{0,255}$/.test(value);
|
|
36
|
+
}
|
|
37
|
+
export function parseHostArgs(args, yes = false) {
|
|
38
|
+
const parsed = { target: "", copyFromFly: false, skipSetup: false, yes };
|
|
39
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
40
|
+
const arg = args[i] ?? "";
|
|
41
|
+
const [flag, inline] = arg.startsWith("--") && arg.includes("=") ? [arg.slice(0, arg.indexOf("=")), arg.slice(arg.indexOf("=") + 1)] : [arg, undefined];
|
|
42
|
+
const value = () => {
|
|
43
|
+
const next = inline ?? args[++i];
|
|
44
|
+
if (!next || next.startsWith("-"))
|
|
45
|
+
throw new Error(`${flag} needs a value. ${USAGE}`);
|
|
46
|
+
return next;
|
|
47
|
+
};
|
|
48
|
+
if (flag === "--data-disk")
|
|
49
|
+
parsed.dataDisk = value();
|
|
50
|
+
else if (flag === "--hostname")
|
|
51
|
+
parsed.hostname = value();
|
|
52
|
+
else if (flag === "--copy-from-fly")
|
|
53
|
+
parsed.copyFromFly = true;
|
|
54
|
+
else if (flag === "--skip-setup")
|
|
55
|
+
parsed.skipSetup = true;
|
|
56
|
+
else if (flag === "--yes" || flag === "-y")
|
|
57
|
+
parsed.yes = true;
|
|
58
|
+
else if (!arg.startsWith("-") && !parsed.target)
|
|
59
|
+
parsed.target = arg;
|
|
60
|
+
else
|
|
61
|
+
throw new Error(`unexpected argument ${arg}. ${USAGE}`);
|
|
62
|
+
}
|
|
63
|
+
// Arguments reach ssh as argv, never through a shell, but a target that
|
|
64
|
+
// looks like an option would still be read as one.
|
|
65
|
+
if (!/^[A-Za-z0-9._@:\[\]-]+$/.test(parsed.target) || parsed.target.startsWith("-")) {
|
|
66
|
+
throw new Error(USAGE);
|
|
67
|
+
}
|
|
68
|
+
if (parsed.dataDisk !== undefined && !/^\/dev\/[A-Za-z0-9/_-]+$/.test(parsed.dataDisk)) {
|
|
69
|
+
throw new Error("--data-disk must be a device path like /dev/nvme1n1");
|
|
70
|
+
}
|
|
71
|
+
if (parsed.hostname !== undefined && !/^[A-Za-z0-9][A-Za-z0-9-]{0,62}$/.test(parsed.hostname)) {
|
|
72
|
+
throw new Error("--hostname must be a single DNS label");
|
|
73
|
+
}
|
|
74
|
+
return parsed;
|
|
75
|
+
}
|
|
76
|
+
/** The env bundle as a Docker --env-file. Refuses anything that would not round-trip. */
|
|
77
|
+
export function renderHomeEnv(env) {
|
|
78
|
+
const lines = [];
|
|
79
|
+
for (const [key, value] of Object.entries(env)) {
|
|
80
|
+
if (!/^[A-Z][A-Z0-9_]*$/.test(key) || typeof value !== "string" || /[\r\n\0]/.test(value)) {
|
|
81
|
+
throw new Error(`the control plane returned an env entry that cannot go in an env file (${key})`);
|
|
82
|
+
}
|
|
83
|
+
lines.push(`${key}=${value}`);
|
|
84
|
+
}
|
|
85
|
+
if (!lines.some((line) => line.startsWith("RUDDER_WORKER_TOKEN="))) {
|
|
86
|
+
throw new Error("the control plane did not return a worker token");
|
|
87
|
+
}
|
|
88
|
+
return `${lines.join("\n")}\n`;
|
|
89
|
+
}
|
|
90
|
+
/** The manual disk copy from the Fly home, printed by --copy-from-fly. */
|
|
91
|
+
export function copyFromFlySteps(target, filesDir = hostFilesDir()) {
|
|
92
|
+
return `Copy the Fly home's disk to ${target} before switching; the home keeps running on Fly until step 4.
|
|
93
|
+
|
|
94
|
+
1. Prepare the host without switching it over:
|
|
95
|
+
scp -r ${filesDir} ${target}:rudder-host
|
|
96
|
+
ssh ${target} sudo rudder-host/rudder-host-setup [--data-disk /dev/<disk>]
|
|
97
|
+
2. Bulk copy while agents keep working (repeat as often as you like). In
|
|
98
|
+
\`fly ssh console\` on the home machine: apt-get install -y rsync, add a key
|
|
99
|
+
${target} accepts, then
|
|
100
|
+
rsync -aHAX --numeric-ids --info=progress2 --exclude=/.rudder-swap \\
|
|
101
|
+
--rsync-path="sudo rsync" /workspace/ ${target}:/srv/workspace/
|
|
102
|
+
3. Freeze it: stop the home (rudder cloud home stop), start the Fly machine with
|
|
103
|
+
/bin/sleep infinity as its init so no agent writes, and run the rsync once
|
|
104
|
+
more with --delete.
|
|
105
|
+
4. Switch: rudder cloud host ${target} --skip-setup
|
|
106
|
+
The Fly machine and volume are left as they are; destroy them once the new
|
|
107
|
+
host checks out.`;
|
|
108
|
+
}
|
|
109
|
+
export function hostFilesDir() {
|
|
110
|
+
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "cloud", "host");
|
|
111
|
+
}
|
|
112
|
+
function run(command, args, options = {}) {
|
|
113
|
+
return new Promise((resolve, reject) => {
|
|
114
|
+
const child = spawn(command, args, {
|
|
115
|
+
stdio: [options.input === undefined ? (options.inherit ? "inherit" : "ignore") : "pipe", options.inherit ? "inherit" : "pipe", "inherit"],
|
|
116
|
+
});
|
|
117
|
+
let stdout = "";
|
|
118
|
+
child.stdout?.on("data", (chunk) => { stdout += String(chunk); });
|
|
119
|
+
child.on("error", reject);
|
|
120
|
+
child.on("close", (code) => resolve({ code: code ?? 1, stdout }));
|
|
121
|
+
if (options.input !== undefined) {
|
|
122
|
+
child.stdin?.end(options.input);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
async function ssh(target, remote, options = {}) {
|
|
127
|
+
return await run("ssh", ["-o", "BatchMode=yes", target, ...remote], options);
|
|
128
|
+
}
|
|
129
|
+
async function must(step, result) {
|
|
130
|
+
const done = await result;
|
|
131
|
+
if (done.code !== 0) {
|
|
132
|
+
throw new Error(`${step} failed (exit ${done.code})`);
|
|
133
|
+
}
|
|
134
|
+
return done;
|
|
135
|
+
}
|
|
136
|
+
async function confirmSwitch(target, yes) {
|
|
137
|
+
if (yes) {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
141
|
+
throw new Error("Refusing to switch the home without confirmation; pass --yes to confirm.");
|
|
142
|
+
}
|
|
143
|
+
const readline = await import("node:readline/promises");
|
|
144
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
145
|
+
try {
|
|
146
|
+
const answer = await rl.question(`Run your home on ${target}? Its Fly machine stops being able to connect, and the home starts from what ${target}:/srv/workspace holds. [y/N] `);
|
|
147
|
+
return /^y(es)?$/i.test(answer.trim());
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
rl.close();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
export async function hostCommand(rawArgs, client, options) {
|
|
154
|
+
const args = parseHostArgs(rawArgs, Boolean(options.yes));
|
|
155
|
+
if (args.copyFromFly) {
|
|
156
|
+
console.log(copyFromFlySteps(args.target));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const current = await client.request("/api/rudder/home/host", { method: "GET" });
|
|
160
|
+
if (!current.home) {
|
|
161
|
+
throw new Error("you have no cloud home yet; create one with `rudder cloud` first");
|
|
162
|
+
}
|
|
163
|
+
// ssh joins its remote argv into one shell line, so every value placed there
|
|
164
|
+
// has a shape with nothing a shell would read.
|
|
165
|
+
if (!validImage(current.image)) {
|
|
166
|
+
throw new Error("the control plane returned an image reference this command will not pass to a shell");
|
|
167
|
+
}
|
|
168
|
+
await must(`ssh ${args.target}`, ssh(args.target, ["sudo", "-n", "true"]));
|
|
169
|
+
if (!args.skipSetup) {
|
|
170
|
+
const dir = hostFilesDir();
|
|
171
|
+
const files = HOST_FILES.map((name) => path.join(dir, name));
|
|
172
|
+
for (const file of files) {
|
|
173
|
+
if (!fs.existsSync(file))
|
|
174
|
+
throw new Error(`missing ${file}; reinstall rudder`);
|
|
175
|
+
}
|
|
176
|
+
const remoteDir = `rudder-host-${randomBytes(4).toString("hex")}`;
|
|
177
|
+
console.log(`Setting up ${args.target} (Docker, sysctls, /srv/workspace, systemd units)...`);
|
|
178
|
+
await must("mkdir on the host", ssh(args.target, ["mkdir", "-p", remoteDir]));
|
|
179
|
+
await must("copying cloud/host", run("scp", ["-q", "-o", "BatchMode=yes", ...files, `${args.target}:${remoteDir}/`]));
|
|
180
|
+
await must("rudder-host-setup", ssh(args.target, ["sudo", "-n", `./${remoteDir}/rudder-host-setup`, ...(args.dataDisk ? ["--data-disk", args.dataDisk] : [])], { inherit: true }));
|
|
181
|
+
await ssh(args.target, ["rm", "-rf", remoteDir]);
|
|
182
|
+
}
|
|
183
|
+
// Before anything changes: a host that cannot pull the image would leave
|
|
184
|
+
// the home switched over with nothing able to run it.
|
|
185
|
+
console.log(`Pulling ${current.image} on ${args.target}...`);
|
|
186
|
+
const pulled = await ssh(args.target, ["sudo", "-n", "docker", "pull", "-q", current.image]);
|
|
187
|
+
if (pulled.code !== 0) {
|
|
188
|
+
throw new Error(`${args.target} cannot pull ${current.image}. Log it in to the registry first (for registry.fly.io: \`fly auth token\` on a laptop, then on the host \`sudo docker login registry.fly.io -u x --password-stdin\`), then run this again.`);
|
|
189
|
+
}
|
|
190
|
+
if (!(await confirmSwitch(args.target, args.yes))) {
|
|
191
|
+
console.log("Nothing changed.");
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const switched = await client.request("/api/rudder/home/host", {
|
|
195
|
+
method: "POST",
|
|
196
|
+
body: { kind: "external" },
|
|
197
|
+
});
|
|
198
|
+
const envFile = renderHomeEnv(switched.env);
|
|
199
|
+
const recover = `The home is switched but ${args.target} is not running it yet; run \`rudder cloud host ${args.target} --skip-setup\` again.`;
|
|
200
|
+
try {
|
|
201
|
+
// stdin, never argv: the token must not show up in a process list.
|
|
202
|
+
await must("writing /etc/rudder/home.env", ssh(args.target, ["sudo", "-n", "install", "-m", "600", "-o", "root", "-g", "root", "/dev/stdin", "/etc/rudder/home.env"], { input: envFile }));
|
|
203
|
+
await must("writing /etc/rudder/image", ssh(args.target, ["sudo", "-n", "install", "-m", "644", "/dev/stdin", "/etc/rudder/image"], { input: `${switched.image}\n` }));
|
|
204
|
+
if (args.hostname) {
|
|
205
|
+
await must("writing /etc/rudder/hostname", ssh(args.target, ["sudo", "-n", "install", "-m", "644", "/dev/stdin", "/etc/rudder/hostname"], { input: `${args.hostname}\n` }));
|
|
206
|
+
}
|
|
207
|
+
await must("starting rudder-home", ssh(args.target, ["sudo", "-n", "systemctl", "restart", "rudder-home.service"], { inherit: true }));
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
throw new Error(`${error instanceof Error ? error.message : String(error)}. ${recover}`);
|
|
211
|
+
}
|
|
212
|
+
console.log(`Waiting for the home on ${args.target} to connect...`);
|
|
213
|
+
for (let i = 0; i < 60; i += 1) {
|
|
214
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
215
|
+
const { home } = await client.request("/api/rudder/home", { method: "GET" }).catch(() => ({ home: null }));
|
|
216
|
+
if (home?.connected) {
|
|
217
|
+
if (options.json) {
|
|
218
|
+
console.log(JSON.stringify({ home, hostKind: "external", image: switched.image, target: args.target }, null, 2));
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
console.log(`Your home runs on ${args.target} now (${switched.image}). Updates arrive there when it is idle.`);
|
|
222
|
+
console.log("The Fly machine and volume were left as they are; destroy them once everything checks out.");
|
|
223
|
+
}
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
throw new Error(`the home did not connect within 3 minutes; check \`sudo systemctl status rudder-home\` and \`sudo docker logs rudder-home\` on ${args.target}`);
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=cloud-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-host.js","sourceRoot":"","sources":["../src/cloud-host.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,2EAA2E;AAC3E,4EAA4E;AAC5E,4DAA4D;AAC5D,EAAE;AACF,6EAA6E;AAC7E,4DAA4D;AAC5D,wDAAwD;AACxD,+EAA+E;AAC/E,8EAA8E;AAC9E,mBAAmB;AACnB,+EAA+E;AAC/E,sEAAsE;AACtE,EAAE;AACF,+EAA+E;AAC/E,6DAA6D;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAiBzC,MAAM,KAAK,GAAG,yHAAyH,CAAC;AACxI,iEAAiE;AACjE,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,mBAAmB;IACnB,mBAAmB;IACnB,0BAA0B;IAC1B,qBAAqB;IACrB,4BAA4B;IAC5B,yBAAyB;IACzB,gBAAgB;CACjB,CAAC;AAEF,iFAAiF;AACjF,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK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IAAI,CAAC,MAAM,SAAS,QAAQ,CAAC,KAAK,0CAA0C,CAAC,CAAC;gBAC/G,OAAO,CAAC,GAAG,CAAC,4FAA4F,CAAC,CAAC;YAC5G,CAAC;YACD,OAAO;QACT,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,kIAAkI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AACnK,CAAC"}
|
package/dist/cloud.js
CHANGED
|
@@ -14,6 +14,7 @@ import { runLaptopOnboarding } from "./onboarding.js";
|
|
|
14
14
|
import { renderQrForTerminal } from "./qr.js";
|
|
15
15
|
import { describeSync, exportWork, importWork, syncCheckout } from "./checkout-sync.js";
|
|
16
16
|
import { pullFromHome } from "./cloud-pull.js";
|
|
17
|
+
import { hostCommand } from "./cloud-host.js";
|
|
17
18
|
import { localTailnetStatus, previewReachable } from "./tailscale-preview.js";
|
|
18
19
|
import { ensureDir, commandExists, expandHome, isTty, newRunId, nowIso, pathExists, promptConfirm, promptSecret, readJson, runCommand, shortenHome, writeJson, } from "./util.js";
|
|
19
20
|
const DEFAULT_LOGIN_INTERVAL_MS = 2000;
|
|
@@ -140,6 +141,12 @@ export async function runCloudCommand(command, args, options = {}) {
|
|
|
140
141
|
case "home":
|
|
141
142
|
await homeCommand(rest, options);
|
|
142
143
|
return;
|
|
144
|
+
case "host":
|
|
145
|
+
if (process.env.RUDDER_CLOUD_RUNTIME === "home") {
|
|
146
|
+
throw new Error("run this from your laptop: moving the home to another host restarts it.");
|
|
147
|
+
}
|
|
148
|
+
await hostCommand(rest, await cloudClient({ requireToken: true }), options);
|
|
149
|
+
return;
|
|
143
150
|
case "preview":
|
|
144
151
|
await cloudPreviewCommand(rest, options);
|
|
145
152
|
return;
|
|
@@ -3354,6 +3361,10 @@ Usage:
|
|
|
3354
3361
|
holds every repo) and attach to its dashboard. --snapshot uploads this
|
|
3355
3362
|
folder to its own machine instead.
|
|
3356
3363
|
rudder cloud home [status|start|stop|open <owner/repo>]
|
|
3364
|
+
rudder cloud host <ssh-target> [--data-disk /dev/X] [--hostname <name>] [--skip-setup] [--copy-from-fly] [--yes]
|
|
3365
|
+
run your home on any Linux host with Docker instead of Fly: sets the
|
|
3366
|
+
host up, then switches the home there (its Fly machine and volume stay
|
|
3367
|
+
as they are). --copy-from-fly prints how to copy the Fly disk first
|
|
3357
3368
|
rudder cloud preview [preview-id] [--list] [--json]
|
|
3358
3369
|
list registered private previews; open the exact preview-id over Tailscale
|
|
3359
3370
|
rudder cloud move [runId...] [--yes]
|