Repository navigation
Conversation
Guard the transition from actual ready-log output to project readiness, and document when callers can consider the project ready. Refs F1bonacc1#557
|
|
Please merge #562 before this PR, then update this branch from #562 makes liveness probes stop gating project readiness and renames Keep After #562 merges:
|
| {name: "elevated without TUI", proc: types.ProcessConfig{ReadyLogLine: "ready", IsElevated: true}}, | ||
| { | ||
| name: "unscanned output keeps its probe", | ||
| proc: types.ProcessConfig{ReadyLogLine: "ready", LivenessProbe: &health.Probe{}}, |
There was a problem hiding this comment.
About the plan for after #562: switching this to a readiness probe would test a config the loader rejects (readiness_probe together with ready_log_line fails validateNoIncompatibleHealthChecks). Once liveness no longer gates readiness, I think this case should just be removed rather than converted.
|
|
||
| // usesAttachedIO reports whether the process inherits process-compose's own | ||
| // stdin, stdout and stderr instead of having its output piped through it. | ||
| func usesAttachedIO(proc *types.ProcessConfig, isMain, isTuiEnabled bool) bool { |
There was a problem hiding this comment.
Small nit: the helper only covers half of the "do we read the output" rule. !IsInteractive is still checked separately below in getProcessStarter and again in newIncarnationState. Maybe something like:
// scansOutput reports whether process-compose reads the process output,
// and so can see its ready_log_line.
func scansOutput(proc *types.ProcessConfig, isMain, isTuiEnabled bool) bool {
return !proc.IsInteractive && !usesAttachedIO(proc, isMain, isTuiEnabled)
}used in both places, so they really can't drift.
|
Oh, and don't worry about the lint failing. It is already fixed in main. |



project is-readycan exit successfully while a running process has not yet printed itsready_log_line. With this change, a process with aready_log_linecounts as ready only once that line appears, so the project stays not ready until then. The same applies to--detach-on-success.This only applies when Process Compose can see the process's output. Some processes write straight to the terminal, so Process Compose never sees their output and could never find the line. Those processes are listed below and behave as before.
Fixes #557
Implementation
Each time a process starts,
newIncarnationState(src/app/project_runner.go) builds its state. It now setsHasHealthProbewhen both of these are true:ready_log_line, andHasHealthProbeis the flag that readiness and liveness probes already set, so no new check is needed. The existing readiness checks already require a process with this flag to be healthy, and they report a process that is still waiting for its line with the existinghealth is Unknownreason.Process Compose does not read the output of the processes below, so their
ready_log_linedoes not affect readiness:is_interactive)process-compose runis_elevated) when the TUI is disabledis_foreground) started from the TUInewIncarnationStatechecks the first three explicitly. The fourth needs no check: the TUI runs a foreground process itself, sonewIncarnationStateis never called for it.Other notes:
getProcessStarter(src/app/process.go). It is now a small helper,usesAttachedIO. The code that starts a process and the new readiness code both call it, so the two cannot drift apart.src/typesis unchanged.NewProcessStateonly sees the process config. It does not know whether the TUI is on or which processprocess-compose runselected, so it cannot tell whether the output is read.has_ready_probeistruein its state JSON (for example inprocess list --output json).ready_log_linebehave as before.Tests and documentation
TestProjectRunner_newIncarnationStateLogReadinessis a table test. It checks case by case whether aready_log_linemakes a process wait:process-compose run, or for an elevated process when the TUI is off.TestProjectRunner_ForegroundLogReadinesschecks that a foreground process that has not been started yet does not hold the project back.TestSystem_TestReadyLineProjectReadinessstarts a real process that prints its ready line after one second. It waits for the project to become ready, then checks that the process was already healthy at that moment. In other words, the project did not become ready before the line was printed. The test does not assert "not ready" at a fixed earlier time, because that would fail whenever the test happens to run slower than the process.www/docs/launcher.mdgains two notes:ready_log_lineis not ready until the line is printed, withproject is-readyand--detach-on-successas examples. A process that exits without printing the line, or that is stopped, is not ready.Validation
Run on macOS (arm64) with Go 1.26.8, at commit
cfd78b9:make buildpassed.make lintpassed with zero issues. This used golangci-lint 2.11.3, the version pinned in the Makefile.make testracepassed for every package exceptsrc/app, where one test,TestWatch_ExitOnEndSurvivesRestart, was reported by the race detector. This failure is not caused by this PR:The race is between starting and stopping the file watcher (
src/app/project_watch.go), which this PR does not touch.The same test fails the same way, intermittently, on
mainat23b0aca(the commit this branch is based on).With that one test skipped,
src/apppasses with the race detector:go test -race ./src/app -count=1 -skip TestWatch_ExitOnEndSurvivesRestartThe new tests fail without the fix:
newIncarnationStateremoved,TestProjectRunner_newIncarnationStateLogReadinessandTestSystem_TestReadyLineProjectReadinessfail.ready_log_line, whether or not its output is read,TestProjectRunner_newIncarnationStateLogReadinessandTestProjectRunner_ForegroundLogReadinessfail.The reproduction script from project is-ready reports success before ready_log_line is emitted #557, run against the built binary:
project is-readyexits with 1 and reportsapp (health is Unknown).Nix package build
Built from a clean clone of commit
cfd78b9in Docker containers, with Nix 2.35.2 and Go 1.26.1 (the version pinned by the flake). Both targets passed:x86_64-linux(the target the Nix workflow builds)linux/amd64, emulated on an ARM64 hostaarch64-linuxlinux/arm64, nativecheckPhase), install, and fixup phases all passed (exit status 0).src/app. They run without the race detector, so the watcher race described above is not reported here.--option filter-syscalls falseis only there because thex86_64-linuxcontainer runs under emulation. An earlier attempt without it failed before compilation withunable to load seccomp BPF program: Invalid argument. The option turns off Nix's system-call filter for the build sandbox. It does not change what is built or tested.