mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
seaweed-block: sw-block mini starts as any user with no sudo (#13421)
* seaweed-block: sw-block mini starts as any user with no sudo blockvolume gets --volume-lock-dir, a trial-run override of the host volume lock directory (refused under systemd and together with the test override). sw-block mini passes <dir>/locks to its holder, so it starts as any user on a host without /run/sw-block. mini also runs v1 with no scheduled snapshot (it prints the command that takes one), names sw-block and weed by their absolute paths in every command it prints, and after a failed start stops what it started and prints the --reuse command for the same --dir. The release archive carries sw-block.tmpfiles.conf for the units' lock directory. The README Quick Start drops its sudo lines, and the v1.1.1 known issue reads fixed in v1.1.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-block: mini under a systemd process tree, and no new lock-dir flag (on #13421) (#13425) * seaweed-block: mini starts its children without INVOCATION_ID Run from a systemd service's process tree (a CI runner unit, a terminal server), mini passed INVOCATION_ID to blockvolume, which then refused mini's lock directory and the run stopped at startup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-block: mini's interrupt test expects the resume command with mini's own path mini prints the resume command with os.Executable(), so the in-process test saw the test binary's path, not a bare sw-block, and failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-block: mini uses the existing hidden lock-dir override, no new flag --volume-lock-dir set the same field as the hidden --volume-lock-dir-test-only with the same systemd refusal, and mini was its only caller. Keep one hidden override so operators are not offered a documented knob that drops the one-holder-per-volume guarantee outside systemd (containers, hand-run hosts). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * docs: track mini resolve helper time bounds * Test active release assets and relative mini paths * Complete mini release assets and bounded process checks * Terminate owned mini groups before checking for residue * Accept inaccessible host locks as a non-root precondition * Harden mini test ownership and fail-stop cleanup * test: reproduce empty filtered mini child environment * fix(block): complete mini startup and cleanup proof * test(block): claim the mini test's ports host-wide The pid-derived --port-shift put mini's 13 ports inside the handoff and weed pair ranges the other process-level harnesses claim, unclaimed, so a parallel CI shard could bind one of them. Pick a shift whose every port is claimed and free, as handoffAddress does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(block): claim the failed-start mini launch's ports too The second launch ran at shift+1, whose ports were neither claimed nor checked, so a parallel shard could take one and fail the launch before it reached the deliberate blockvolume refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(block): exercise production mini hint with quoted paths * docs(block): explain mini local data lock scope * fix(block): preserve mini executable and cleanup proof * test(block): settle a leader that exits as member capture expires stopGroup checked done only at the top of each capture iteration. A leader that exited after that check, once the one-second window had passed, made the next failed read fail-stop even though the group had settled. Both capture deadlines now defer to assertStopped when done has closed, so live residue still fail-stops. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(block): refuse a PATH weed found through the current directory exec.LookPath reports exec.ErrDot for a weed found only through . in PATH. Making that name absolute let exec.Command start it, where it refused before; mini now refuses it and names --weed ./weed as the explicit choice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(block): accept a reused --weed that names the recorded executable A relative --weed made absolute from another working directory names the same file through a different path; mini compared the strings and refused the retry. Compare file identity when the paths differ, so a different executable is still refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(block): prove the selected weed ran in the mini startup tests A start failure and the fixture weed's exit both return 1, and the printed command and the record exist either way. The dying fixture weed now writes a marker file, and both startup tests require it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(block): name the mini trial lock in the M4 start arrows The table already says a mini trial's blockvolume locks the run's --dir/locks; the diagram's start arrows still named only the host lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(block): shell-quote mini's startup trace Making --weed absolute can put a space from the working directory into the printed command. Quote the executable and each argument with shQuote, as mini's other printed commands already are, so the trace runs as printed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(block): count the mini group again when it is gone after a census A member listed by the census can exit before the signal-0 query reports ESRCH. On the iteration that crosses the deadline that stale count fail-stopped a settled group. Count again when the group is absent, so only a member still listed holds the settlement; the residue control still fail-stops. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(block): name the empty-census case in the mini group fail-stop A group that still exists while the census lists no live member failed with "live residue []". Say what it can be: a member the census missed, or zombies their new parent does not reap. Both stay fail-stops. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(block): match the quoted failed-start trace in the non-root mini test The startup trace is shell-quoted now, and this test's weed path has a quote in it, so match each binary through miniHintWord. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(block): let --reuse take its recorded run past a weed found through . The exec.ErrDot refusal ran before the record was read, so a reuse of a recorded run failed whenever . in PATH found a ./weed, although the reuse would use the recorded weed (or none for a walstore run). A reuse now ignores that weed; a fresh start still refuses it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(block): match the shell-quoted start trace in the mini unit tests mini shell-quotes each word of its "+" trace, so a TMPDIR holding a space prints the blockmaster, blockvolume and weed paths quoted, and three unit tests looked for them bare. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(block): pin that a normal start keeps the host volume lock A start under systemd (INVOCATION_ID set, as every shipped unit runs) gets no lock directory of its own, so the provider uses the host one, and the hidden test-only override is refused, naming the host lock directory. The test is listed under INV-WS-ONE-PROCESS-PER-HOST-001. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(block): mini quotes the --weed path in its dot-in-PATH hint Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
This commit is contained in:
18 files changed
+1448
-56
No files matched your search
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
+3
-1
@@ -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
|
||||
|
||||
+10
-8
@@ -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-<time>` snapshot also appears soon after the start. A restore into a new volume does not run inside `mini`
|
||||
yet; use the standalone setup for it.
|
||||
- Snapshots of `v1` work at once, through the `sw-block ops chunk snapshot` command it prints. From v1.1.2 `mini`
|
||||
takes no scheduled snapshot (with v1.1.1 a scheduled `sched-<time>` snapshot appears soon after the start). A
|
||||
restore into a new volume does not run inside `mini` yet; use the standalone setup for it.
|
||||
- To stop: unmount `v1`, run the `sudo nvme disconnect` that `mini` printed, then press Ctrl-C.
|
||||
|
||||
**Next:**
|
||||
|
||||
@@ -129,8 +129,8 @@ type flags struct {
|
||||
durableBlockSize uint
|
||||
durableWALMultiBlockRecords bool
|
||||
durableWALRecoveryTestDisableFlusher bool
|
||||
// volumeLockDirTestOnly replaces durable.HostVolumeLockDir (hidden,
|
||||
// test-only; refused under systemd).
|
||||
// volumeLockDirTestOnly replaces durable.HostVolumeLockDir (hidden, for
|
||||
// tests and sw-block mini's one-user trial; refused under systemd).
|
||||
volumeLockDirTestOnly string
|
||||
|
||||
// WAL retention window past checkpoint LSN. Zero = strict
|
||||
@@ -333,7 +333,7 @@ func parseFlagsWithCgroup(args []string, readFile func(string) ([]byte, error))
|
||||
return flags{}, err
|
||||
}
|
||||
if f.volumeLockDirTestOnly != "" && os.Getenv("INVOCATION_ID") != "" {
|
||||
return flags{}, fmt.Errorf("--%s is test-only and refused under systemd (INVOCATION_ID is set): the one-process-per-host guarantee needs %s", volumeLockDirTestOnlyFlag, durable.HostVolumeLockDir)
|
||||
return flags{}, fmt.Errorf("--%s is for tests and trial runs and refused under systemd (INVOCATION_ID is set): the one-process-per-host guarantee needs %s", volumeLockDirTestOnlyFlag, durable.HostVolumeLockDir)
|
||||
}
|
||||
if f.recoveryMode != "legacy" && f.recoveryMode != "dual-lane" {
|
||||
return flags{}, fmt.Errorf("--recovery-mode=%q invalid; want \"legacy\" or \"dual-lane\"", f.recoveryMode)
|
||||
@@ -757,7 +757,7 @@ func runVolume(f flags, exits *processExit) int {
|
||||
VolumeLockDirTestOnly: f.volumeLockDirTestOnly,
|
||||
}
|
||||
if f.volumeLockDirTestOnly != "" {
|
||||
fmt.Fprintf(os.Stderr, "blockvolume: volume lock directory %s is a test override: the one-process-per-host guarantee does not hold\n", f.volumeLockDirTestOnly)
|
||||
fmt.Fprintf(os.Stderr, "blockvolume: volume lock directory %s is an override: one process per volume is enforced only among processes using it\n", f.volumeLockDirTestOnly)
|
||||
}
|
||||
var chunkErr error
|
||||
var chunk chunkWiring
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
//go:build linux && subprocess && chunkstore_integration
|
||||
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// sw-block mini starts as any user on a host without /run/sw-block: the
|
||||
// holder takes its volume lock under --dir and serves, every sw-block and
|
||||
// weed command mini prints names the binary by its absolute path, and no
|
||||
// scheduled snapshot runs. A start that fails after --dir was made stops what
|
||||
// it started and prints the --reuse command for the same --dir.
|
||||
func TestMiniStartsWithoutRootAndNamesItsBinaries(t *testing.T) {
|
||||
assertMiniUnprivileged(t)
|
||||
weed := os.Getenv("CHUNKSTORE_WEED")
|
||||
if weed == "" {
|
||||
t.Fatal("CHUNKSTORE_WEED must name the pinned real SeaweedFS binary")
|
||||
}
|
||||
var err error
|
||||
weed, err = filepath.Abs(weed)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// The real startup/output assertion must exercise the production hint,
|
||||
// even when CI supplied an ordinary path. Both spaces and apostrophes need
|
||||
// POSIX quoting; exec still receives the path as one argument.
|
||||
quotedWeed := filepath.Join(t.TempDir(), "weed's tools")
|
||||
if err := os.Symlink(weed, quotedWeed); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
weed = quotedWeed
|
||||
bins := os.Getenv("SWBLOCK_TEST_BINS")
|
||||
if bins == "" {
|
||||
bins = t.TempDir()
|
||||
for _, b := range []string{"blockmaster", "blockvolume", "sw-block"} {
|
||||
miniGoBuild(t, filepath.Join(bins, b), "github.com/seaweedfs/seaweed-block/cmd/"+b)
|
||||
}
|
||||
}
|
||||
bins, err = filepath.Abs(bins)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cli := filepath.Join(bins, "sw-block")
|
||||
shift := miniPortShift(t)
|
||||
dir := filepath.Join(t.TempDir(), "mini")
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 4*time.Minute)
|
||||
defer cancel()
|
||||
p := startOwnedMini(t, ctx, cli, "mini", "--dir", dir, "--bin", bins, "--weed", weed, "--port-shift", fmt.Sprint(shift))
|
||||
for !strings.Contains(p.output.String(), "sw-block mini: running") {
|
||||
select {
|
||||
case <-p.done:
|
||||
t.Fatalf("mini did not reach running: %v\n%s", p.err, p.output.String())
|
||||
case <-ctx.Done():
|
||||
t.Fatalf("mini startup expired: %s", p.output.String())
|
||||
case <-time.After(20 * time.Millisecond):
|
||||
}
|
||||
}
|
||||
// The running line precedes the hints; await the last hint without reading
|
||||
// a buffer concurrently with its writer.
|
||||
for !strings.Contains(p.output.String(), miniHintWord(weed)+" shell -master=") {
|
||||
select {
|
||||
case <-p.done:
|
||||
t.Fatalf("mini exited before its hints: %s", p.output.String())
|
||||
case <-ctx.Done():
|
||||
t.Fatalf("mini hints expired: %s", p.output.String())
|
||||
case <-time.After(20 * time.Millisecond):
|
||||
}
|
||||
}
|
||||
if err := miniLockConflict(filepath.Join(dir, "locks", "v1.lock")); err != nil {
|
||||
t.Fatalf("serving holder does not own its trial lock: %v", err)
|
||||
}
|
||||
if err := p.signalLeader(syscall.SIGINT); err != nil {
|
||||
t.Fatalf("could not deliver Ctrl-C: %v", err)
|
||||
}
|
||||
if err := p.join(t, 40*time.Second); err != nil {
|
||||
t.Fatalf("mini after Ctrl-C: %v\n%s", err, p.output.String())
|
||||
}
|
||||
p.assertStopped(t) // before the safety-net cleanup: product shutdown owns this
|
||||
t.Logf("sw-block mini output:\n%s", p.output.String())
|
||||
if !exists(filepath.Join(dir, "locks", "v1.lock")) {
|
||||
t.Fatalf("the holder's lock is not under --dir")
|
||||
}
|
||||
text := p.output.String()
|
||||
if strings.Contains(text, "+ sw-block ") || strings.Contains(text, " sw-block ") {
|
||||
t.Errorf("mini prints a sw-block command without its absolute path")
|
||||
}
|
||||
for _, want := range []string{" " + miniHintWord(cli) + " ops workspace show", " " + miniHintWord(cli) + " ops chunk snapshot", miniHintWord(weed) + " shell -master=", "mini takes no scheduled snapshot", miniHintWord(cli) + " mini --dir "} {
|
||||
if !strings.Contains(text, want) {
|
||||
t.Errorf("mini's output lacks %q", want)
|
||||
}
|
||||
}
|
||||
|
||||
// A start that fails after --dir exists names the --reuse command.
|
||||
broken := t.TempDir()
|
||||
for _, b := range []string{"blockmaster", "sw-block"} {
|
||||
if err := os.Symlink(filepath.Join(bins, b), filepath.Join(broken, b)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(broken, "blockvolume"), []byte("#!/bin/sh"+string(rune(10))+"echo refused >&2; exit 1"+string(rune(10))), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
dir2 := filepath.Join(t.TempDir(), "mini")
|
||||
ctx2, cancel2 := context.WithTimeout(context.Background(), 3*time.Minute)
|
||||
defer cancel2()
|
||||
p2 := startOwnedMini(t, ctx2, cli, "mini", "--dir", dir2, "--bin", broken, "--weed", weed, "--port-shift", fmt.Sprint(miniPortShift(t)))
|
||||
err = p2.join(t, 3*time.Minute+miniShutdownGrace+10*time.Second)
|
||||
p2.assertNaturalExit(t)
|
||||
b2 := p2.output.String()
|
||||
t.Logf("failed start:\n%s", b2)
|
||||
if err == nil || !strings.Contains(b2, "start again on it with") || !strings.Contains(b2, miniHintWord(cli)+" mini --dir "+miniHintWord(dir2)+" --reuse") {
|
||||
t.Fatalf("a failed start: %v", err)
|
||||
}
|
||||
for _, binary := range []string{weed, filepath.Join(broken, "blockmaster"), filepath.Join(broken, "blockvolume")} {
|
||||
if !strings.Contains(b2, "+ "+miniHintWord(binary)+" ") {
|
||||
t.Fatalf("failed-start path did not reach %s: %s", binary, b2)
|
||||
}
|
||||
}
|
||||
p2.assertStopped(t) // rejects a failed start which left weed/master running
|
||||
|
||||
}
|
||||
|
||||
func miniGoBuild(t *testing.T, out, pkg string) {
|
||||
t.Helper()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
|
||||
defer cancel()
|
||||
p := startOwnedMini(t, ctx, "go", "build", "-o", out, pkg)
|
||||
if err := p.join(t, 3*time.Minute+miniShutdownGrace+10*time.Second); err != nil {
|
||||
t.Fatalf("build %s: %v\n%s", pkg, err, p.output.String())
|
||||
}
|
||||
p.assertStopped(t)
|
||||
|
||||
}
|
||||
|
||||
// miniPortShift picks a --port-shift whose every mini port (defaultMiniPorts
|
||||
// in cmd/sw-block) is claimed host-wide and free now, as the other harnesses'
|
||||
// ports are, so a parallel process-level shard never binds one of them.
|
||||
func miniPortShift(t *testing.T) int {
|
||||
t.Helper()
|
||||
defaults := []int{9180, 9201, 9202, 9203, 4420, 9333, 19333, 9340, 19340, 8888, 18888, 12535, 22535}
|
||||
for i := 0; i < 200; i++ {
|
||||
shift := 3000 + rand.Intn(6000)
|
||||
free := true
|
||||
for _, p := range defaults {
|
||||
if !claimHostPort(p + shift) {
|
||||
free = false
|
||||
break
|
||||
}
|
||||
ln, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", p+shift))
|
||||
if err != nil {
|
||||
free = false
|
||||
break
|
||||
}
|
||||
ln.Close()
|
||||
}
|
||||
if free {
|
||||
return shift
|
||||
}
|
||||
}
|
||||
t.Fatal("no --port-shift with every mini port claimed and free")
|
||||
return 0
|
||||
}
|
||||
|
||||
func exists(p string) bool {
|
||||
_, err := os.Stat(p)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// Expected command words follow the printed POSIX-shell contract.
|
||||
func miniHintWord(s string) string {
|
||||
if s != "" && strings.Trim(s, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@%+=:,./_-") == "" {
|
||||
return s
|
||||
}
|
||||
return "'" + strings.ReplaceAll(s, "'", `'\''`) + "'"
|
||||
}
|
||||
|
||||
func miniLockConflict(path string) error {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
err = syscall.Flock(int(f.Fd()), syscall.LOCK_EX|syscall.LOCK_NB)
|
||||
if err == syscall.EWOULDBLOCK || err == syscall.EAGAIN {
|
||||
return nil
|
||||
}
|
||||
if err == nil {
|
||||
_ = syscall.Flock(int(f.Fd()), syscall.LOCK_UN)
|
||||
return fmt.Errorf("lock was available")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func TestMiniLockProofRequiresContention(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "v1.lock")
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer f.Close()
|
||||
if err := miniLockConflict(path); err == nil {
|
||||
t.Fatal("unheld file passed the serving-lock proof")
|
||||
}
|
||||
if err := syscall.Flock(int(f.Fd()), syscall.LOCK_EX|syscall.LOCK_NB); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := miniLockConflict(path); err != nil {
|
||||
t.Fatalf("held lock failed proof: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,615 @@
|
||||
//go:build linux && subprocess && chunkstore_integration
|
||||
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// Preconditions are assertions: a privileged run is not non-root evidence.
|
||||
func assertMiniUnprivileged(t *testing.T) {
|
||||
t.Helper()
|
||||
if os.Getuid() == 0 || os.Geteuid() == 0 {
|
||||
t.Fatal("non-root qualification must run without uid 0")
|
||||
}
|
||||
p := "/run/sw-block/locks"
|
||||
// A read-only existing file can still be flocked without a directory write.
|
||||
// Refuse qualification if it can even be opened; never mutate the host path.
|
||||
lock, err := os.Open(filepath.Join(p, "v1.lock"))
|
||||
if err == nil {
|
||||
_ = lock.Close()
|
||||
t.Fatal("existing host lock is readable; old host-lock path is usable")
|
||||
}
|
||||
if !errors.Is(err, os.ErrNotExist) && !errors.Is(err, syscall.EACCES) && !errors.Is(err, syscall.EPERM) {
|
||||
t.Fatalf("host lock file preflight: %v", err)
|
||||
}
|
||||
for {
|
||||
_, err := os.Stat(p)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
if errors.Is(err, syscall.EACCES) || errors.Is(err, syscall.EPERM) {
|
||||
t.Logf("non-root uid=%d euid=%d; host lock path %s is inaccessible: %v", os.Getuid(), os.Geteuid(), p, err)
|
||||
return
|
||||
}
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
t.Fatalf("host lock preflight: %v", err)
|
||||
}
|
||||
p = filepath.Dir(p)
|
||||
}
|
||||
if err := syscall.Access(p, 3); err == nil {
|
||||
t.Fatalf("host lock path/ancestor %s is writable; non-root precondition is unproved", p)
|
||||
} else if !errors.Is(err, syscall.EACCES) && !errors.Is(err, syscall.EPERM) {
|
||||
t.Fatalf("host lock access preflight: %v", err)
|
||||
}
|
||||
t.Logf("non-root uid=%d euid=%d; host lock ancestor %s is not writable", os.Getuid(), os.Geteuid(), p)
|
||||
}
|
||||
|
||||
type miniOutput struct {
|
||||
mu sync.Mutex
|
||||
b bytes.Buffer
|
||||
}
|
||||
|
||||
func (b *miniOutput) Write(p []byte) (int, error) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
return b.b.Write(p)
|
||||
}
|
||||
func (b *miniOutput) String() string { b.mu.Lock(); defer b.mu.Unlock(); return b.b.String() }
|
||||
|
||||
const miniFailStopExit = 86
|
||||
|
||||
func miniFailStop(t *testing.T, why string) {
|
||||
fmt.Fprintf(os.Stderr, "%s: %s; stopping tests before directory cleanup\n", t.Name(), why)
|
||||
os.Exit(miniFailStopExit)
|
||||
}
|
||||
|
||||
type ownedMini struct {
|
||||
cmd *exec.Cmd
|
||||
done chan struct{}
|
||||
err error
|
||||
output miniOutput
|
||||
stopOnce sync.Once
|
||||
mu sync.Mutex
|
||||
settled bool
|
||||
leaderFD int
|
||||
leaderKey string
|
||||
dispatches atomic.Int64
|
||||
watchdog atomic.Bool
|
||||
// Only the isolated fail-stop controls replace the census or its window.
|
||||
groupExists func() bool
|
||||
census func() []int
|
||||
censusWait time.Duration
|
||||
captureLeader func(int) (miniProcInfo, error)
|
||||
}
|
||||
|
||||
const miniShutdownGrace = 35 * time.Second // three 10-second child stops plus margin
|
||||
|
||||
// Probe before starting any workload. CLONE_PIDFD then obtains the child's
|
||||
// immutable reference atomically with creation, before a cancellation can run.
|
||||
func miniPidfdSupport() error {
|
||||
fd, err := unix.PidfdOpen(os.Getpid(), 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer unix.Close(fd)
|
||||
return unix.PidfdSendSignal(fd, 0, nil, 0)
|
||||
}
|
||||
func startOwnedMini(t *testing.T, ctx context.Context, bin string, args ...string) *ownedMini {
|
||||
t.Helper()
|
||||
if err := miniPidfdSupport(); err != nil {
|
||||
t.Fatalf("pidfd ownership unavailable before start: %v", err)
|
||||
}
|
||||
p := &ownedMini{cmd: exec.CommandContext(ctx, bin, args...), done: make(chan struct{}), leaderFD: -1}
|
||||
p.cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true, PidFD: &p.leaderFD}
|
||||
p.cmd.Stdout, p.cmd.Stderr = &p.output, &p.output
|
||||
// os/exec must not kill only the leader after a short WaitDelay. Our
|
||||
// watchdog grants the full product shutdown window, then owns group cleanup.
|
||||
p.cmd.Cancel = func() error { p.watchdog.Store(true); go p.stop(t); return nil }
|
||||
p.mu.Lock() // a context cancellation cannot observe the unopened pidfd
|
||||
if err := p.cmd.Start(); err != nil {
|
||||
p.mu.Unlock()
|
||||
t.Fatal(err)
|
||||
}
|
||||
if p.leaderFD < 0 {
|
||||
p.mu.Unlock()
|
||||
p.ownershipFailed(t, "atomic leader pidfd missing")
|
||||
}
|
||||
info, err := miniProc(p.cmd.Process.Pid)
|
||||
if err != nil {
|
||||
p.mu.Unlock()
|
||||
p.ownershipFailed(t, fmt.Sprintf("cannot record leader incarnation: %v", err))
|
||||
}
|
||||
p.leaderKey = info.key
|
||||
p.mu.Unlock()
|
||||
go func() { p.err = p.cmd.Wait(); close(p.done) }()
|
||||
t.Cleanup(func() { p.stop(t) })
|
||||
return p
|
||||
}
|
||||
|
||||
// No Wait goroutine exists yet: the unreaped direct child cannot have its
|
||||
// PID recycled. Stop and reap it before failing closed with directories kept.
|
||||
func (p *ownedMini) ownershipFailed(t *testing.T, why string) {
|
||||
_ = p.cmd.Process.Kill()
|
||||
p.cmd.WaitDelay = time.Second
|
||||
reaped := make(chan struct{})
|
||||
go func() { _ = p.cmd.Wait(); close(reaped) }()
|
||||
select {
|
||||
case <-reaped:
|
||||
case <-time.After(5 * time.Second):
|
||||
}
|
||||
miniFailStop(t, why)
|
||||
}
|
||||
func (p *ownedMini) signalFD(fd int, sig unix.Signal) error {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
if p.settled {
|
||||
return os.ErrProcessDone
|
||||
}
|
||||
p.dispatches.Add(1)
|
||||
return unix.PidfdSendSignal(fd, sig, nil, 0)
|
||||
}
|
||||
func (p *ownedMini) signalLeader(sig unix.Signal) error {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
if p.settled {
|
||||
return os.ErrProcessDone
|
||||
}
|
||||
p.dispatches.Add(1)
|
||||
return unix.PidfdSendSignal(p.leaderFD, sig, nil, 0)
|
||||
}
|
||||
func (p *ownedMini) isSettled() bool { p.mu.Lock(); defer p.mu.Unlock(); return p.settled }
|
||||
func (p *ownedMini) settle() {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
if !p.settled {
|
||||
p.settled = true
|
||||
if p.leaderFD >= 0 {
|
||||
_ = unix.Close(p.leaderFD)
|
||||
p.leaderFD = -1
|
||||
}
|
||||
}
|
||||
}
|
||||
func (p *ownedMini) join(t *testing.T, bound time.Duration) error {
|
||||
t.Helper()
|
||||
select {
|
||||
case <-p.done:
|
||||
return p.err
|
||||
case <-time.After(bound):
|
||||
miniFailStop(t, fmt.Sprintf("owned process did not join in %s", bound))
|
||||
return nil
|
||||
}
|
||||
}
|
||||
func (p *ownedMini) assertNaturalExit(t *testing.T) {
|
||||
t.Helper()
|
||||
if p.watchdog.Load() {
|
||||
t.Fatal("watchdog intervened; failed-start cleanup was not completed by mini")
|
||||
}
|
||||
}
|
||||
func (p *ownedMini) stop(t *testing.T) {
|
||||
p.stopOnce.Do(func() {
|
||||
if p.isSettled() {
|
||||
return
|
||||
}
|
||||
_ = p.signalLeader(unix.SIGTERM)
|
||||
select {
|
||||
case <-p.done:
|
||||
p.assertStopped(t)
|
||||
return
|
||||
case <-time.After(miniShutdownGrace):
|
||||
}
|
||||
p.stopGroup(t)
|
||||
})
|
||||
}
|
||||
|
||||
// Never signal a numeric PGID. While the original leader is stopped, its
|
||||
// group identity cannot disappear; capture and stop each member by pidfd.
|
||||
// After resuming, TERM/KILL use those immutable references even if a PID is
|
||||
// recycled. Unknown late members or an exited leader with live residue cause
|
||||
// fail-stop rather than guessing ownership and signaling an unrelated group.
|
||||
func (p *ownedMini) stopGroup(t *testing.T) {
|
||||
t.Helper()
|
||||
if p.isSettled() {
|
||||
return
|
||||
}
|
||||
select {
|
||||
case <-p.done:
|
||||
p.assertStopped(t)
|
||||
return
|
||||
default:
|
||||
}
|
||||
if err := p.signalLeader(unix.SIGSTOP); err != nil {
|
||||
select {
|
||||
case <-p.done:
|
||||
p.assertStopped(t)
|
||||
return
|
||||
default:
|
||||
miniFailStop(t, fmt.Sprintf("cannot stop owned leader: %v", err))
|
||||
}
|
||||
}
|
||||
pgid := p.cmd.Process.Pid
|
||||
leaderFD := p.leaderFD
|
||||
refs := map[string]int{}
|
||||
defer func() {
|
||||
for _, fd := range refs {
|
||||
if fd != leaderFD {
|
||||
_ = unix.Close(fd)
|
||||
}
|
||||
}
|
||||
}()
|
||||
deadline := time.Now().Add(time.Second)
|
||||
for {
|
||||
select {
|
||||
case <-p.done:
|
||||
p.assertStopped(t)
|
||||
return
|
||||
default:
|
||||
}
|
||||
readLeader := miniProc
|
||||
if p.captureLeader != nil {
|
||||
readLeader = p.captureLeader
|
||||
}
|
||||
leader, err := readLeader(pgid)
|
||||
if err != nil || leader.key != p.leaderKey || (leader.state != "T" && leader.state != "t") || unix.PidfdSendSignal(leaderFD, 0, nil, 0) != nil {
|
||||
if time.Now().After(deadline) {
|
||||
p.captureExpired(t, "leader incarnation not held during member capture")
|
||||
return
|
||||
}
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
continue
|
||||
}
|
||||
refs[leader.key] = leaderFD
|
||||
members := miniGroupMembers(t, pgid)
|
||||
stopped := true
|
||||
for _, m := range members {
|
||||
fd, ok := refs[m.key]
|
||||
if !ok {
|
||||
fd, err = unix.PidfdOpen(m.pid, 0)
|
||||
if err != nil {
|
||||
if errors.Is(err, unix.ESRCH) {
|
||||
stopped = false
|
||||
continue
|
||||
}
|
||||
miniFailStop(t, fmt.Sprintf("cannot own descendant: %v", err))
|
||||
}
|
||||
current, err := miniProc(m.pid)
|
||||
if err != nil || current.key != m.key || current.group != pgid {
|
||||
_ = unix.Close(fd)
|
||||
stopped = false
|
||||
continue
|
||||
}
|
||||
refs[m.key] = fd
|
||||
}
|
||||
if m.state != "T" && m.state != "t" {
|
||||
stopped = false
|
||||
if err := p.signalFD(fd, unix.SIGSTOP); err != nil && !errors.Is(err, unix.ESRCH) {
|
||||
miniFailStop(t, fmt.Sprintf("cannot stop descendant: %v", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
if stopped {
|
||||
break
|
||||
}
|
||||
if time.Now().After(deadline) {
|
||||
p.captureExpired(t, "descendant capture did not quiesce")
|
||||
return
|
||||
}
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
}
|
||||
for _, fd := range refs {
|
||||
_ = p.signalFD(fd, unix.SIGTERM)
|
||||
}
|
||||
for _, fd := range refs {
|
||||
_ = p.signalFD(fd, unix.SIGCONT)
|
||||
}
|
||||
select {
|
||||
case <-p.done:
|
||||
case <-time.After(2 * time.Second):
|
||||
}
|
||||
for _, fd := range refs {
|
||||
_ = p.signalFD(fd, unix.SIGKILL)
|
||||
}
|
||||
_ = p.join(t, 5*time.Second)
|
||||
p.assertStopped(t)
|
||||
}
|
||||
|
||||
// A leader that exits as the capture window closes settles through assertStopped.
|
||||
func (p *ownedMini) captureExpired(t *testing.T, why string) {
|
||||
t.Helper()
|
||||
select {
|
||||
case <-p.done:
|
||||
p.assertStopped(t)
|
||||
default:
|
||||
miniFailStop(t, why)
|
||||
}
|
||||
}
|
||||
func (p *ownedMini) assertStopped(t *testing.T) {
|
||||
t.Helper()
|
||||
wait := p.censusWait
|
||||
if wait == 0 {
|
||||
wait = 5 * time.Second
|
||||
}
|
||||
deadline := time.Now().Add(wait)
|
||||
census := func() []int {
|
||||
if p.census != nil {
|
||||
return p.census()
|
||||
}
|
||||
return miniGroupLive(t, p.cmd.Process.Pid)
|
||||
}
|
||||
for {
|
||||
live := census()
|
||||
// A /proc listing is not atomic: a member can fork then disappear
|
||||
// between list and stat. Signal 0 is only an existence query (never a
|
||||
// numeric effect signal); ESRCH proves the entire group is now absent.
|
||||
absent := false
|
||||
if p.groupExists != nil {
|
||||
absent = !p.groupExists()
|
||||
} else {
|
||||
err := unix.Kill(-p.cmd.Process.Pid, 0)
|
||||
absent = errors.Is(err, unix.ESRCH)
|
||||
}
|
||||
// A member counted before ESRCH may have exited in between: count
|
||||
// again, so only a member still listed holds the settlement.
|
||||
if len(live) != 0 && absent {
|
||||
live = census()
|
||||
}
|
||||
if len(live) == 0 && absent {
|
||||
select {
|
||||
case <-p.done:
|
||||
p.settle()
|
||||
return
|
||||
default:
|
||||
miniFailStop(t, "empty group but leader not joined")
|
||||
}
|
||||
}
|
||||
if time.Now().After(deadline) {
|
||||
if len(live) == 0 {
|
||||
miniFailStop(t, "owned group still exists with no live member listed: a member the census missed, or zombies its new parent does not reap")
|
||||
}
|
||||
miniFailStop(t, fmt.Sprintf("owned group has live residue %v", live))
|
||||
}
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
||||
type miniProcInfo struct {
|
||||
pid, group int
|
||||
state, key string
|
||||
}
|
||||
|
||||
func miniProc(pid int) (miniProcInfo, error) {
|
||||
b, err := os.ReadFile(filepath.Join("/proc", strconv.Itoa(pid), "stat"))
|
||||
if err != nil {
|
||||
return miniProcInfo{}, err
|
||||
}
|
||||
end := strings.LastIndexByte(string(b), ')')
|
||||
if end < 0 {
|
||||
return miniProcInfo{}, fmt.Errorf("invalid proc stat")
|
||||
}
|
||||
fields := strings.Fields(string(b[end+1:]))
|
||||
if len(fields) < 20 {
|
||||
return miniProcInfo{}, fmt.Errorf("short proc stat")
|
||||
}
|
||||
group, err := strconv.Atoi(fields[2])
|
||||
if err != nil {
|
||||
return miniProcInfo{}, err
|
||||
}
|
||||
return miniProcInfo{pid: pid, group: group, state: fields[0], key: strconv.Itoa(pid) + ":" + fields[19]}, nil
|
||||
}
|
||||
func miniGroupMembers(t *testing.T, pgid int) []miniProcInfo {
|
||||
entries, err := os.ReadDir("/proc")
|
||||
if err != nil {
|
||||
miniFailStop(t, err.Error())
|
||||
}
|
||||
var members []miniProcInfo
|
||||
for _, entry := range entries {
|
||||
pid, err := strconv.Atoi(entry.Name())
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
info, err := miniProc(pid)
|
||||
if errors.Is(err, os.ErrNotExist) || errors.Is(err, unix.ESRCH) {
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
miniFailStop(t, err.Error())
|
||||
}
|
||||
if info.group == pgid && info.state != "Z" && info.state != "X" {
|
||||
members = append(members, info)
|
||||
}
|
||||
}
|
||||
return members
|
||||
}
|
||||
func miniGroupLive(t *testing.T, pgid int) []int {
|
||||
var live []int
|
||||
for _, m := range miniGroupMembers(t, pgid) {
|
||||
live = append(live, m.pid)
|
||||
}
|
||||
return live
|
||||
}
|
||||
|
||||
// An intentionally TERM-ignoring descendant exercises the safety net itself.
|
||||
func TestMiniOwnedGroupCleanupStopsDescendants(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
defer cancel()
|
||||
p := startOwnedMini(t, ctx, "/bin/sh", "-c", "trap '' TERM; sleep 60 & echo ready; wait")
|
||||
deadline := time.Now().Add(5 * time.Second)
|
||||
for !strings.Contains(p.output.String(), "ready") {
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatal("fixture did not start")
|
||||
}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
if live := miniGroupLive(t, p.cmd.Process.Pid); len(live) < 2 {
|
||||
t.Fatalf("descendant fixture not reached: %v", live)
|
||||
}
|
||||
p.stop(t)
|
||||
select {
|
||||
case <-p.done:
|
||||
default:
|
||||
t.Fatal("leader not joined")
|
||||
}
|
||||
}
|
||||
|
||||
// This real process settles normally before its registered cleanup runs. A
|
||||
// later cleanup must not dispatch anything to its old group or descriptor.
|
||||
func TestMiniSettledCleanupDoesNotSignal(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
p := startOwnedMini(t, ctx, "/bin/true")
|
||||
if err := p.join(t, 3*time.Second); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p.assertStopped(t)
|
||||
before := p.dispatches.Load()
|
||||
p.stop(t)
|
||||
if got := p.dispatches.Load(); got != before {
|
||||
t.Fatalf("settled cleanup dispatched %d signals", got-before)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMiniCleanupFailStopAndSettlement(t *testing.T) {
|
||||
for _, mode := range []string{"join", "residue", "missed-member", "settled", "late-exit-settled", "capture-settled", "capture-residue", "capture-expired-settled", "capture-expired-residue", "natural", "watchdog"} {
|
||||
t.Run(mode, func(t *testing.T) {
|
||||
marker := filepath.Join(t.TempDir(), "cleanup-ran")
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
self, err := os.Executable()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Setenv("MINI_CLEANUP_CONTROL", mode)
|
||||
t.Setenv("MINI_CLEANUP_MARKER", marker)
|
||||
p := startOwnedMini(t, ctx, self, "-test.run=^TestMiniCleanupFailStopHelper$")
|
||||
err = p.join(t, 3*time.Second)
|
||||
p.assertStopped(t)
|
||||
_, statErr := os.Stat(marker)
|
||||
if mode == "settled" || mode == "late-exit-settled" || mode == "capture-settled" || mode == "capture-expired-settled" || mode == "natural" {
|
||||
if err != nil || statErr != nil {
|
||||
t.Fatalf("positive cleanup twin: err=%v marker=%v", err, statErr)
|
||||
}
|
||||
} else if mode == "watchdog" {
|
||||
var exit *exec.ExitError
|
||||
if !errors.As(err, &exit) || exit.ExitCode() != 1 || !strings.Contains(p.output.String(), "watchdog intervened") || statErr != nil {
|
||||
t.Fatalf("watchdog cannot prove natural cleanup: err=%v marker=%v output=%s", err, statErr, p.output.String())
|
||||
}
|
||||
} else {
|
||||
var exit *exec.ExitError
|
||||
if !errors.As(err, &exit) || exit.ExitCode() != miniFailStopExit || !errors.Is(statErr, os.ErrNotExist) {
|
||||
t.Fatalf("fail-stop %s: err=%v marker=%v output=%s", mode, err, statErr, p.output.String())
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
func TestMiniCleanupFailStopHelper(t *testing.T) {
|
||||
mode := os.Getenv("MINI_CLEANUP_CONTROL")
|
||||
if mode == "" {
|
||||
t.Skip("isolated fail-stop helper")
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
if err := os.WriteFile(os.Getenv("MINI_CLEANUP_MARKER"), []byte("cleanup ran"), 0o600); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
})
|
||||
p := &ownedMini{done: make(chan struct{}), leaderFD: -1, censusWait: 10 * time.Millisecond, groupExists: func() bool { return false }}
|
||||
switch mode {
|
||||
case "join":
|
||||
p.join(t, 10*time.Millisecond)
|
||||
case "residue":
|
||||
close(p.done)
|
||||
p.census = func() []int { return []int{1234} }
|
||||
p.assertStopped(t)
|
||||
case "missed-member":
|
||||
close(p.done)
|
||||
p.census = func() []int { return nil }
|
||||
p.groupExists = func() bool { return true }
|
||||
p.assertStopped(t)
|
||||
case "settled":
|
||||
close(p.done)
|
||||
p.census = func() []int { return nil }
|
||||
p.assertStopped(t)
|
||||
case "late-exit-settled":
|
||||
close(p.done)
|
||||
counted := false
|
||||
p.census = func() []int {
|
||||
if counted {
|
||||
return nil
|
||||
}
|
||||
counted = true
|
||||
time.Sleep(2 * p.censusWait) // the member exits as the window closes
|
||||
return []int{1234}
|
||||
}
|
||||
p.assertStopped(t)
|
||||
case "capture-settled", "capture-residue", "capture-expired-settled", "capture-expired-residue":
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
p := startOwnedMini(t, ctx, "/bin/sleep", "60")
|
||||
p.censusWait = 10 * time.Millisecond
|
||||
if strings.HasSuffix(mode, "-residue") {
|
||||
p.census = func() []int { return []int{1234} }
|
||||
p.groupExists = func() bool { return true }
|
||||
}
|
||||
p.captureLeader = func(int) (miniProcInfo, error) {
|
||||
if strings.HasPrefix(mode, "capture-expired") {
|
||||
time.Sleep(1100 * time.Millisecond) // past the one-second capture window
|
||||
}
|
||||
_ = p.signalLeader(unix.SIGKILL)
|
||||
_ = p.join(t, time.Second)
|
||||
return miniProcInfo{}, os.ErrNotExist
|
||||
}
|
||||
p.stopGroup(t)
|
||||
case "natural", "watchdog":
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
bin, args := "/bin/false", []string{}
|
||||
if mode == "watchdog" {
|
||||
bin, args = "/bin/sleep", []string{"60"}
|
||||
}
|
||||
p := startOwnedMini(t, ctx, bin, args...)
|
||||
if mode == "watchdog" {
|
||||
cancel()
|
||||
}
|
||||
_ = p.join(t, time.Second)
|
||||
p.assertStopped(t)
|
||||
p.assertNaturalExit(t)
|
||||
default:
|
||||
t.Fatal("invalid control")
|
||||
}
|
||||
}
|
||||
|
||||
// A four-second shutdown exceeds the old WaitDelay. The context watchdog
|
||||
// must let it finish rather than kill its leader before children are stopped.
|
||||
func TestMiniContextAllowsChildShutdownGrace(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
p := startOwnedMini(t, ctx, "/bin/sh", "-c", "trap 'sleep 4; echo graceful; exit 0' TERM; echo ready; while :; do sleep .05; done")
|
||||
deadline := time.Now().Add(5 * time.Second)
|
||||
for !strings.Contains(p.output.String(), "ready") {
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatal("shutdown fixture not ready")
|
||||
}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
cancel()
|
||||
_ = p.join(t, miniShutdownGrace+10*time.Second)
|
||||
p.assertStopped(t)
|
||||
if !strings.Contains(p.output.String(), "graceful") {
|
||||
t.Fatalf("shutdown killed prematurely: %s", p.output.String())
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/durable"
|
||||
)
|
||||
|
||||
// The test lock directory override is refused under systemd
|
||||
@@ -50,3 +52,42 @@ func TestVolumeLockDirTestOnlyHiddenFromHelp(t *testing.T) {
|
||||
t.Fatalf("--help lists the test override:\n%s", out)
|
||||
}
|
||||
}
|
||||
|
||||
// Without the override the lock directory stays the host one: the provider
|
||||
// gets no override, so it uses durable.HostVolumeLockDir.
|
||||
func TestVolumeLockDirDefaultIsTheHostDirectory(t *testing.T) {
|
||||
t.Setenv("INVOCATION_ID", "")
|
||||
f, err := parseFlags(append(phase150RequiredBlockvolumeArgs(), "--durable-root="+t.TempDir(), "--durable-impl=walstore"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if f.volumeLockDirTestOnly != "" {
|
||||
t.Fatalf("a default start overrides the lock directory: %q", f.volumeLockDirTestOnly)
|
||||
}
|
||||
if durable.HostVolumeLockDir != "/run/sw-block/locks" {
|
||||
t.Fatalf("the host lock directory moved: %s", durable.HostVolumeLockDir)
|
||||
}
|
||||
}
|
||||
|
||||
// INV-WS-ONE-PROCESS-PER-HOST-001, the normal start: a start under systemd
|
||||
// (INVOCATION_ID set, as every shipped unit runs) keeps the host-wide volume
|
||||
// lock. Without the override it gets no lock directory of its own, so the
|
||||
// provider uses the host one; with the hidden test-only override it is
|
||||
// refused, naming the host lock directory it would have bypassed. Only a
|
||||
// start outside systemd (a test, or mini, which drops INVOCATION_ID from its
|
||||
// children and keeps data and lock under its --dir) may move the lock.
|
||||
func TestNormalStartKeepsTheHostVolumeLock(t *testing.T) {
|
||||
base := append(phase150RequiredBlockvolumeArgs(), "--durable-root="+t.TempDir(), "--durable-impl=walstore")
|
||||
t.Setenv("INVOCATION_ID", "0123456789abcdef")
|
||||
f, err := parseFlags(append([]string(nil), base...))
|
||||
if err != nil || f.volumeLockDirTestOnly != "" {
|
||||
t.Fatalf("a unit start without the override: lock dir %q, err %v; want the host directory", f.volumeLockDirTestOnly, err)
|
||||
}
|
||||
if durable.HostVolumeLockDir != "/run/sw-block/locks" {
|
||||
t.Fatalf("the host lock directory moved: %s", durable.HostVolumeLockDir)
|
||||
}
|
||||
_, err = parseFlags(append(append([]string(nil), base...), "--"+volumeLockDirTestOnlyFlag+"="+t.TempDir()))
|
||||
if err == nil || !strings.Contains(err.Error(), durable.HostVolumeLockDir) {
|
||||
t.Fatalf("a unit start with the override: %v; want a refusal naming %s", err, durable.HostVolumeLockDir)
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,9 @@ type miniConfig struct {
|
||||
// Explicit names the flags given on the command line (fs.Visit); a
|
||||
// --reuse refuses one that differs from the recorded run.
|
||||
Explicit map[string]bool
|
||||
// Self and WeedPath are the absolute paths of this sw-block and of the
|
||||
// weed it runs, for the commands mini prints; empty in unit tests.
|
||||
Self, WeedPath string
|
||||
}
|
||||
|
||||
// miniRecord is what a fresh start records in <dir>/mini.json and --reuse
|
||||
@@ -99,6 +102,23 @@ type miniRecord struct {
|
||||
|
||||
const miniRecordFile = "mini.json"
|
||||
|
||||
// Make an executable path absolute without collapsing symlink/.. components.
|
||||
func miniExecutablePath(path string) (string, error) {
|
||||
if filepath.IsAbs(path) {
|
||||
return path, nil
|
||||
}
|
||||
volume := filepath.VolumeName(path)
|
||||
base, err := filepath.Abs(volume + ".")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
relative := strings.TrimPrefix(path, volume)
|
||||
if len(relative) > 0 && os.IsPathSeparator(relative[0]) {
|
||||
return filepath.VolumeName(base) + relative, nil
|
||||
}
|
||||
return base + string(os.PathSeparator) + relative, nil
|
||||
}
|
||||
|
||||
func writeMiniRecord(dir string, r miniRecord) error {
|
||||
b, err := json.MarshalIndent(r, "", " ")
|
||||
if err != nil {
|
||||
@@ -119,6 +139,20 @@ func reuseMiniRecord(c *miniConfig, weedFound string) (string, error) {
|
||||
if err := json.Unmarshal(b, &r); err != nil {
|
||||
return "", fmt.Errorf("--reuse: %s/%s: %w", c.Dir, miniRecordFile, err)
|
||||
}
|
||||
if r.Weed != "" {
|
||||
abs, err := miniExecutablePath(r.Weed)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("--reuse: resolve weed path: %w", err)
|
||||
}
|
||||
r.Weed = abs
|
||||
}
|
||||
if c.Weed != r.Weed && c.Weed != "" && r.Weed != "" {
|
||||
now, errNow := os.Stat(c.Weed)
|
||||
then, errThen := os.Stat(r.Weed)
|
||||
if errNow == nil && errThen == nil && os.SameFile(now, then) {
|
||||
c.Weed = r.Weed
|
||||
}
|
||||
}
|
||||
differs := func(flag string, now, then any) error {
|
||||
if c.Explicit[flag] && fmt.Sprint(now) != fmt.Sprint(then) {
|
||||
return fmt.Errorf("--reuse: --%s %v differs from this dir's run (%v); drop it to reuse the run as recorded", flag, now, then)
|
||||
@@ -187,9 +221,16 @@ func miniMasterArgs(c miniConfig, chunk bool) []string {
|
||||
}
|
||||
|
||||
// miniVolumeArgs is blockvolume as swb_start runs it, plus, with a chunk
|
||||
// store, the walstore-chunk settings and the volume's layout id.
|
||||
// store, the walstore-chunk settings and the volume's layout id. Its volume
|
||||
// lock is under the run's dir, so mini needs no root and no tmpfiles.d entry
|
||||
// (a trial override, which blockvolume refuses under systemd); with a chunk
|
||||
// store it takes no scheduled snapshot (mini prints how to take one).
|
||||
func miniVolumeArgs(c miniConfig, chunk bool, layoutID string) []string {
|
||||
return miniVolumeSpec(c, chunk, layoutID).args()
|
||||
a := append(miniVolumeSpec(c, chunk, layoutID).args(), "--volume-lock-dir-test-only", filepath.Join(c.Dir, "locks"))
|
||||
if chunk {
|
||||
a = append(a, "--chunk-snapshot-schedule", "off")
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
// miniVolumeSpec is mini's v1: the same settings volume start writes for a
|
||||
@@ -269,13 +310,25 @@ type miniRun struct {
|
||||
|
||||
// start prints the command, then starts it with its output in <dir>/<name>.log.
|
||||
func (r *miniRun) start(name, bin string, args []string) (*miniChild, error) {
|
||||
fmt.Fprintf(r.out, "+ %s %s\n", bin, strings.Join(args, " "))
|
||||
words := []string{shQuote(bin)}
|
||||
for _, a := range args {
|
||||
words = append(words, shQuote(a))
|
||||
}
|
||||
fmt.Fprintf(r.out, "+ %s\n", strings.Join(words, " "))
|
||||
lf, err := os.Create(filepath.Join(r.cfg.Dir, name+".log"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cmd := exec.Command(bin, args...)
|
||||
cmd.Stdout, cmd.Stderr, cmd.Stdin = lf, lf, nil
|
||||
cmd.Env = []string{}
|
||||
// mini's children are not systemd units even when mini runs under one;
|
||||
// blockvolume refuses mini's lock directory while INVOCATION_ID is set.
|
||||
for _, kv := range os.Environ() {
|
||||
if !strings.HasPrefix(kv, "INVOCATION_ID=") {
|
||||
cmd.Env = append(cmd.Env, kv)
|
||||
}
|
||||
}
|
||||
if err := cmd.Start(); err != nil {
|
||||
lf.Close()
|
||||
return nil, fmt.Errorf("start %s: %w", name, err)
|
||||
@@ -322,6 +375,30 @@ func (r *miniRun) ready(ctx context.Context, c *miniChild, ports ...int) error {
|
||||
}
|
||||
}
|
||||
|
||||
// resolveLayoutID looks up volume's layout id through blockmaster,
|
||||
// retrying while blockmaster registers it, bounded by miniResolveWait.
|
||||
func (r *miniRun) resolveLayoutID(ctx context.Context, master, volume string) (string, error) {
|
||||
deadline := time.Now().Add(miniResolveWait)
|
||||
for {
|
||||
rctx, rcancel := context.WithTimeout(ctx, 5*time.Second)
|
||||
id, err := resolveVolumeID(rctx, master, volume)
|
||||
rcancel()
|
||||
if err == nil {
|
||||
return id.String(), nil
|
||||
}
|
||||
if d := r.dead(); d != nil {
|
||||
return "", fmt.Errorf("%s exited while resolving %s's layout id: %v", d.name, volume, d.err)
|
||||
}
|
||||
if ctx.Err() != nil || time.Now().After(deadline) {
|
||||
return "", fmt.Errorf("resolve %s's layout id: %v", volume, err)
|
||||
}
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
case <-time.After(time.Second):
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dead is the first child that has exited, if any.
|
||||
func (r *miniRun) dead() *miniChild {
|
||||
for _, c := range r.children {
|
||||
@@ -414,10 +491,26 @@ func runMini(args []string, stdout, stderr io.Writer) int {
|
||||
func mini(ctx context.Context, cfg miniConfig, stdout, stderr io.Writer) (int, error) {
|
||||
weed := cfg.Weed
|
||||
if weed == "" {
|
||||
weed, _ = exec.LookPath("weed")
|
||||
var err error
|
||||
if weed, err = exec.LookPath("weed"); errors.Is(err, exec.ErrDot) {
|
||||
if !cfg.Reuse {
|
||||
return ops.VolumeStatusExitInvalid, fmt.Errorf("weed on PATH is in the current directory (%v); pass --weed %s to use it", err, shQuote("./"+weed))
|
||||
}
|
||||
weed = ""
|
||||
}
|
||||
} else if st, err := os.Stat(weed); err != nil || st.IsDir() {
|
||||
return ops.VolumeStatusExitInvalid, fmt.Errorf("--weed %s not found", weed)
|
||||
}
|
||||
if weed != "" {
|
||||
abs, err := miniExecutablePath(weed)
|
||||
if err != nil {
|
||||
return ops.VolumeStatusExitInvalid, fmt.Errorf("resolve weed path: %w", err)
|
||||
}
|
||||
weed = abs
|
||||
if cfg.Weed != "" {
|
||||
cfg.Weed = abs
|
||||
}
|
||||
}
|
||||
// A reuse takes the recorded run (its binaries included) before any
|
||||
// lookup; a fresh start finds the binaries next to sw-block by default.
|
||||
if cfg.Reuse {
|
||||
@@ -485,7 +578,11 @@ func mini(ctx context.Context, cfg miniConfig, stdout, stderr io.Writer) (int, e
|
||||
return 1, err
|
||||
}
|
||||
}
|
||||
for _, d := range []string{filepath.Join(cfg.Dir, "master"), filepath.Join(cfg.Dir, "vol")} {
|
||||
if exe, err := os.Executable(); err == nil {
|
||||
cfg.Self = exe
|
||||
}
|
||||
cfg.WeedPath = weed
|
||||
for _, d := range []string{filepath.Join(cfg.Dir, "master"), filepath.Join(cfg.Dir, "vol"), filepath.Join(cfg.Dir, "locks")} {
|
||||
if err := os.MkdirAll(d, 0o755); err != nil {
|
||||
return 1, err
|
||||
}
|
||||
@@ -494,6 +591,8 @@ func mini(ctx context.Context, cfg miniConfig, stdout, stderr io.Writer) (int, e
|
||||
defer r.stop()
|
||||
fail := func(err error) (int, error) {
|
||||
r.tail(20)
|
||||
r.stop()
|
||||
fmt.Fprintf(stderr, "sw-block mini: not started; logs in %s/*.log. After fixing the cause, start again on it with\n %s\nor remove %s and start fresh.\n", shQuote(cfg.Dir), miniResume(cfg), shQuote(cfg.Dir))
|
||||
return 1, err
|
||||
}
|
||||
if chunk {
|
||||
@@ -522,26 +621,9 @@ func mini(ctx context.Context, cfg miniConfig, stdout, stderr io.Writer) (int, e
|
||||
}
|
||||
layoutID := ""
|
||||
if chunk {
|
||||
fmt.Fprintf(stdout, "+ sw-block ops volume resolve --master %s %s\n", loopback(cfg.Ports.Master), miniVolume)
|
||||
deadline := time.Now().Add(miniResolveWait)
|
||||
for {
|
||||
rctx, rcancel := context.WithTimeout(ctx, 5*time.Second)
|
||||
id, err := resolveVolumeID(rctx, loopback(cfg.Ports.Master), miniVolume)
|
||||
rcancel()
|
||||
if err == nil {
|
||||
layoutID = id.String()
|
||||
break
|
||||
}
|
||||
if d := r.dead(); d != nil {
|
||||
return fail(fmt.Errorf("%s exited while resolving %s's layout id: %v", d.name, miniVolume, d.err))
|
||||
}
|
||||
if ctx.Err() != nil || time.Now().After(deadline) {
|
||||
return fail(fmt.Errorf("resolve %s's layout id: %v", miniVolume, err))
|
||||
}
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
case <-time.After(time.Second):
|
||||
}
|
||||
fmt.Fprintf(stdout, "+ %s ops volume resolve --master %s %s\n", miniSelf(cfg), loopback(cfg.Ports.Master), miniVolume)
|
||||
if layoutID, err = r.resolveLayoutID(ctx, loopback(cfg.Ports.Master), miniVolume); err != nil {
|
||||
return fail(err)
|
||||
}
|
||||
}
|
||||
vc, err := r.start("blockvolume", volume, miniVolumeArgs(cfg, chunk, layoutID))
|
||||
@@ -601,9 +683,18 @@ func shQuote(s string) string {
|
||||
return "'" + strings.ReplaceAll(s, "'", `'\''`) + "'"
|
||||
}
|
||||
|
||||
// miniSelf is how a printed command names this sw-block: its absolute path
|
||||
// when known, so the command runs from any directory.
|
||||
func miniSelf(c miniConfig) string {
|
||||
if c.Self == "" {
|
||||
return "sw-block"
|
||||
}
|
||||
return shQuote(c.Self)
|
||||
}
|
||||
|
||||
// miniResume is the command that starts the recorded run in c.Dir again.
|
||||
func miniResume(c miniConfig) string {
|
||||
return "sw-block mini --dir " + shQuote(c.Dir) + " --reuse"
|
||||
return miniSelf(c) + " mini --dir " + shQuote(c.Dir) + " --reuse"
|
||||
}
|
||||
|
||||
// miniNextSteps prints what to run next; mini runs none of it.
|
||||
@@ -619,9 +710,14 @@ func miniNextSteps(w io.Writer, c miniConfig, chunk bool) {
|
||||
return
|
||||
}
|
||||
cmds := miniCommands(c, chunk)
|
||||
fmt.Fprintf(w, "\nCheck the volume:\n sw-block %s\n sw-block %s\n", strings.Join(cmds[0], " "), strings.Join(cmds[1], " "))
|
||||
fmt.Fprintf(w, "\nSnapshot:\n sw-block %s\n", strings.Join(cmds[2], " "))
|
||||
fmt.Fprintf(w, "\nSeaweedFS itself: weed shell -master=%s\n", loopback(c.Ports.WeedMaster))
|
||||
self := miniSelf(c)
|
||||
fmt.Fprintf(w, "\nCheck the volume:\n %s %s\n %s %s\n", self, strings.Join(cmds[0], " "), self, strings.Join(cmds[1], " "))
|
||||
fmt.Fprintf(w, "\nSnapshot (mini takes no scheduled snapshot):\n %s %s\n", self, strings.Join(cmds[2], " "))
|
||||
weed := "weed"
|
||||
if c.WeedPath != "" {
|
||||
weed = shQuote(c.WeedPath)
|
||||
}
|
||||
fmt.Fprintf(w, "\nSeaweedFS itself: %s shell -master=%s\n", weed, loopback(c.Ports.WeedMaster))
|
||||
}
|
||||
|
||||
// miniBeforeStop reminds the user, before the target goes away, to have
|
||||
|
||||
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
@@ -57,6 +58,9 @@ func fakeMiniChild(mode string) int {
|
||||
term := make(chan os.Signal, 1)
|
||||
signal.Notify(term, syscall.SIGTERM)
|
||||
if mode == "die-"+name {
|
||||
if marker := os.Getenv("SWB_MINI_FAKE_RAN"); marker != "" {
|
||||
_ = os.WriteFile(marker, []byte(name), 0o644)
|
||||
}
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
return 9
|
||||
}
|
||||
@@ -145,7 +149,9 @@ func TestMiniWalstoreFlagsAreThePage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
for f := range got {
|
||||
if _, ok := page[f]; !ok {
|
||||
// mini keeps the volume lock under --dir, so it needs no root
|
||||
// (the page's unit uses the host lock directory).
|
||||
if _, ok := page[f]; !ok && f != "--volume-lock-dir-test-only" {
|
||||
t.Errorf("%s: mini passes %s; the page's swb_start does not", c.binary, f)
|
||||
}
|
||||
}
|
||||
@@ -328,7 +334,7 @@ func TestMiniInterruptStopsEveryChild(t *testing.T) {
|
||||
}
|
||||
})
|
||||
waitOutput(t, out, "sw-block mini: running")
|
||||
for _, want := range []string{"+ " + filepath.Join(c.Bin, "blockmaster") + " ", "+ " + filepath.Join(c.Bin, "blockvolume") + " ", "sudo nvme connect -t tcp -a 127.0.0.1 -s " + strconv.Itoa(c.Ports.NVMe) + " -n nqn.test:v1", "sudo nvme disconnect -n nqn.test:v1",
|
||||
for _, want := range []string{"+ " + shQuote(filepath.Join(c.Bin, "blockmaster")) + " ", "+ " + shQuote(filepath.Join(c.Bin, "blockvolume")) + " ", "sudo nvme connect -t tcp -a 127.0.0.1 -s " + strconv.Itoa(c.Ports.NVMe) + " -n nqn.test:v1", "sudo nvme disconnect -n nqn.test:v1",
|
||||
"sw-block mini: no chunk store: snapshots unavailable", "trial setup: one host, loopback, no authentication"} {
|
||||
if !strings.Contains(out.String(), want) {
|
||||
t.Fatalf("output lacks %q:\n%s", want, out.String())
|
||||
@@ -344,7 +350,12 @@ func TestMiniInterruptStopsEveryChild(t *testing.T) {
|
||||
case <-time.After(30 * time.Second):
|
||||
t.Fatal("mini did not stop")
|
||||
}
|
||||
for _, want := range []string{"if v1 is connected: unmount it, then sudo nvme disconnect -n nqn.test:v1", "The data stays in " + c.Dir, " " + miniResume(c) + "\n"} {
|
||||
self, err := os.Executable()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
resume := miniResume(miniConfig{Dir: c.Dir, Self: self})
|
||||
for _, want := range []string{"if v1 is connected: unmount it, then sudo nvme disconnect -n nqn.test:v1", "The data stays in " + c.Dir, " " + resume + "\n"} {
|
||||
if !strings.Contains(out.String(), want) {
|
||||
t.Fatalf("at stop, output lacks %q:\n%s", want, out.String())
|
||||
}
|
||||
@@ -442,7 +453,8 @@ func wantChunkCommands(dir, id string) map[string][]string {
|
||||
"--data-addr", "127.0.0.1:9201", "--ctrl-addr", "127.0.0.1:9202", "--status-addr", "127.0.0.1:9203",
|
||||
"--durable-root", filepath.Join(dir, "vol"), "--durable-impl", "walstore-chunk", "--durable-blocks", "65536", "--durable-blocksize", "4096",
|
||||
"--chunk-filer", "127.0.0.1:18888", "--chunk-path", "/swblock/chunks", "--chunk-control-endpoint", "--workspace-lease", "--layout-id", id,
|
||||
"--nvme-listen", "127.0.0.1:4420", "--nvme-subsysnqn", "nqn.2026-05.io.seaweedfs:v1"},
|
||||
"--nvme-listen", "127.0.0.1:4420", "--nvme-subsysnqn", "nqn.2026-05.io.seaweedfs:v1",
|
||||
"--volume-lock-dir-test-only", filepath.Join(dir, "locks"), "--chunk-snapshot-schedule", "off"},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,6 +589,52 @@ func TestMiniWeedDyingDuringStartupStopsTheRest(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMiniRelativeWeedIsRecordedAndPrintedAbsolutely(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("signals and listening children: Linux")
|
||||
}
|
||||
t.Setenv("SWB_MINI_FAKE_CHILD", "die-weed")
|
||||
ran := filepath.Join(t.TempDir(), "ran")
|
||||
t.Setenv("SWB_MINI_FAKE_RAN", ran)
|
||||
bin := fakeBin(t)
|
||||
abs := filepath.Join(bin, "weed")
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rel, err := filepath.Rel(cwd, abs)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c := miniConfig{Dir: filepath.Join(t.TempDir(), "run"), Bin: bin, Weed: rel, NQN: "n", SizeBytes: 1 << 20, Ports: freePorts(t)}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||
defer cancel()
|
||||
out := &syncBuf{}
|
||||
code, err := mini(ctx, c, out, io.Discard)
|
||||
if code == 0 || err == nil {
|
||||
t.Fatalf("fixture must reach the dying weed: code=%d err=%v", code, err)
|
||||
}
|
||||
b, err := os.ReadFile(filepath.Join(c.Dir, miniRecordFile))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var record miniRecord
|
||||
if err := json.Unmarshal(b, &record); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
selected, selectedErr := os.Stat(abs)
|
||||
recorded, recordedErr := os.Stat(record.Weed)
|
||||
if selectedErr != nil || recordedErr != nil || !filepath.IsAbs(record.Weed) || !os.SameFile(selected, recorded) {
|
||||
t.Errorf("record weed=%q changed selected executable %q", record.Weed, abs)
|
||||
}
|
||||
if !strings.Contains(out.String(), "+ "+shQuote(record.Weed)+" ") {
|
||||
t.Errorf("relative weed command: %s", out.String())
|
||||
}
|
||||
if _, err := os.Stat(ran); err != nil {
|
||||
t.Errorf("the selected weed did not run: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// --reuse starts the recorded run again: its size, ports, mode (its weed)
|
||||
// and NQN, whatever the defaults are; a flag that differs from the record
|
||||
// is refused, and so are a recorded weed that is gone and a walstore run
|
||||
@@ -800,3 +858,83 @@ func TestMiniPrintedResumeRunsOnASpacedDir(t *testing.T) {
|
||||
t.Fatalf("control: the unquoted line reached the dir too (exit %d)", code)
|
||||
}
|
||||
}
|
||||
|
||||
// mini started from a systemd service's process tree (a CI runner unit, a
|
||||
// terminal server) inherits INVOCATION_ID; blockvolume refuses the lock-dir
|
||||
// override under it, so mini's children must start without it.
|
||||
func TestMiniChildrenStartWithoutInvocationID(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("Unix child environment and signals")
|
||||
}
|
||||
t.Setenv("INVOCATION_ID", "0123456789abcdef")
|
||||
dir := t.TempDir()
|
||||
r := &miniRun{cfg: miniConfig{Dir: dir}, out: io.Discard, log: io.Discard}
|
||||
c, err := r.start("env", "/bin/sh", []string{"-c", `echo "id=${INVOCATION_ID-unset}"`})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
joined := false
|
||||
stop := func() {
|
||||
if joined {
|
||||
return
|
||||
}
|
||||
_ = c.cmd.Process.Signal(syscall.SIGTERM)
|
||||
select {
|
||||
case <-c.done:
|
||||
joined = true
|
||||
return
|
||||
case <-time.After(2 * time.Second):
|
||||
}
|
||||
_ = c.cmd.Process.Kill()
|
||||
select {
|
||||
case <-c.done:
|
||||
joined = true
|
||||
case <-time.After(2 * time.Second):
|
||||
fmt.Fprintln(os.Stderr, "mini child did not join; stopping tests before directory cleanup")
|
||||
os.Exit(86)
|
||||
}
|
||||
}
|
||||
t.Cleanup(stop)
|
||||
select {
|
||||
case <-c.done:
|
||||
joined = true
|
||||
case <-time.After(2 * time.Second):
|
||||
stop()
|
||||
t.Fatal("mini environment child did not finish")
|
||||
}
|
||||
b, err := os.ReadFile(filepath.Join(dir, "env.log"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := strings.TrimSpace(string(b)); got != "id=unset" {
|
||||
t.Fatalf("mini's child saw %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
// An empty filtered environment must be explicit: nil would inherit again.
|
||||
func TestMiniOnlyInvocationIDDoesNotLeak(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("Unix environment child")
|
||||
}
|
||||
saved := os.Environ()
|
||||
t.Cleanup(func() {
|
||||
os.Clearenv()
|
||||
for _, kv := range saved {
|
||||
key, value, _ := strings.Cut(kv, "=")
|
||||
_ = os.Setenv(key, value)
|
||||
}
|
||||
})
|
||||
os.Clearenv()
|
||||
TestMiniChildrenStartWithoutInvocationID(t)
|
||||
}
|
||||
|
||||
// Assert the actual weed-hint call site, not only the quoting helper. This
|
||||
// stays sensitive if formatting is correct but the hint stops calling it.
|
||||
func TestMiniProductionWeedHintQuotesItsExecutable(t *testing.T) {
|
||||
var out bytes.Buffer
|
||||
miniNextSteps(&out, miniConfig{WeedPath: "/tmp/weed's tools/weed"}, true)
|
||||
const want = `SeaweedFS itself: '/tmp/weed'\''s tools/weed' shell -master=`
|
||||
if !strings.Contains(out.String(), want) {
|
||||
t.Fatalf("production weed hint lacks %q:\n%s", want, out.String())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestMiniWeedSymlinkParentKeepsSelectedExecutable(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("Unix symlink and child-process fixture")
|
||||
}
|
||||
t.Setenv("SWB_MINI_FAKE_CHILD", "die-weed")
|
||||
bin := fakeBin(t)
|
||||
root := t.TempDir()
|
||||
for _, dir := range []string{"tools", "releases/v2"} {
|
||||
if err := os.MkdirAll(filepath.Join(root, dir), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
selected := filepath.Join(root, "releases", "weed")
|
||||
if err := os.Symlink(filepath.Join(bin, "weed"), selected); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(root, "tools", "weed"), []byte("wrong executable"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Symlink(filepath.Join(root, "releases", "v2"), filepath.Join(root, "tools", "current")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Chdir(root)
|
||||
rel := "tools/current/../weed"
|
||||
want, err := os.Stat(selected)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
check := func(t *testing.T, path string) {
|
||||
t.Helper()
|
||||
got, err := os.Stat(path)
|
||||
if err != nil || !filepath.IsAbs(path) || !os.SameFile(want, got) {
|
||||
t.Fatalf("selected executable changed: path=%q stat=%v", path, err)
|
||||
}
|
||||
}
|
||||
t.Run("fresh", func(t *testing.T) {
|
||||
ran := filepath.Join(t.TempDir(), "ran")
|
||||
t.Setenv("SWB_MINI_FAKE_RAN", ran)
|
||||
c := miniConfig{Dir: filepath.Join(t.TempDir(), "run"), Bin: bin, Weed: rel, NQN: "n", SizeBytes: 1 << 20, Ports: freePorts(t)}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||
defer cancel()
|
||||
out := &syncBuf{}
|
||||
_, _ = mini(ctx, c, out, io.Discard)
|
||||
data, err := os.ReadFile(filepath.Join(c.Dir, miniRecordFile))
|
||||
if err != nil {
|
||||
t.Fatalf("did not reach record publication: %v; %s", err, out.String())
|
||||
}
|
||||
var record miniRecord
|
||||
if err := json.Unmarshal(data, &record); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
check(t, record.Weed)
|
||||
if !strings.Contains(out.String(), "+ "+shQuote(record.Weed)+" ") {
|
||||
t.Fatalf("selected executable was not launched: %s", out.String())
|
||||
}
|
||||
if _, err := os.Stat(ran); err != nil {
|
||||
t.Fatalf("the selected weed did not run: %v", err)
|
||||
}
|
||||
})
|
||||
t.Run("legacy", func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
if err := writeMiniRecord(dir, miniRecord{Weed: rel, Bin: bin, SizeBytes: 1 << 20, NQN: "n"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c := miniConfig{Dir: dir}
|
||||
weed, err := reuseMiniRecord(&c, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
check(t, weed)
|
||||
})
|
||||
}
|
||||
|
||||
func TestMiniRefusesWeedFoundThroughDotInPath(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("Unix PATH lookup")
|
||||
}
|
||||
dir := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(dir, "weed"), []byte("#!/bin/sh\nexit 0\n"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Chdir(dir)
|
||||
t.Setenv("PATH", ".")
|
||||
c := miniConfig{Dir: filepath.Join(t.TempDir(), "run"), NQN: "n", SizeBytes: 1 << 20, Ports: freePorts(t)}
|
||||
code, err := mini(context.Background(), c, io.Discard, io.Discard)
|
||||
if code == 0 || err == nil || !strings.Contains(err.Error(), "current directory") {
|
||||
t.Fatalf("weed found only through . in PATH: code %d err %v; want a refusal", code, err)
|
||||
}
|
||||
if _, err := os.Stat(c.Dir); !os.IsNotExist(err) {
|
||||
t.Fatalf("refused start created %s: %v", c.Dir, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMiniReuseAcceptsSameWeedFromAnotherDirectory(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("Unix paths")
|
||||
}
|
||||
root := t.TempDir()
|
||||
for _, d := range []string{"a", "b", "bin"} {
|
||||
if err := os.MkdirAll(filepath.Join(root, d), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(root, "bin", "weed"), []byte("x"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(root, "bin", "other"), []byte("x"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
dir := t.TempDir()
|
||||
recorded := filepath.Join(root, "a") + "/../bin/weed"
|
||||
if err := writeMiniRecord(dir, miniRecord{Weed: recorded, Bin: t.TempDir(), SizeBytes: 1 << 20, NQN: "n"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Chdir(filepath.Join(root, "b"))
|
||||
weedNow := func(t *testing.T, rel string) (string, error) {
|
||||
t.Helper()
|
||||
abs, err := miniExecutablePath(rel)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c := miniConfig{Dir: dir, Weed: abs, Explicit: map[string]bool{"weed": true}}
|
||||
return reuseMiniRecord(&c, abs)
|
||||
}
|
||||
if weed, err := weedNow(t, "../bin/weed"); err != nil || weed != recorded {
|
||||
t.Fatalf("same weed through another cwd: weed %q err %v; want the recorded %q", weed, err, recorded)
|
||||
}
|
||||
if _, err := weedNow(t, "../bin/other"); err == nil || !strings.Contains(err.Error(), "differs") {
|
||||
t.Fatalf("a different executable: err %v; want a refusal", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMiniStartTraceQuotesPathsWithSpaces(t *testing.T) {
|
||||
dir := filepath.Join(t.TempDir(), "my tools")
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
out := &syncBuf{}
|
||||
r := &miniRun{cfg: miniConfig{Dir: dir}, out: out}
|
||||
if _, err := r.start("weed", filepath.Join(dir, "absent"), []string{"mini", "-dir=" + dir}); err == nil {
|
||||
t.Fatal("an absent executable started")
|
||||
}
|
||||
want := "+ " + shQuote(filepath.Join(dir, "absent")) + " mini " + shQuote("-dir="+dir) + "\n"
|
||||
if got := out.String(); got != want || !strings.Contains(got, "'") {
|
||||
t.Fatalf("start trace %q; want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMiniReuseIgnoresWeedFoundThroughDotInPath(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("Unix PATH lookup")
|
||||
}
|
||||
bin := fakeBin(t)
|
||||
cwd := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(cwd, "weed"), []byte("#!/bin/sh\nexit 0\n"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Chdir(cwd)
|
||||
t.Setenv("PATH", ".")
|
||||
for name, recorded := range map[string]string{"chunk": filepath.Join(bin, "weed"), "walstore": ""} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
if err := writeMiniRecord(dir, miniRecord{SizeBytes: 1 << 20, NQN: "n", Bin: bin, Weed: recorded}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ports := freePorts(t)
|
||||
l, err := net.Listen("tcp", loopback(ports.NVMe))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer l.Close()
|
||||
c := miniConfig{Dir: dir, NQN: "n", SizeBytes: 1 << 20, Ports: ports, Reuse: true, Explicit: map[string]bool{}}
|
||||
code, err := mini(context.Background(), c, io.Discard, io.Discard)
|
||||
if err == nil || !strings.Contains(err.Error(), "in use") {
|
||||
t.Fatalf("--reuse with ./weed only through . in PATH: code %d err %v; want the recorded run (then the busy port)", code, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// The refusal's hint is a pastable shell word: a relative PATH entry with a
|
||||
// space ("my tools") prints its --weed path quoted, as mini's other printed
|
||||
// commands are.
|
||||
func TestMiniDotWeedHintQuotesAPathWithASpace(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("Unix PATH lookup")
|
||||
}
|
||||
dir := t.TempDir()
|
||||
tools := filepath.Join(dir, "my tools")
|
||||
if err := os.MkdirAll(tools, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
nl := string(rune(10))
|
||||
if err := os.WriteFile(filepath.Join(tools, "weed"), []byte("#!/bin/sh"+nl+"exit 0"+nl), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Chdir(dir)
|
||||
t.Setenv("PATH", "my tools")
|
||||
c := miniConfig{Dir: filepath.Join(t.TempDir(), "run"), NQN: "n", SizeBytes: 1 << 20, Ports: freePorts(t)}
|
||||
_, err := mini(context.Background(), c, io.Discard, io.Discard)
|
||||
if err == nil || !strings.Contains(err.Error(), "pass --weed './my tools/weed' to use it") {
|
||||
t.Fatalf("weed found through a relative PATH entry with a space: %v; want the quoted --weed hint", err)
|
||||
}
|
||||
}
|
||||
@@ -401,8 +401,8 @@ stateDiagram-v2
|
||||
Drained --> Acked: revocation acknowledged with the HEAD gen
|
||||
}
|
||||
state "HEAD holder" as H {
|
||||
[*] --> Attaching: this process took the volume's host lock
|
||||
[*] --> Refused: another live process holds the volume's host lock
|
||||
[*] --> Attaching: this process took the volume lock (host lock, or a mini trial's own lock dir)
|
||||
[*] --> Refused: another live process holds that volume lock
|
||||
Attaching --> Claiming: fresh or same-holder local root
|
||||
Attaching --> Refused: existing root, HEAD published by another holder or above its durable LSN
|
||||
Claiming --> Cooling: replace generation (or exclusive create), same image
|
||||
@@ -423,7 +423,7 @@ stateDiagram-v2
|
||||
| StopPending | StopPending | each sleep after a completed renewal is at most `stopPendingPoll` (250 ms); a renewal already in flight is not interrupted | `core/host/volume/workspace_lease.go` `renewDelay`, `Run` | `INV-WS-STOP-PENDING-001` |
|
||||
| StopPending | Valid | only the latest detach attempt, provably not applied, with serving resumed; an applied, fenced or unknown outcome, or an older attempt's resume, leaves StopPending | `core/frontend/durable/provider_chunk.go` `resumeAfterDetach`; `core/host/volume/workspace_runtime.go` `WorkspaceStopResumed`; `core/host/volume/workspace_lease.go` `ClearStopPending` | `INV-WS-STOP-PENDING-001` |
|
||||
| Fenced | Drained, Acked | the stop callback succeeded; only then, and only when revoked, the acknowledgement is sent; a call that got no answer (`DeadlineExceeded`, `Unavailable`) is made again until the lease deadline, any other answer is final | `core/host/volume/workspace_lease.go` `drain`, `retryableAckError` | `INV-WS-REVOKE-ACK-001`, `INV-WS-REVOKE-ACK-RETRY-001` |
|
||||
| (start) | Attaching, Refused | the volume's host lock `/run/sw-block/locks/<volume id>.lock` is taken before the store opens; held by another live process, or its directory or file cannot be created or opened, refuses (`storage.ErrWALStoreLocked`, `ErrVolumeLockDirUnavailable`) | `core/frontend/durable/provider.go` `DurableProvider.lockVolumeOnHost` (from `ensureHandle`) | `INV-WS-ONE-PROCESS-PER-HOST-001` |
|
||||
| (start) | Attaching, Refused | normal starts take the volume's host lock `/run/sw-block/locks/<volume id>.lock` before the store opens (a mini trial's blockvolume instead uses the run's `--dir/locks`, also when mini runs under systemd, since mini drops `INVOCATION_ID` from its children); held by another live process, or its directory or file cannot be created or opened, refuses (`storage.ErrWALStoreLocked`, `ErrVolumeLockDirUnavailable`) | `core/frontend/durable/provider.go` `DurableProvider.lockVolumeOnHost` (from `ensureHandle`) | `INV-WS-ONE-PROCESS-PER-HOST-001` |
|
||||
| Attaching | Refused | a local root from another claim or behind HEAD's position (`layout.ErrStaleLocalRoot`): final typed refusal with a cure, no serving or retry | `core/frontend/durable/provider_layout.go` `startLayoutRoot`; `provider_chunk.go` `recoverChunk`, `chunkAuthorityWait` | `INV-WS-STALE-LOCAL-ROOT-001` |
|
||||
| (startup) | Refused | The agreed leader lists another filer or several; or all configured masters cannot agree and confirm exactly the target within 60 s (`ErrNotSingleFiler`) | `core/frontend/chunkstore/single_filer.go` `CheckSingleFiler`; `cmd/blockvolume/chunk_remote.go` `newChunkWiring` | `INV-WS-SINGLE-FILER-001` |
|
||||
| (startup) | (startup), chunk guard on or off | on only if the filer definitely refuses the probe's mismatched chunk-condition update of a disposable HEAD; then every store the catalog opens sends the chunk condition. Any other answer leaves it off (page re-read only) and refuses nothing. sw-block metadata writers run the same probe within their --timeout | `core/frontend/chunkstore/startup_head_probe.go` `checkConditionalHead`, `probeChunkCondition`, `ProbeChunkGuard`; `cmd/sw-block/chunk_b.go` `bCatalog` | `INV-WS-CHUNK-CONDITION-PROBE-001` |
|
||||
@@ -1131,7 +1131,7 @@ Notes:
|
||||
| `INV-WS-CLAIM-BEFORE-SERVE-001` | A new B holder claims HEAD at its issued epoch only after the local root is validated against the HEAD it updates; an older epoch or another holder at the same epoch is refused, and guest writes stay closed until assignment and claim. | M9 Start → Claim → Serving | `core/frontend/chunkstore/layout/start.go` `Start`; `core/frontend/durable/provider_layout.go` `startLayoutRoot` | `TestStart_ValidatesAgainstTheHeadItUpdates`, `TestStart_Refusals` (`core/frontend/chunkstore/layout/start_test.go`); `TestStart_TheClaimRechecksTheSeedRule` (`core/frontend/chunkstore/layout/start_seed_test.go`); `TestFreshStoreRefusesWriteBeforeAssignmentThenPublishesAfterClaim` (`core/frontend/durable/provider_restore_schedule_test.go`) | `INV-SNAPK-START-LINEAGE-001`, `INV-SNAPK-START-CLAIM-001` | ACTIVE |
|
||||
| `INV-VOL-GEOMETRY-FLAGS-RECORD-001` | A create-mode start whose `--durable-blocks`/`--durable-blocksize` disagree with the volume record exits 78 before any local store exists; an existing store is checked only at attach; an absent record keeps the create path; an unread record exits 75 (filer failed) or 78 (corrupt). | blockvolume startup (before the durable provider) | `cmd/blockvolume/main.go`; `cmd/blockvolume/chunk_remote.go` `geometryFlagsRefusal`; `core/frontend/chunkstore/layout/volume.go`, `start.go`, `create.go`; `core/frontend/chunkstore/catalog_b.go` | `TestGeometryFlagsRefusalComparesTheRecord`, `TestVolumeRequiresGeometry`, `TestVolumeGeometryChecksAndIsImmutable`, `TestStartGeometryMismatchPrecedesClaim`, `TestBCatalogRestoreCopiesVolumeGeometry`, `TestVolumeGeometryLivesOnlyInVolume` | K3: immutable required VOLUME geometry; Start checks the local persisted shape before claim; restores copy source geometry; no resize or compatibility path. | ACTIVE |
|
||||
| `INV-WS-STALE-LOCAL-ROOT-001` | An old or rolled-back local root is refused by `layout.Start` before serving; synchronous and deferred attach end without retry and report the typed stale-root error and cure. A fresh root at its own epoch likewise ends with `ErrMissingLocalRoot` and its cure. | M4 Claiming → Refused | `core/frontend/durable/provider_layout.go` `startLayoutRoot`; `core/frontend/durable/provider_chunk.go` `recoverChunk`, `chunkAuthorityWait`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestLayoutProviderRefusesEmptyOwnEpochAndRemountedOldRoot`, `TestFinalLayoutStartRefusalTable` (`core/frontend/durable/provider_layout_test.go`, `provider_layout_start_class_test.go`) | — | ACTIVE |
|
||||
| `INV-WS-ONE-PROCESS-PER-HOST-001` | One host runs at most one live blockvolume per volume: each takes the volume's exclusive host lock before its store opens and holds it until the store closes; a second is refused before it opens anything, whatever its `--durable-root`. | M4 (start) → Attaching, Refused | `core/frontend/durable/provider.go` `DurableProvider.lockVolumeOnHost` | `TestOneLiveProcessPerVolumePerHost`, `TestHostVolumeLockDirectoryCreatedOrRefused`, `TestHostVolumeLockRefusesNonDirectoryLockPath`, `TestHostVolumeLockTakesReadOnlyLockFile` (`core/frontend/durable/one_process_per_volume_test.go`); `TestHostVolumeLockCreatesParent0755AndLocks0700`, `TestHostVolumeLockKeepsExistingDirectoryModes` (`core/frontend/durable/volume_lock_parent_mode_test.go`); `TestVolumeLockDirTestOnlyRefusedUnderSystemd` (`cmd/blockvolume/volume_lock_flag_test.go`) | — | ACTIVE |
|
||||
| `INV-WS-ONE-PROCESS-PER-HOST-001` | Normal starts exclude a second process from a volume's local data with a host lock until store close. Mini puts both data and lock under --dir via the hidden test-only override, refused under INVOCATION_ID. Normal/systemd starts keep host-wide exclusion. | M4 (start) → Attaching, Refused | `core/frontend/durable/provider.go` `DurableProvider.lockVolumeOnHost` | `TestOneLiveProcessPerVolumePerHost`, `TestHostVolumeLockDirectoryCreatedOrRefused`, `TestHostVolumeLockRefusesNonDirectoryLockPath`, `TestHostVolumeLockTakesReadOnlyLockFile` (`core/frontend/durable/one_process_per_volume_test.go`); `TestHostVolumeLockCreatesParent0755AndLocks0700`, `TestHostVolumeLockKeepsExistingDirectoryModes` (`core/frontend/durable/volume_lock_parent_mode_test.go`); `TestVolumeLockDirTestOnlyRefusedUnderSystemd`, `TestNormalStartKeepsTheHostVolumeLock` (`cmd/blockvolume/volume_lock_flag_test.go`) | — | ACTIVE |
|
||||
| `INV-CHUNK-LEASE-REQUIRED-001` | Blockvolume refuses walstore-chunk startup without --workspace-lease before any host or store is opened. The refusal names concurrent acknowledging writers and acknowledged-write loss after a forced move; plain walstore startup is unchanged. | M4 startup → Refused | `cmd/blockvolume/main.go` `parseFlags` | `TestChunkVolumeRequiresWorkspaceLeaseBeforeStart` | — | ACTIVE |
|
||||
| `INV-WS-CONDITIONAL-HEAD-001` | Catalog startup requires a wrong-generation conditional update of a disposable HEAD to be definitely refused and leave its bytes and generation unchanged. Unknown probe outcomes refuse admission; cleanup failures only warn with the leftover path. No volume HEAD is used. | M4 startup → Refused | `core/frontend/chunkstore/swfs_catalog.go` `DialBCatalog`; `startup_head_probe.go` `checkConditionalHead` | `TestCatalogStartupRequiresWrongGenerationHeadRefusal`, `TestConditionalHeadNextStartCleansCrashLeftovers`, `TestConditionalHeadSweepWaitsAndLeavesNewProbes`, `TestCatalogStartupDoesNotWaitForUndeletableProbe`, `TestLayoutIdentityWriterAndReaders` | — | ACTIVE |
|
||||
| `INV-WS-CHUNK-CONDITION-PROBE-001` | Catalog startup and sw-block metadata writers turn the chunk guard on only if the filer definitely refuses a mismatched chunk-condition update of a disposable HEAD; any other answer leaves the page re-read as the only check. No version string is read; the startup log and /status/chunk name it. | M4 startup | `core/frontend/chunkstore/startup_head_probe.go` `probeChunkCondition`, `ProbeChunkGuard`; `catalog_b.go` `Store`, `MetadataGuard`, `Usage`; `cmd/sw-block/chunk_b.go` `bCatalog` | `TestTheStartupProbeTurnsTheChunkGuardOnOnlyForAFilerThatEnforcesIt` (`core/frontend/chunkstore/startup_chunk_condition_probe_test.go`), `TestAFailedChunkGuardProbeLeavesTheGuardOff` (`core/frontend/chunkstore/chunk_guard_report_test.go`), `TestCatalogStartupRequiresWrongGenerationHeadRefusal` (`core/frontend/chunkstore/startup_head_probe_test.go`), `TestStatusServer_StatusChunkUsage` (`core/host/volume/status_chunk_test.go`), `TestOpsChunkWritingCatalogRunsTheChunkConditionProbe`, `TestOpsChunkWritingCatalogProbeIsBoundedByTheTimeout` (`cmd/sw-block/chunk_guard_probe_test.go`) | MetaABA r2, checked outside the repository: guard on = `safe_chunks_equal`; the fallback is the re-read, which a chunk still queued for deletion defeats (`mut_reread_delayed`) | ACTIVE |
|
||||
@@ -1304,6 +1304,7 @@ Notes:
|
||||
| `INV-CLI-DELETE-RETRY-001` | Only the final lease barrier after a committed volume-delete reservation permits retryable true/exit 75 at its horizon. A live-holder Reserve refusal requires stopping the volume first (not_admitted, non-retryable, exit 1). No lease guard is bypassed. | M9 delete admission result projection | `cmd/sw-block/chunk_volume_delete.go` `authorityErr`; `cmd/sw-block/chunk.go` `chunkResult` | `TestVolumeDeleteAdmissionRetryAnswer`; `TestOpsChunkVolumeDeleteRefusalSaysNothingWasPersisted` | MoveAdmission.DelRead; MoveAdmission.DelMark (unchanged guards) | STUB |
|
||||
| `INV-SNAPSHOT-REPLAY-FLAG-001` | A successful same-ID snapshot admission reports replayed true without changing HEAD or its retained outcome. First creation reports false; the flag decorates only the response. | M9 snapshot outcome projection | `core/host/volume/snapshot_operation.go`, `chunk_control.go`; `cmd/sw-block/snapshot_operation.go` | `TestSnapshotReplayFlagDoesNotRewriteOutcome`, `TestSnapshotCLIUsesReplayedAdmissionAnswer` | SnapOps.Poll; SnapOps.Start (no transition change) | STUB |
|
||||
| `INV-CLI-UNSENT-REQUEST-001` | An observed operation's initial typed dial failure sends no admission and is remote_unavailable (75) through the shared classifier. A lost answer after send, or a dial failure while polling an admitted handle, retains outcome_unknown. | CLI pre-admission error projection; no server transition | `cmd/sw-block/cut_progress_poll.go` `chunkObserveHandle`; `chunkTransportFailure`, `chunkFail` | `TestPlainDetachRefusedDialIsRemoteUnavailable`, `TestPlainDetachLostAnswerAfterSendStaysUnknown`, `TestPlainDetachPollDialFailureKeepsAdmittedOutcomeUnknown`, `TestOpsChunk_ErrorsAreJSONOnStdout` | CutTime Poll/CliGiveUp boundary; pre-admission transport proof | ACTIVE |
|
||||
| `INV-CLI-MINI-EXECUTABLE-001` | Mini records and launches the executable selected by --weed without changing symlink/.. resolution; fresh and legacy runs use an absolute path. | TrialLauncher path wiring, no protocol transition | `cmd/sw-block/mini.go` `miniExecutablePath`, `mini`, `reuseMiniRecord` | `TestMiniWeedSymlinkParentKeepsSelectedExecutable`, `TestMiniRelativeWeedIsRecordedAndPrintedAbsolutely` (`cmd/sw-block`); `TestMiniCleanupFailStopAndSettlement` (`cmd/blockvolume`: failed-start proof rejects watchdog intervention; settled capture completes and live residue refuses cleanup) | NONE (path selection and test ownership only; fresh Linux qualification pending) | STUB |
|
||||
| `INV-CLI-CATALOG-ERROR-001` | The chunk CLI preserves admission evidence and definite domain/certificate answers. Possibly-sent requests require replay/poll. Incomplete verify never exits 3; non-retryable server answers never exit 75. Absent snapshot delete is snapshot_not_found. | M9 client error projection; M4 census refusal, no transition change | `core/rpc/answer` `Lookup`; `cmd/sw-block/chunk_answer.go` `chunkAnswer`; `cmd/sw-block/chunk.go` `chunkResult`; `cmd/sw-block/catalog_snapshot_operation.go` `catalogSnapshotDeleteRefusal`; `core/frontend/chunkstore/single_filer.go` `CheckSingleFiler`; `core/frontend/chunkstore/layout/delete.go` `RunMarkDeleting` | `TestOpsChunkTransportFailureMatrix`, `TestOpsChunkVerifyUnreachableCensusPreservesTransport`, `TestCheckSingleFilerKeepsTransportCause`, `TestSingleFilerConfigurationErrorDeadlineBetweenReads`, `TestCheckSingleFilerSlowDialOrdering`, `TestDialBCatalogKeepsCustomCallerDeadline`, `TestMasterCensusKeepsCustomCallerDeadline`, `TestCheckSingleFilerValidatesAllMasterAddressesBeforeCensus`; `TestOpsChunkCatalogUnavailableIsTyped`, `TestCatalogTransportClassificationKeepsDefiniteAnswers`, `TestSnapshotDeleteAbsentCLIUsesContractCodeAndKeepsReceipt`; `TestLinkNeverTurnsASentRequestIntoSafeResend`; `TestChunkHTTPPostLostAnswerIsUnknown`; `TestCommandFamilyTransportGrid`; `TestLocalCredentialsFailBeforeDialWithTypedPolicy`; `TestHTTPCancellationBeforeDispatchKeepsOperationPhase`; `TestDeclaredDomainCodesHaveRegistryRows`; `TestOwnedClientTransportsKeepAdmissionEvidence`; `TestPresentationFailsClosedForUnknownContract`; `TestUnsentRPCWithMixedPeerFailuresIsRetryable`; `TestRPCPeerCertificateFailureDoesNotHideHandshakeTimeout`; `TestRPCSucceedsOnGoodPeerAfterBadCertificate`; `TestPeerCertificateProofRequiresEveryFreshCompletedAttempt`; `TestPeerDiagnosticTruncationNeverAuthorizesTerminalClassification`; `TestTypedRemoteUnavailableRespectsRetryable`; `TestNonRetryableServerAnswerNeverInvitesTemporaryRetry`; `TestVerifyStartCheckLostAnswerNeverLooksLikeFindings`; `TestVerifyIncompleteTransportPreservesPartialProgress`; `TestOpsFailoverUsesSharedDefiniteExitProjection`; `TestBlobHTTPAnswerSurvivesLayoutFetch`; `TestPlaintextPrefaceFailureKeepsUnsentRetryAndTLSHint`; `TestHTTPPartialCustomTraceCannotProveUnsentAfterReceivedPOST`; `TestHTTPRegisteredProtocolCannotProveUnsentAfterReceivedPOST`; `TestHTTPOwnedTransportDoesNotInheritRegisteredDefault`; `TestDelayedPeerNotificationCannotRefreshAnOldTLSFailure`; `TestObservedTLSForwardsPerCallAuthorityValidation`; `TestChunkCensusPreflightPreservesOpaqueContextCause`; `TestSingleFilerReviewPreservesDefiniteAndCallerWinner`; `TestReviewContextAndDefiniteAnswerPrecedence`; `TestReviewOldPickerCannotBorrowNewPeerGeneration`; `TestReviewContractProjectionAndReadOnlyRecovery`; `TestReviewAdmittedPollTLSFailureKeepsOperationRecoverable`; `TestReviewPickerCannotReplaceCustomCallerDeadline`; `TestReviewSelectedTLSCannotReplaceCallerCompletion`; `TestReviewHTTPStatusOverridesNestedTransport`; `TestReviewVerifyPreservesServerRetryRefusal`; `TestReviewInitialPostBodyFailurePreservesStatus`; `TestReviewForceMovePreservesServerPolicyExit`; `TestReviewFailoverDomainAnswerRequiresRecovery`; `TestSnapshotOperationCLIInterruptThenResumeUsesPrintedID`; `TestSnapshotOperationCLIInterruptedTLSKeepsUnknownAndHandle`; `TestReviewCompleteBodyKeepsStatusAndAdmission`; `TestReviewInvalidAdmissionKeepsOriginalRequest`; `TestReviewUnsafeSnapshotLocationKeepsOriginalUnknown`; `TestReviewAdmittedMissingResultKeepsUnknown`; `TestCutBusyHasItsOwnLegacyExitClass`; `TestCutCLIBusyIsDistinctAndDoesNotStartAnotherCut` | SnapOps.Poll; CutTime.Poll; CutTime.CliGiveUp (result projection; no new transition) | STUB |
|
||||
| `INV-CLI-CHUNK-LOOP-001` | Above the per-request bound, sw-block ops chunk snapshot\|detach repeats the SAME request (same name and request id) only after a retryable or outcome_unknown answer. Manual cut and plain detach use the separate one-POST/read-only-poll contract. | client (no state machine): the CLI side of M5 requests | `cmd/sw-block/chunk_loop.go` `chunkPostLoop`; `cmd/sw-block/chunk.go` `chunkPostUntil` | `TestChunkSnapshotRepeatsTimedOutRequestsWithTheSameBody`, `TestChunkSnapshotLoopReusesTheGeneratedRequestID`, `TestChunkLoopRepeatsAnOutcomeUnknownNotMarkedRetryable` (`cmd/sw-block`) | — | ACTIVE |
|
||||
| `INV-CLI-CHUNK-LOOP-002` | Above the per-request bound, sw-block ops chunk snapshot\|detach stops at the first definite answer (success or non-retryable refusal). | client (no state machine): the CLI side of M5 cut requests | `cmd/sw-block/chunk_loop.go` `chunkPostLoop` | `TestChunkLoopStopsOnANonRetryableRefusal`, `TestChunkDetachOutcomeUnknownSettles` (`cmd/sw-block`) | — | ACTIVE |
|
||||
|
||||
@@ -236,6 +236,9 @@ retains the earlier isolation guidance.
|
||||
`install`, not `mv`: with SELinux, a file moved from a home directory keeps its home label and systemd may refuse
|
||||
to run it.
|
||||
|
||||
blockvolume's volume locks are always in `/run/sw-block/locks` under the units. Only `sw-block mini`, a one-user
|
||||
trial, keeps them under its own `--dir`; blockvolume refuses that override under systemd.
|
||||
|
||||
Do **not** enable `sw-blockvolume.service`. It is the single-volume example for the `--topology` setup, which cannot
|
||||
serve a walstore-chunk volume. This manual runs each volume as the template unit `sw-blockvolume@<volume>.service`,
|
||||
which `sw-block volume start` creates (section 3). `sw-blockmaster.service` is enabled in section 2.
|
||||
|
||||
@@ -4,7 +4,10 @@ v1.1.1 is released (2026-12-04).
|
||||
|
||||
v1.1.1 is a fix release of the v1.1 line. None of its changes alters a stored format.
|
||||
|
||||
## Known issue: `sw-block mini` as a non-root user
|
||||
## Known issue: `sw-block mini` as a non-root user (fixed in v1.1.2)
|
||||
|
||||
v1.1.2's `mini` keeps the volume lock under `--dir`, needs no `sudo` to start, prints absolute paths, and names the
|
||||
`--reuse` command after a failed start. With v1.1.1:
|
||||
|
||||
- `blockvolume` keeps one lock per volume under `/run/sw-block/locks`, which a non-root user cannot create. On a
|
||||
fresh host `mini` starts `weed` and `blockmaster`, then stops when `blockvolume` cannot take its lock. Create the
|
||||
|
||||
@@ -500,6 +500,9 @@ sw-block mini --dir ./swb-mini # blockmaster and blockvolume next to sw
|
||||
- If you connected v1, unmount it and run `sudo nvme disconnect -n <nqn>` **before** stopping mini. Otherwise a mounted filesystem sits on a stopped target while the kernel retries for 3 minutes. mini prints this with the connect command and again when it stops.
|
||||
- The data stays in `--dir`; `sw-block mini --dir <dir> --reuse` (printed at stop, quoted for the shell) starts it again, with that run's size, ports, mode and NQN (recorded in `<dir>/mini.json`; a flag that differs is refused).
|
||||
- **It is a trial setup:** one host, loopback, no authentication.
|
||||
- **No root:** blockvolume's volume lock is in `<dir>/locks` (`--volume-lock-dir-test-only`, a hidden override that blockvolume refuses under systemd), so mini starts as any user without the tmpfiles.d entry. Every command it prints names sw-block and weed by their absolute paths.
|
||||
- **Snapshots:** mini runs `v1` with `--chunk-snapshot-schedule off` and prints the command that takes one; the units' daily schedule is not part of a trial.
|
||||
- **A failed start** stops what it started and prints the `--reuse` command that starts again on the same `--dir` (or remove the directory and start fresh).
|
||||
- **Refusals:** it refuses a `--dir` that already exists, unless you pass `--reuse` to start again on it, and refuses a port that is already in use. `--port-shift N` moves every port by N, for a host where a default port is taken.
|
||||
- **Size:** `--size` sets v1's size (default `256MiB`). Volumes above the release maximum are refused by blockmaster as usual.
|
||||
|
||||
|
||||
@@ -83,11 +83,11 @@ cmd/sw-block/main.go runOpsGenerateHelmValues context.WithTimeout 1 per-call NON
|
||||
cmd/sw-block/main.go loadObservationVolume context.WithTimeout 1 per-call NONE: no model row maps this file yet one CLI request (operator --timeout)
|
||||
cmd/sw-block/mini.go miniRun.ready time.Now().Add 1 per-call NONE: no model row maps this file yet mini cluster start wait
|
||||
cmd/sw-block/mini.go miniRun.ready time.After 1 control-timer NONE: no model row maps this file yet start-wait poll
|
||||
cmd/sw-block/mini.go miniRun.resolveLayoutID time.Now().Add 1 per-call NONE: no model row maps this file yet mini cluster resolve wait
|
||||
cmd/sw-block/mini.go miniRun.resolveLayoutID context.WithTimeout 1 per-call NONE: no model row maps this file yet one CLI request (operator --timeout)
|
||||
cmd/sw-block/mini.go miniRun.resolveLayoutID time.After 1 control-timer NONE: no model row maps this file yet resolve-wait poll
|
||||
cmd/sw-block/mini.go miniRun.stop time.After 1 per-call NONE: no model row maps this file yet mini cluster stop wait
|
||||
cmd/sw-block/mini.go mini time.Now().Add 1 per-call NONE: no model row maps this file yet mini cluster resolve wait
|
||||
cmd/sw-block/mini.go mini context.WithTimeout 1 per-call NONE: no model row maps this file yet one CLI request (operator --timeout)
|
||||
cmd/sw-block/mini.go mini time.After 1 control-timer NONE: no model row maps this file yet resolve-wait poll
|
||||
cmd/sw-block/mini.go mini time.After 2 control-timer NONE: no model row maps this file yet resolve-wait poll
|
||||
cmd/sw-block/mini.go mini time.After 1 control-timer NONE: no model row maps this file yet trial child-health poll
|
||||
cmd/sw-block/shell.go inspectionShell.execute context.WithTimeout 1 per-call NONE: no model row maps this file yet one CLI request (operator --timeout)
|
||||
cmd/sw-block/shell_check.go inspectionShell.check context.WithTimeout 1 per-call NONE: no model row maps this file yet one CLI request (operator --timeout)
|
||||
cmd/sw-block/snapshot_operation.go chunkObserveSnapshot context.WithTimeout 1 per-call SnapOps.Send one CLI request (operator --timeout)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 50 and column 123.
|
Reference in new issue
Block a user