No defined way to deploy worker updates; worker hosts drift from the repo #40

Closed
opened 2026-11-22 01:01:14 -05:00 by jared · 2 comments
Owner

Problem

A merge to main auto-deploys the server through the deploy job in .gitea/workflows/lint.yml, which calls the pulse-deploy webhook. Nothing deploys worker/worker.js to the worker hosts. No one has a documented answer for which hosts run a worker, where it's installed, or how to update it. In practice it's done by hand and only occasionally.

Some planned fixes need a new worker, so this now blocks them:

  • #38: the worker has to send WORKER_API_KEY at the WebSocket handshake. Today it never sends the key at all (see worker_connect in worker/worker.js).
  • #8: cancel_command support, so aborts kill the process on the worker.
  • #7: the worker reports "at capacity" instead of dropping the command, and keeps results queued while disconnected.
  • #14: exit code and signal in failed results.

The server will keep accepting old workers until enforcement is turned on (WORKER_AUTH_ENFORCE, coming with #38), so nothing breaks in the meantime. But old workers will stay on the old behaviour until something updates them.

Proposed fix

  1. Inventory: list every worker host, its install path (README says /opt/pulse-worker), its systemd unit, and its Node version. Workers that are online report in the Workers tab and the workers table.
  2. Script: add scripts/deploy-worker.sh <host...>. It copies worker/worker.js plus package.json/package-lock.json over SSH, runs npm ci --omit=dev, restarts the unit, and then checks that the worker reconnects (status online in the API).
    • Alternatively, have each worker git pull a tagged release on start, or on a timer. That's more automatic, but it gives every worker host repo access.
  3. Version reporting: each worker sends a version (its git SHA or package.json version) in worker_connect and in heartbeat metadata. The Workers tab shows it, so drift is visible.
  4. Docs: document the process in the README. This overlaps #28 (the worker onboarding path is wrong).

Acceptance

  • One command updates every worker.
  • The Workers tab shows each worker's version.
  • The README explains how to add a worker and how to update all of them.

Related: #38, #8, #7, #14, #28.

## Problem A merge to `main` auto-deploys the **server** through the `deploy` job in `.gitea/workflows/lint.yml`, which calls the `pulse-deploy` webhook. Nothing deploys **`worker/worker.js`** to the worker hosts. No one has a documented answer for which hosts run a worker, where it's installed, or how to update it. In practice it's done by hand and only occasionally. Some planned fixes need a new worker, so this now blocks them: - **#38:** the worker has to send `WORKER_API_KEY` at the WebSocket handshake. Today it never sends the key at all (see `worker_connect` in `worker/worker.js`). - **#8:** `cancel_command` support, so aborts kill the process on the worker. - **#7:** the worker reports "at capacity" instead of dropping the command, and keeps results queued while disconnected. - **#14:** exit code and signal in failed results. The server will keep accepting old workers until enforcement is turned on (`WORKER_AUTH_ENFORCE`, coming with #38), so nothing breaks in the meantime. But old workers will stay on the old behaviour until something updates them. ## Proposed fix 1. **Inventory:** list every worker host, its install path (README says `/opt/pulse-worker`), its systemd unit, and its Node version. Workers that are online report in the Workers tab and the `workers` table. 2. **Script:** add `scripts/deploy-worker.sh <host...>`. It copies `worker/worker.js` plus `package.json`/`package-lock.json` over SSH, runs `npm ci --omit=dev`, restarts the unit, and then checks that the worker reconnects (status `online` in the API). - Alternatively, have each worker `git pull` a tagged release on start, or on a timer. That's more automatic, but it gives every worker host repo access. 3. **Version reporting:** each worker sends a version (its git SHA or `package.json` version) in `worker_connect` and in heartbeat metadata. The Workers tab shows it, so drift is visible. 4. **Docs:** document the process in the README. This overlaps #28 (the worker onboarding path is wrong). ## Acceptance - One command updates every worker. - The Workers tab shows each worker's version. - The README explains how to add a worker and how to update all of them. Related: #38, #8, #7, #14, #28.
Author
Owner

Inventory (2026-11-22)

  • Only one worker: pulse-worker-01, LXC CT 153 on monitor-01.
  • Install: /opt/pulse-worker/ contains worker.js, package.json and node_modules. It is not a git checkout. The unit is pulse-worker.service, running node worker.js as root, on Node v20.20.0.
  • Config deploy: CT 153 already runs a webhook.service (/usr/local/bin/pulse-worker-01_deploy.sh). It deploys only the systemd unit file, from jared/pve-infra (containers/153-pulse-worker-01/), not the worker code.
  • Drift: the installed worker.js was commit 2290d52 (2026-03-17), the last worker change before tonight.

Updated manually tonight

I updated it to main @ 8e77c1a, which includes #41 and #42:

  • Backup: worker.js.bak-2026-11-22.
  • Path used: ssh monitor-01 → pct push 153 → node --check → swap the file → systemctl restart pulse-worker.
  • The worker reconnected over the authenticated handshake, and Gandalf commands are completing again.

Suggested fix

Extend the existing pve-infra deploy for CT 153 to also install worker.js (and package.json/npm ci when they change) from a pinned Pulse release or commit. Then a push to pve-infra deploys the worker code the same way it already deploys the unit file. Adding version reporting to the Workers tab would make drift visible.

## Inventory (2026-11-22) - **Only one worker:** `pulse-worker-01`, LXC **CT 153** on `monitor-01`. - **Install:** `/opt/pulse-worker/` contains `worker.js`, `package.json` and `node_modules`. It is **not** a git checkout. The unit is `pulse-worker.service`, running `node worker.js` as root, on Node v20.20.0. - **Config deploy:** CT 153 already runs a `webhook.service` (`/usr/local/bin/pulse-worker-01_deploy.sh`). It deploys only the **systemd unit file**, from `jared/pve-infra` (`containers/153-pulse-worker-01/`), not the worker code. - **Drift:** the installed `worker.js` was commit `2290d52` (2026-03-17), the last worker change before tonight. ## Updated manually tonight I updated it to `main` @ `8e77c1a`, which includes #41 and #42: - Backup: `worker.js.bak-2026-11-22`. - Path used: `ssh monitor-01` → `pct push 153` → `node --check` → swap the file → `systemctl restart pulse-worker`. - The worker reconnected over the authenticated handshake, and Gandalf commands are completing again. ## Suggested fix Extend the existing pve-infra deploy for CT 153 to also install `worker.js` (and `package.json`/`npm ci` when they change) from a pinned Pulse release or commit. Then a push to pve-infra deploys the worker code the same way it already deploys the unit file. Adding version reporting to the Workers tab would make drift visible.
jared closed this issue 2026-11-22 18:58:07 -05:00
Author
Owner

Done in #54 and live. The first automated deploy (main run for e167e2f) went through:

Time Log entry on CT 153
19:03:48 deploying worker e167e2f… (previous unknown)
19:04:05 deployed worker e167e2f…: connected

/healthz now reports worker_versions: ["e167e2f…"], and 28 commands completed on the worker in the 10 minutes after the deploy.

Setup on CT 153:

  • /usr/local/bin/pulse_worker_deploy.sh
  • the pulse-worker-deploy hook in /etc/webhook/hooks.json (backup: hooks.json.bak-2026-11-22)
  • the repo secret WORKER_WEBHOOK_SECRET
  • a cached clone in /var/lib/pulse-worker-deploy/repo

Still to do: show the version in the Workers tab. The data is already in the heartbeat metadata (metadata.version); it's a UI change, so it needs a screenshot PR. Also, when deploy/pulse_worker_deploy.sh itself changes, the installed copy has to be updated by hand, the same as the server's deploy script.

**Done in #54 and live.** The first automated deploy (main run for `e167e2f`) went through: | Time | Log entry on CT 153 | |---|---| | 19:03:48 | `deploying worker e167e2f… (previous unknown)` | | 19:04:05 | `deployed worker e167e2f…: connected` | `/healthz` now reports `worker_versions: ["e167e2f…"]`, and 28 commands completed on the worker in the 10 minutes after the deploy. **Setup on CT 153:** - `/usr/local/bin/pulse_worker_deploy.sh` - the `pulse-worker-deploy` hook in `/etc/webhook/hooks.json` (backup: `hooks.json.bak-2026-11-22`) - the repo secret `WORKER_WEBHOOK_SECRET` - a cached clone in `/var/lib/pulse-worker-deploy/repo` **Still to do:** show the version in the Workers tab. The data is already in the heartbeat metadata (`metadata.version`); it's a UI change, so it needs a screenshot PR. Also, when `deploy/pulse_worker_deploy.sh` itself changes, the installed copy has to be updated by hand, the same as the server's deploy script.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/pulse#40