Skip to content

test(deploy/local): run the launcher through the system shell instead of a written script - #99

Open
mrgoonie wants to merge 1 commit into
mainfrom
fix/98-launcher-etxtbsy
Open

mrgoonie wants to merge 1 commit into
mainfrom
fix/98-launcher-etxtbsy

Conversation

@mrgoonie

Copy link
Copy Markdown
Contributor

What and why

Closes #98. TestARestartedBackendStopsAProcessItsLauncherExecedInto flaked once in CI with "text file busy" when executing its launcher. The test wrote a launcher script and executed it right away. A concurrent fork in the same test process could still hold the inherited write descriptor (the classic Linux ETXTBSY race). The launcher is now the system shell (/bin/sh -c 'exec /bin/sleep 300', through the package's existing shell() helper), so no file is written and then executed. The test also polls ps until the launcher has become /bin/sleep before it restarts the backend, instead of sleeping a fixed 200 ms. The exec path is therefore proven rather than assumed.

The property under test is unchanged: identity is the process start time, which execve does not change, while the command line changes from the shell to /bin/sleep 300.

How it was tested

  • go test ./adapters/deploy/local/ -race -count=20: ok (116 s), which is the issue's DoD.
  • make check (build, e2e/smoke vet, golangci-lint run 0 issues, go test ./... -race): rc=0 on head 2bb55480, Linux.
  • Layer: unit (test-only change).

Checklist

  • make check passes locally (what CI runs: build, gofmt, the e2e and smoke suites vetted, lint, go test ./... -race).
  • Tests come with the change; a security or spending rule has a negative test.
  • If an action changed: make generate was run and api/ is committed. (n/a)
  • If the decision brief changed: both languages changed in this PR. (n/a)
  • If an ADR was added: TestADRSetIsComplete was updated. (n/a)
  • If a SISF-01 to SISF-20 scenario gained a test: the acceptance matrix row names it. (n/a)
  • pkg/ changes are additive. (no pkg/ change)
  • No new dependency without an ADR (ADR 0020).
  • Docs describe only what code and a passing test prove. (no docs change)
  • Conventional commit messages, each signed off (git commit -s).
  • No secrets, tokens or personal data.

Governance

  • Changes dependencies, lockfiles, base images or CI configuration.
  • Changes the supervisor, signing keys, policy enforcement, the QA baseline or rollback rules.
  • Widens permissions, egress, budget or scope.
  • Ran make e2e (needs Docker); say where it ran.

Quyết định của routine

  • Vấn đề: cách sửa race ETXTBSY. Các phương án: (a) ghi file tạm rồi rename trước khi exec; (b) retry khi gặp ETXTBSY trong helper test; (c) không ghi file thực thi nữa mà dùng /bin/sh -c. Chọn (c). Rename giữ nguyên inode nên không loại bỏ được descriptor bị kế thừa. Retry chỉ che race đi. Còn (c) xoá hẳn nguyên nhân và vẫn chứng minh đúng hành vi của test.
  • Theo góp ý của reviewer subagent (không có blocker), PR dùng lại helper shell() có sẵn và thay sleep cố định 200 ms bằng vòng chờ đến khi exec xảy ra.
  • Không tự merge: AGENTS.md của repo quy định "Never push to main. Branch, open a PR; the Owner merges". Quy định của repo được ưu tiên hơn quy tắc tự merge của routine.
  • Ghi chú ngoài phạm vi: tests/smoke và cmd/supervisor/local_programs_test.go cũng ghi script 0o700 rồi chạy. Nếu chúng chạy song song thì có thể gặp cùng race này, nên tách thành issue riêng nếu tái diễn.

Generated by Claude Code

… of a written script

Executing a script the test had just written could fail with "text file
busy" when a concurrent fork in the test process inherited the write
descriptor. The launcher is now /bin/sh -c 'exec /bin/sleep 300', and the
test waits until the launcher has become the program instead of sleeping
a fixed 200 ms.

Closes #98

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A1xMi7WMQKm61tTfRrDhon
Signed-off-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(deploy/local): TestARestartedBackendStopsAProcessItsLauncherExecedInto fails intermittently with "text file busy"

2 participants