diff --git a/.github/workflows/block-release.yml b/.github/workflows/block-release.yml index c15d562b5d..deac728e3a 100644 --- a/.github/workflows/block-release.yml +++ b/.github/workflows/block-release.yml @@ -135,8 +135,9 @@ jobs: docker cp "$container:/usr/local/bin/$binary" "$out/bin/$binary" done bash seaweed-block/scripts/refuse-lab-binary.sh "$out/bin/"* + cp seaweed-block/deploy/systemd/sw-block.tmpfiles.conf "$out/bin/sw-block.tmpfiles.conf" asset="sw-block-${version}-linux-amd64.tar.gz" - tar -C "$out/bin" -czf "$out/$asset" blockmaster blockvolume sw-block + tar -C "$out/bin" -czf "$out/$asset" blockmaster blockvolume sw-block sw-block.tmpfiles.conf (cd "$out" && sha256sum "$asset" >SHA256SUMS) prerelease=false if [[ "$version" == *-* ]]; then prerelease=true; fi diff --git a/.github/workflows/block-test.yml b/.github/workflows/block-test.yml index 39c1d55651..27ddaf8ce4 100644 --- a/.github/workflows/block-test.yml +++ b/.github/workflows/block-test.yml @@ -98,6 +98,10 @@ jobs: python3 -B ../.github/block/scripts/doc-links-check-test.py python3 -I ../.github/block/scripts/doc-links-check.py . + - name: Release binary archive contract + if: matrix.suite == 'unit' + run: python3 -I .github/scripts/release-binary-assets-test.py + - name: Runner disk is NVMe # A self-hosted runner whose work, temp or Go cache directory sits on a # SATA system disk times the process-level tests out under disk load; diff --git a/seaweed-block/.github/process-level-tests.txt b/seaweed-block/.github/process-level-tests.txt index 741d925ac5..71d82382ed 100644 --- a/seaweed-block/.github/process-level-tests.txt +++ b/seaweed-block/.github/process-level-tests.txt @@ -97,3 +97,11 @@ TestWeedClustersSideBySideKeepTheirOwnFilerCensus # Kubernetes state: a holder on a wiped state directory never comes up empty. TestRF1HolderOnAWipedStateDirectoryRefusesStoreLost TestRF3WipedPrimaryRefusesAndASurvivorServesItsData + +# Non-root mini startup and owned cleanup controls. +TestMiniStartsWithoutRootAndNamesItsBinaries +TestMiniOwnedGroupCleanupStopsDescendants +TestMiniSettledCleanupDoesNotSignal +TestMiniCleanupFailStopAndSettlement +TestMiniContextAllowsChildShutdownGrace +TestMiniLockProofRequiresContention diff --git a/seaweed-block/.github/scripts/release-binary-assets-test.py b/seaweed-block/.github/scripts/release-binary-assets-test.py index 38cd2f81d8..8db47d8dd0 100644 --- a/seaweed-block/.github/scripts/release-binary-assets-test.py +++ b/seaweed-block/.github/scripts/release-binary-assets-test.py @@ -7,6 +7,41 @@ REV = "a" * 40 DIGEST = "example.invalid/block@sha256:" + "b" * 64 class ReleaseAssets(unittest.TestCase): + def test_active_root_release_contains_tmpfiles(self): + repo = HERE.parents[2] + workflow = (repo / '.github/workflows/block-release.yml').read_text() + step = workflow.split(' - name: Publish matching binary tarball\n', 1)[1] + script = step.split(' run: |\n', 1)[1].split('\n - name:', 1)[0] + script = '\n'.join(line[10:] for line in script.splitlines()) + with tempfile.TemporaryDirectory() as tmp: + root = Path(tmp) + tools = root / 'tools'; tools.mkdir() + image = root / 'image'; image.mkdir() + for name in ('blockmaster', 'blockvolume', 'sw-block'): + (image / name).write_bytes(('#!/bin/sh\necho '+name+' release\n').encode()) + (image / name).chmod(0o755) + (tools / 'docker').write_text('''#!/usr/bin/env python3 +import os,pathlib,shutil,sys +a=sys.argv[1:] +if a[0]=='create': print('owned-container') +elif a[0]=='cp': shutil.copy2(pathlib.Path(os.environ['IMAGE'])/a[1].rsplit('/',1)[1],a[2]) +''') + (tools / 'gh').write_text('#!/bin/sh\nexit 0\n') + for tool in tools.iterdir(): tool.chmod(0o755) + env = dict(os.environ, PATH=str(tools)+os.pathsep+os.environ['PATH'], + IMAGE=str(image), RUNNER_TEMP=str(root), BLOCK_IMAGE='example/block', + BLOCK_DIGEST='sha256:'+'b'*64, GITHUB_REF_NAME='seaweed-block/v1.1.2', + GITHUB_REPOSITORY='example/block', NOTES=str(root/'notes')) + result = subprocess.run(['bash', '-c', script], cwd=repo, env=env, + capture_output=True, text=True, timeout=15) + self.assertEqual(result.returncode, 0, result.stderr) + with tarfile.open(root/'block-release/sw-block-v1.1.2-linux-amd64.tar.gz') as tar: + self.assertEqual(set(tar.getnames()), {'blockmaster', 'blockvolume', 'sw-block', 'sw-block.tmpfiles.conf'}) + self.assertEqual(tar.extractfile('sw-block.tmpfiles.conf').read(), + (repo/'seaweed-block/deploy/systemd/sw-block.tmpfiles.conf').read_bytes()) + subprocess.run(['sha256sum', '--check', 'SHA256SUMS'], cwd=root/'block-release', + check=True, capture_output=True) + def run_case(self, bad=None, mode="revision", existing=True, tag="v1.1.1", docker_rm_rc=0, rm_rc=0, publish_rc=0): with tempfile.TemporaryDirectory() as tmp: @@ -23,6 +58,7 @@ class ReleaseAssets(unittest.TestCase): else: self.fail("invalid fixture mode") data=(f"#!/bin/sh\necho '{name} revision={revision} modified={modified}{suffix}'\nexit {status}\n").encode() (image/name).write_bytes(data); (image/name).chmod(0o755); expected[name]=data + expected["sw-block.tmpfiles.conf"]=(HERE.parent.parent/"deploy"/"systemd"/"sw-block.tmpfiles.conf").read_bytes() log=root/"calls.jsonl"; state=root/"release.json"; state.write_text(json.dumps({"prerelease":"-" not in tag})) common="""#!/usr/bin/env python3 import json,os,pathlib,shutil,sys diff --git a/seaweed-block/.github/scripts/release-binary-assets.sh b/seaweed-block/.github/scripts/release-binary-assets.sh index 8c23355c81..921eb269c3 100644 --- a/seaweed-block/.github/scripts/release-binary-assets.sh +++ b/seaweed-block/.github/scripts/release-binary-assets.sh @@ -33,9 +33,11 @@ for binary in blockmaster blockvolume sw-block; do exit 1 fi done +# The tmpfiles.d entry that creates the host volume lock directory for the units. +cp -- "$(dirname -- "$0")/../../deploy/systemd/sw-block.tmpfiles.conf" "$work/bin/sw-block.tmpfiles.conf" mkdir -p "$out" asset="sw-block-${tag}-linux-amd64.tar.gz" -tar -C "$work/bin" -czf "$out/$asset" blockmaster blockvolume sw-block +tar -C "$work/bin" -czf "$out/$asset" blockmaster blockvolume sw-block sw-block.tmpfiles.conf (cd "$out" && sha256sum "$asset" >SHA256SUMS) prerelease=false if [[ "$tag" == *-* ]]; then prerelease=true; fi diff --git a/seaweed-block/README.md b/seaweed-block/README.md index a5244b3dcd..d531262c3b 100644 --- a/seaweed-block/README.md +++ b/seaweed-block/README.md @@ -116,23 +116,25 @@ TAG=v1.1.1 curl -fsSLO https://github.com/seaweedfs/seaweed-block/releases/download/$TAG/sw-block-$TAG-linux-amd64.tar.gz curl -fsSLO https://github.com/seaweedfs/seaweed-block/releases/download/$TAG/SHA256SUMS sha256sum -c --ignore-missing SHA256SUMS && tar -xzf sw-block-$TAG-linux-amd64.tar.gz -export PATH="$PWD:$PATH" # so the sw-block commands that mini prints run as shown +# v1.1.1 prerequisite: its child lookup uses PATH and its lock is host-wide. +export PATH="$PWD:$PATH" +sudo install -d -m 0755 /run/sw-block +sudo install -d -m 0700 -o "$(id -u)" -g "$(id -g)" /run/sw-block/locks ./blockvolume --version # must print the tag's commit -# blockvolume keeps one lock per volume here, so only one live process serves a volume on a host: -sudo install -d -m 0755 -o root -g root /run/sw-block -sudo install -d -m 0755 -o "$USER" -g "$(id -gn)" /run/sw-block/locks ./sw-block mini --dir ./swb-mini --weed /path/to/weed ``` -A failed start leaves `--dir` behind: start again with a new `--dir`, or on the same one with `--reuse`. +From v1.1.2 `mini` needs no `sudo` to start: it keeps the volume lock under `--dir`, prints every command with the +absolute paths of `sw-block` and `weed`, and on a failed start prints the `--reuse` command that starts again on the +same `--dir`. With v1.1.1, see its [known issue](docs/releases/v1.1.1.md#known-issue-sw-block-mini-as-a-non-root-user-fixed-in-v112). **What it shows today:** - `mini` starts `weed mini`, `blockmaster` and one `blockvolume`: volume `v1`, 256 MiB, on loopback. - It never runs `sudo` itself. It prints the `nvme connect` command that attaches `v1`, and the status, check and snapshot commands. After the connect, `sudo nvme list` shows the disk's device (for example `/dev/nvme0n1`). -- Snapshots of `v1` work at once, through the `sw-block ops chunk snapshot` command it prints. A scheduled - `sched-