Worker hosts keep the same keys in setup.env, env and every env.N

Open
#63 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
bash, python

Research direction

Start with setup-scripts/debian13-worker/lib.sh and run-fleet.sh to trace how environment files are stamped, worker names are chosen, and slots are pruned; then inspect Makefile and ops/release/install-release.sh for env-file use and the pre-swap gate. Read the existing bats tests before choosing a layout, and add migration coverage for old hosts, per-slot keys, names, and rollback behavior. Done means all acceptance criteria pass, including the README, example config, and Unreleased changelog updates.

Written by the indexing model from the issue text.

Description

client enhancement P3 question

Problem

A fleet worker host has three kinds of environment file in the config directory (setup-scripts/debian13-worker/README.md:35-42):

  • setup.env: provisioning config that the operator edits. It is sourced by bash and uses shell quoting, including multi-line values such as EXTRA_ENV.
  • env: the base worker env, written by setup-scripts/debian13-worker/03-worker-env.sh:26.
  • env.N: one per worker, written by setup-scripts/debian13-worker/run-fleet.sh:174. The Makefile points WORKER_ENV_HOST at it (Makefile:210) and passes it to podman run --env-file (Makefile:979).

stamp_worker_env copies the same keys from setup.env into env and into every env.N: ORCH_BASE_URL, ORCH_ENROLLMENT_TOKEN, the disk gate, the isolation flags and the full EXTRA_ENV block (setup-scripts/debian13-worker/lib.sh:651, :681-721). With two workers, a secret in EXTRA_ENV sits at rest in four files.

Other points:

  • The base env is not used in the fleet flow. The script says so itself (setup-scripts/debian13-worker/03-worker-env.sh:15-20).
  • ORCH_API_KEY is stamped and preserved (setup-scripts/debian13-worker/lib.sh:658, :686), but the worker never reads it. Credentials come from state.json (client/src/orcaster_worker/config.py:4-5). run-fleet.sh still uses it as a credentials signal (setup-scripts/debian13-worker/run-fleet.sh:202).
  • A hand edit to an env.N is lost on the next run-fleet.sh run, except ORCH_WORKER_NAME, the token and a previous ORCH_ENFORCE_ISOLATION value (setup-scripts/debian13-worker/lib.sh:656-677). The only value that really differs per worker is ORCH_WORKER_NAME (setup-scripts/debian13-worker/run-fleet.sh:150-160).
  • Changing one value (for example rotating a secret in EXTRA_ENV) means editing setup.env and re-stamping every worker.

setup.env cannot be passed to --env-file as is: podman does not understand its shell quoting, and the file also holds provisioning-only keys (WORKER_COUNT, WORKER_MEMORY, and others).

Proposed change

Keep each key in one file at rest. Two layouts are possible (see Open questions).

Option A: setup.env is the only file. make up client N=<n> reads setup.env, builds the container env (the ORCH_* keys, the EXTRA_ENV lines and ORCH_WORKER_NAME for slot N) and passes it to podman with -e or through a 0600 temporary file that is removed even when podman run fails. env and env.N are no longer written.

Option B: two files with no overlap. setup.env keeps only provisioning keys. One shared env (in --env-file format) holds the container keys. The Makefile passes ORCH_WORKER_NAME with -e. env.N is no longer written.

In both options:

  1. Stop stamping ORCH_API_KEY, and stop using it as a credentials signal in run-fleet.sh. Keep the state.json check.
  2. Keep each worker's current name. Today a non-empty ORCH_WORKER_NAME in env.N wins over PREFIX-N. The new layout needs a place for per-slot name overrides, and the migration must copy existing names there.
  3. Move slot ownership away from the env.N glob. The prune of surplus workers (setup-scripts/debian13-worker/run-fleet.sh:284-307) and the pre-swap gate of ops/release/install-release.sh (:892-910) use the existence of env.N as proof that a slot exists. They need another source, for example WORKER_COUNT plus the existing containers and volumes.
  4. Update setup-scripts/debian13-worker/README.md, ops/release/README.md and setup.env.example.

Compatibility

Existing hosts have setup.env, env and env.N files, enrolled workers with state.json in their volumes, and possibly hand-set worker names in env.N.

Guard:

  • The first run-fleet.sh or install-release.sh run on an old layout migrates in place. It reads names from env.N, never re-enrolls a worker, and never touches worker volumes or state.json.
  • The migration keeps every key of an env.N that setup.env does not produce (for example a hand-added ORCH_FLUSH_MARKERS line, or a previous ORCH_ENFORCE_ISOLATION value). It moves those keys to the new layout, or it refuses to migrate and names the keys (never the values). It never drops a key silently.
  • A carried key can have different values in different env.N files. ORCH_ENFORCE_ISOLATION does today: slots whose env.N existed at upgrade get false, slots created later get true (setup-scripts/debian13-worker/lib.sh:671-676). A shared layout cannot hold both. Such a key is kept per slot, or the migration refuses and names the key (never the values).
  • During one release, the Makefile and the pre-swap gate still accept an env.N when the new layout is absent, so a rollback to the previous release keeps working.
  • Rollback also needs setup.env. The previous release's load_env requires ORCH_BASE_URL in setup.env (setup-scripts/debian13-worker/lib.sh:270). During the compatibility window, setup.env keeps every key that the previous release requires, or the release note says that a rollback needs the old setup.env restored.
  • Leftover env and env.N files are not deleted silently. The scripts print which files are no longer used, and the operator removes them.

Acceptance criteria

  • After a fresh deploy, each key is stored in exactly one file in the config directory (plus server-ed25519.pub).
  • Each worker N starts with its expected ORCH_WORKER_NAME without a per-worker env file.
  • ORCH_API_KEY is no longer stamped, and run-fleet.sh no longer treats it as a credentials signal.
  • The prune of surplus workers and the pre-swap gate work without env.N. Their bats tests pass.
  • Bats test: a host with the old layout (setup.env, env, env.N, a custom ORCH_WORKER_NAME, existing volumes) runs the new scripts. No worker is re-enrolled, names are kept, volumes and state.json are untouched, and the leftover files are reported on stderr.
  • Bats test: an env.N with a hand-added key that setup.env does not produce. The migration keeps the key in the new layout, or refuses and names the key without its value. The key is never dropped silently.
  • Bats test: env.1 has ORCH_ENFORCE_ISOLATION=false and env.2 has ORCH_ENFORCE_ISOLATION=true. After the migration each worker keeps its value, or the migration refuses and names the key.
  • Existing deployments keep working without manual config changes on upgrade, and a rollback to the previous release still starts the workers.
  • The READMEs and setup.env.example describe the new layout.
  • CHANGELOG entry under Unreleased, with the upgrade note.

Open questions

  • Option A or Option B? Option A gives one file but changes the most code (Makefile, prune, pre-swap gate) and needs a temporary file or many -e flags. Option B keeps --env-file, which the current Makefile already uses, so it changes less code. But Option B removes ORCH_BASE_URL and EXTRA_ENV from setup.env, and the previous release's scripts need ORCH_BASE_URL there, so a rollback with Option B also needs the window rule above. Either option keeps existing deployments working only with the migration and compatibility window above.
  • Should ORCH_ENROLLMENT_TOKEN stay at rest after enrollment, or only be injected while a worker has no state.json?
Dominant language
Python
Stars
0
Forks
0
Avg merge
1d 1h
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AInvirion/orcaster

All issues in AInvirion/orcaster

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.