@rallycry/conveyor-k3 0.1.6 → 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.
Files changed (2) hide show
  1. package/dist/cli.js +41 -20
  2. 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", "--now", TUNNEL_UNIT]);
9431
- await runOrThrow(ports.exec, "systemctl", ["enable", "--now", DAEMON_UNIT]);
9432
- await runOrThrow(ports.exec, "systemctl", ["enable", "--now", UPDATE_TIMER]);
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.connect();
10501
- const bundle = await connection.enroll();
10502
- log(`Enrolled as ${bundle.hostname}.`);
10503
- await installUnits(ports, bundle, cloudflaredBin, bundle.desiredState.maintenance.hour);
10504
- const runningConveyorPods = await countRunningConveyorPods(exec);
10505
- const result = await reconcile(
10506
- { exec, fs: nodeFileSystem, runningConveyorPods },
10507
- bundle.desiredState
10508
- );
10509
- for (const warning of result.warnings) log(warning);
10510
- const saToken = await mintServiceAccountToken(ports);
10511
- await connection.completeEnrollment({ saToken });
10512
- await recordSetupState(ports, bundle, result.appliedVersion, {
10513
- bun: await resolveBunBin(ports),
10514
- cli: ports.cliBin,
10515
- cloudflared: cloudflaredBin
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rallycry/conveyor-k3",
3
- "version": "0.1.6",
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",