@rallycry/conveyor-k3 0.1.5 → 0.1.7
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/dist/cli.js +41 -20
- package/dist/vm-qemu.js +27 -19
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9427,9 +9427,10 @@ async function installUnits(ports, bundle, cloudflaredBin, maintenanceHour) {
|
|
|
9427
9427
|
changed = true;
|
|
9428
9428
|
}
|
|
9429
9429
|
if (changed) await runOrThrow(ports.exec, "systemctl", ["daemon-reload"]);
|
|
9430
|
-
await runOrThrow(ports.exec, "systemctl", ["enable",
|
|
9431
|
-
await runOrThrow(ports.exec, "systemctl", ["
|
|
9432
|
-
await runOrThrow(ports.exec, "systemctl", ["enable",
|
|
9430
|
+
await runOrThrow(ports.exec, "systemctl", ["enable", TUNNEL_UNIT]);
|
|
9431
|
+
await runOrThrow(ports.exec, "systemctl", ["restart", TUNNEL_UNIT]);
|
|
9432
|
+
await runOrThrow(ports.exec, "systemctl", ["enable", DAEMON_UNIT]);
|
|
9433
|
+
await runOrThrow(ports.exec, "systemctl", ["enable", UPDATE_TIMER]);
|
|
9433
9434
|
}
|
|
9434
9435
|
async function recordSetupState(ports, bundle, appliedVersion, bins) {
|
|
9435
9436
|
await ports.fs.ensureDir(STATE_DIR);
|
|
@@ -9472,6 +9473,25 @@ async function resolveBinaries(exec, state, selfPath) {
|
|
|
9472
9473
|
};
|
|
9473
9474
|
}
|
|
9474
9475
|
|
|
9476
|
+
// src/commands/setup-session.ts
|
|
9477
|
+
init_exec();
|
|
9478
|
+
async function withSetupConnection(ports, connection, enroll) {
|
|
9479
|
+
for (const unit of [UPDATE_TIMER, UPDATE_UNIT, DAEMON_UNIT]) {
|
|
9480
|
+
if (await ports.fs.readFile(`${SYSTEMD_DIR}/${unit}`))
|
|
9481
|
+
await runOrThrow(ports.exec, "systemctl", ["stop", unit]);
|
|
9482
|
+
}
|
|
9483
|
+
let result;
|
|
9484
|
+
try {
|
|
9485
|
+
await connection.connect();
|
|
9486
|
+
result = await enroll();
|
|
9487
|
+
} finally {
|
|
9488
|
+
connection.disconnect();
|
|
9489
|
+
}
|
|
9490
|
+
await runOrThrow(ports.exec, "systemctl", ["start", DAEMON_UNIT]);
|
|
9491
|
+
await runOrThrow(ports.exec, "systemctl", ["start", UPDATE_TIMER]);
|
|
9492
|
+
return result;
|
|
9493
|
+
}
|
|
9494
|
+
|
|
9475
9495
|
// src/lib/guest-vm.ts
|
|
9476
9496
|
async function requireGuestVm(exec) {
|
|
9477
9497
|
try {
|
|
@@ -10497,24 +10517,25 @@ async function runSetup(exec) {
|
|
|
10497
10517
|
const cloudflaredBin = await ensureCloudflared(ports);
|
|
10498
10518
|
await ensureCaPool(ports);
|
|
10499
10519
|
const connection = new ClusterConnection({ apiUrl: env.apiUrl, clusterToken: env.clusterToken });
|
|
10500
|
-
await connection
|
|
10501
|
-
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
|
|
10506
|
-
|
|
10507
|
-
|
|
10508
|
-
|
|
10509
|
-
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
|
|
10514
|
-
|
|
10515
|
-
|
|
10520
|
+
const bundle = await withSetupConnection(ports, connection, async () => {
|
|
10521
|
+
const enrollment = await connection.enroll();
|
|
10522
|
+
log(`Enrolled as ${enrollment.hostname}.`);
|
|
10523
|
+
await installUnits(ports, enrollment, cloudflaredBin, enrollment.desiredState.maintenance.hour);
|
|
10524
|
+
const runningConveyorPods = await countRunningConveyorPods(exec);
|
|
10525
|
+
const result = await reconcile(
|
|
10526
|
+
{ exec, fs: nodeFileSystem, runningConveyorPods },
|
|
10527
|
+
enrollment.desiredState
|
|
10528
|
+
);
|
|
10529
|
+
for (const warning of result.warnings) log(warning);
|
|
10530
|
+
const saToken = await mintServiceAccountToken(ports);
|
|
10531
|
+
await connection.completeEnrollment({ saToken });
|
|
10532
|
+
await recordSetupState(ports, enrollment, result.appliedVersion, {
|
|
10533
|
+
bun: await resolveBunBin(ports),
|
|
10534
|
+
cli: ports.cliBin,
|
|
10535
|
+
cloudflared: cloudflaredBin
|
|
10536
|
+
});
|
|
10537
|
+
return enrollment;
|
|
10516
10538
|
});
|
|
10517
|
-
connection.disconnect();
|
|
10518
10539
|
const registries = parseRegistries(await nodeFileSystem.readFile(REGISTRIES_FILE));
|
|
10519
10540
|
const missing = missingAuthHosts(registries, requiredAuthHosts(bundle.desiredState.namespaces));
|
|
10520
10541
|
log("");
|
package/dist/vm-qemu.js
CHANGED
|
@@ -472,7 +472,7 @@ import { join } from "path";
|
|
|
472
472
|
import { Socket } from "net";
|
|
473
473
|
var MAX_RELAYS = 16;
|
|
474
474
|
var MAX_RELAY_BYTES = 1024 * 1024 * 1024;
|
|
475
|
-
var
|
|
475
|
+
var RELAY_CONNECT_MS = 6e4;
|
|
476
476
|
var RELAY_IDLE_MS = 3e4;
|
|
477
477
|
var GUARD_FRESH_MS = 6e3;
|
|
478
478
|
var RELAY_PREFIX = "--conveyor-vm-relay";
|
|
@@ -665,10 +665,10 @@ function currentGuardStillValid(root, runId) {
|
|
|
665
665
|
return false;
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
|
-
function runRelay(root, invocation) {
|
|
669
|
-
return Promise.resolve().then(() => runRelayNow(root, invocation));
|
|
668
|
+
function runRelay(root, invocation, io) {
|
|
669
|
+
return Promise.resolve().then(() => runRelayNow(root, invocation, io));
|
|
670
670
|
}
|
|
671
|
-
function runRelayNow(root, invocation) {
|
|
671
|
+
function runRelayNow(root, invocation, io) {
|
|
672
672
|
const guard = readLiveGuard(root);
|
|
673
673
|
assertApprovedDestination(root, invocation);
|
|
674
674
|
const record = registerRelay(root, guard.runId);
|
|
@@ -677,15 +677,19 @@ function runRelayNow(root, invocation) {
|
|
|
677
677
|
let sent = 0;
|
|
678
678
|
let received = 0;
|
|
679
679
|
let guardTimer;
|
|
680
|
-
let
|
|
681
|
-
const socket =
|
|
680
|
+
let connectTimer;
|
|
681
|
+
const { socket, input, output } = io ?? {
|
|
682
|
+
socket: new Socket(),
|
|
683
|
+
input: process.stdin,
|
|
684
|
+
output: process.stdout
|
|
685
|
+
};
|
|
682
686
|
const finish = (error) => {
|
|
683
687
|
if (finished) return;
|
|
684
688
|
finished = true;
|
|
685
689
|
if (guardTimer) clearInterval(guardTimer);
|
|
686
|
-
if (
|
|
690
|
+
if (connectTimer) clearTimeout(connectTimer);
|
|
687
691
|
socket.destroy();
|
|
688
|
-
|
|
692
|
+
input.destroy();
|
|
689
693
|
try {
|
|
690
694
|
unregisterRelay(root, record);
|
|
691
695
|
} catch {
|
|
@@ -695,30 +699,34 @@ function runRelayNow(root, invocation) {
|
|
|
695
699
|
};
|
|
696
700
|
const exceedsLimit = (total) => total > MAX_RELAY_BYTES;
|
|
697
701
|
socket.setTimeout(RELAY_IDLE_MS, () => finish(new Error("VM relay idle timeout")));
|
|
702
|
+
socket.once("connect", () => {
|
|
703
|
+
if (connectTimer) clearTimeout(connectTimer);
|
|
704
|
+
connectTimer = void 0;
|
|
705
|
+
});
|
|
698
706
|
socket.on("error", () => finish(new Error("VM relay connection failed")));
|
|
699
707
|
socket.on("close", () => finish());
|
|
700
708
|
socket.on("data", (chunk) => {
|
|
701
709
|
received += chunk.length;
|
|
702
710
|
if (exceedsLimit(received)) return finish(new Error("VM relay receive limit exceeded"));
|
|
703
|
-
if (!
|
|
711
|
+
if (!output.write(chunk)) socket.pause();
|
|
704
712
|
});
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
713
|
+
output.on("drain", () => socket.resume());
|
|
714
|
+
output.on("error", () => finish(new Error("VM relay output failed")));
|
|
715
|
+
input.on("data", (chunk) => {
|
|
708
716
|
sent += chunk.length;
|
|
709
717
|
if (exceedsLimit(sent)) return finish(new Error("VM relay send limit exceeded"));
|
|
710
|
-
if (!socket.write(chunk))
|
|
718
|
+
if (!socket.write(chunk)) input.pause();
|
|
711
719
|
});
|
|
712
|
-
socket.on("drain", () =>
|
|
713
|
-
|
|
714
|
-
|
|
720
|
+
socket.on("drain", () => input.resume());
|
|
721
|
+
input.on("end", () => socket.end());
|
|
722
|
+
input.on("error", () => finish(new Error("VM relay input failed")));
|
|
715
723
|
guardTimer = setInterval(() => {
|
|
716
724
|
if (!currentGuardStillValid(root, record.runId))
|
|
717
725
|
finish(new Error("VM relay guard is no longer healthy"));
|
|
718
726
|
}, 2e3);
|
|
719
|
-
|
|
720
|
-
() => finish(new Error("VM relay
|
|
721
|
-
|
|
727
|
+
connectTimer = setTimeout(
|
|
728
|
+
() => finish(new Error("VM relay connection timed out")),
|
|
729
|
+
RELAY_CONNECT_MS
|
|
722
730
|
);
|
|
723
731
|
socket.connect(invocation.port, invocation.address);
|
|
724
732
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rallycry/conveyor-k3",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Managed personal compute for Conveyor. Installs and maintains a k3s cluster that runs your own card builds, kept converged on Conveyor's desired state.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflared",
|