Skip to content

Add threshold member share volume compose and startup guard, inert by default - #772

Merged
samgbafa merged 15 commits into
mainfrom
skgbafa/tc-2224-share-volume
Nov 29, 2026
Merged

samgbafa merged 15 commits into
mainfrom
skgbafa/tc-2224-share-volume

Conversation

@samgbafa

Copy link
Copy Markdown
Contributor

Adds the backup-excluded threshold share volume compose file, container directory and startup guard, inert by default when [global.encryption_network] threshold_share_dir is unset.

What it adds

  • Member compose (docker-compose.dstack-threshold-member.yaml): Runs tinycloud with an in-CVM postgres service. Mounts the named threshold-shares volume only in tinycloud at /var/lib/tinycloud/threshold, mounts /var/run/dstack.sock only in tinycloud and omits ssh-gateway.
  • Container image (Dockerfile): Creates /var/lib/tinycloud/threshold owned by uid 1000 with mode 0700 and copies it into the runtime image with --chown=tinycloud:tinycloud --chmod=0700.
  • Configuration and startup guard (config.rs, threshold_share.rs, lib.rs): Adds optional [global.encryption_network] threshold_share_dir. When unset, startup runs no prctl call and opens no share directory. When set on Linux, startup sets prctl(PR_SET_DUMPABLE, 0) early and requires the directory to exist without symlinks, have mode 0700, be owned by the process uid and support an exclusive advisory lock held for the server's lifetime; non-Linux targets refuse to start when configured.
  • Compose proof checks (scripts/tc959-compose-proof.mjs, scripts/tc959-docker.mjs, scripts/tc959-docker.test.mjs, .github/workflows/logship.yml): Adds strict allowlist and refusal checks for the member compose (service allowlist, single named share mount, no ssh-gateway, no dstack.sock outside tinycloud, no host bind mounts or hidden profiles, pinned default network name and no threshold-shares volume in the production compose).

Not changed

  • docker-compose.dstack-postgres.yaml is byte-identical to origin/main (sha256: 53a78d72e291efa6f588f0e0ef308211ede3a214360671a07b405a637875e7d7).
  • No SPEC, README or other documentation text.
  • No database migration, Cargo.toml or Cargo.lock change.

Test edits

Line 7 of scripts/tc959-docker.test.mjs adds assertThresholdMemberCompose to the import list for the new tests appended at the end of the file. No existing test body, fixture or assertion changes.

--- a/scripts/tc959-docker.test.mjs
+++ b/scripts/tc959-docker.test.mjs
@@ -4,7 +4,7 @@ import { spawnSync } from 'node:child_process';
 import { readFileSync } from 'node:fs';
 import { fileURLToPath } from 'node:url';
 import { parseArgs, assertCapture, resourceNames } from './tc959-docker.mjs';
-import { assertHostedRunner, cleanupOwnedResources, burstEvidence, assertHealthyBurst, progressEvidence, assertServiceParity, assertLogshipNetwork, composeRuntimeValues, socketEvidence, hostUdpEvidence, numericMetrics, diagnosticCounts } from './tc959-compose-proof.mjs';
+import { assertHostedRunner, cleanupOwnedResources, burstEvidence, assertHealthyBurst, progressEvidence, assertServiceParity, assertLogshipNetwork, composeRuntimeValues, socketEvidence, hostUdpEvidence, numericMetrics, diagnosticCounts, assertThresholdMemberCompose } from './tc959-compose-proof.mjs';

Verification

  • cargo test --locked -p tinycloud-node --lib threshold_share: 11/11 passed (including subprocess PR_GET_DUMPABLE == 0 check).
  • cargo clippy -p tinycloud-node --all-targets -- -D warnings: clean.
  • cargo fmt --all -- --check: clean.
  • node --test scripts/tc959-docker.test.mjs: 43/43 passed.
  • Real docker compose -f docker-compose.dstack-threshold-member.yaml config render and assertThresholdMemberCompose check: passed.

Merge effects

Merging to main runs the usual image build, which pushes the main and edge image tags. No deployment runs: deploying stays a manual dispatch.

Details: TC-2224

Adds [global.encryption_network] threshold_share_dir (unset: unchanged behavior). When set, app_with_control makes the process non-dumpable (PR_SET_DUMPABLE, 0 on Linux) and requires the directory to exist with mode 0700, be owned by the process uid and take an exclusive File::try_lock on a probe file; otherwise the start is refused with a named error_kind before any route is served.

Details: TC-2224
docker-compose.dstack-threshold-member.yaml (derived from dstack-full, in-CVM disposable Postgres) mounts the named threshold-shares volume only in the tinycloud service at /var/lib/tinycloud/threshold and sets threshold_share_dir there; no ssh-gateway. The Dockerfile creates that path uid 1000 mode 0700 in the builder and copies it into the scratch runtime. docker-compose.dstack-postgres.yaml is unchanged.

Details: TC-2224
assertThresholdMemberCompose in tc959-compose-proof.mjs: threshold-shares mounts only in member tinycloud at /var/lib/tinycloud/threshold as a named volume, no member ssh-gateway, and production declares and mounts no threshold-shares. Called from tc959-docker.mjs after compose_mounts on a --no-interpolate render, with the same no-secret-files checks as production. New negative unit cases in tc959-docker.test.mjs; logship.yml now triggers on the member compose.

Details: TC-2224
COPY --from=builder creates the destination directory at 0755, so the builder-stage chmod was not carried into the image; pin it with --chmod=0700 on the copy.

Details: TC-2224
Restores the file byte-identical to base.

Details: TC-2224
Test ruling (Naomi 2026-11-27 17:28Z): scripts/tc959-docker.test.mjs:7 import gains only assertThresholdMemberCompose; no test body, fixture or expectation changes; needed by the new appended tests.

Details: TC-2224
@samgbafa
samgbafa merged commit 4e511a8 into main Nov 29, 2026
35 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant