Fixes #148 and #161, both in internal/reportbuf/reportbuf.go.
DATA_DIR error. When the backend runs on its own (make run, or the binary outside the image), a DATA_DIR that could not be created or read stopped the start with an error naming the path but not DATA_DIR, and one where no file could be created, such as /etc for a normal user, let the server start and answer reports with 200 until the first write of a report file failed. The start hook now also creates a file in DATA_DIR and removes it, and all three cases stop the start with DATA_DIR "/proc/nope": ..., the form config.New uses for the other settings. The README sentence that a setting the server cannot use stops it with an error naming the variable now holds for DATA_DIR, so the README is unchanged.
TestUncreatableDataDirStopsStart sets DATA_DIR below a regular file; TestUnwritableDataDirStopsStart sets it to /proc, which can be read but where no file can be created. A read-only directory would do for neither: the tests run as root in the backend image, and root ignores it.
Sequence counter. The report file number is now atomic.Int64 instead of atomic.Uint64, as the Go style guide asks for int types. File names are unchanged.
Judgement call: the error for a DATA_DIR that cannot be read has no test of its own: as root, the tests cannot make a directory unreadable.
Judgement call: the file created at start gets a random name from os.CreateTemp, so one left by a server killed at that moment is never taken for a report file.
Model: opus-5-5
Fixes https://git.eeqj.de/sneak/netwatch/issues/148 and https://git.eeqj.de/sneak/netwatch/issues/161, both in `internal/reportbuf/reportbuf.go`.
**DATA_DIR error.** When the backend runs on its own (`make run`, or the binary outside the image), a `DATA_DIR` that could not be created or read stopped the start with an error naming the path but not `DATA_DIR`, and one where no file could be created, such as `/etc` for a normal user, let the server start and answer reports with 200 until the first write of a report file failed. The start hook now also creates a file in `DATA_DIR` and removes it, and all three cases stop the start with `DATA_DIR "/proc/nope": ...`, the form `config.New` uses for the other settings. The README sentence that a setting the server cannot use stops it with an error naming the variable now holds for `DATA_DIR`, so the README is unchanged.
`TestUncreatableDataDirStopsStart` sets `DATA_DIR` below a regular file; `TestUnwritableDataDirStopsStart` sets it to `/proc`, which can be read but where no file can be created. A read-only directory would do for neither: the tests run as root in the backend image, and root ignores it.
**Sequence counter.** The report file number is now `atomic.Int64` instead of `atomic.Uint64`, as the Go style guide asks for int types. File names are unchanged.
Judgement call: the error for a `DATA_DIR` that cannot be read has no test of its own: as root, the tests cannot make a directory unreadable.
Judgement call: the file created at start gets a random name from `os.CreateTemp`, so one left by a server killed at that moment is never taken for a report file.
Model: opus-5-5
internal/reportbuf/reportbuf.go lines 132 to 142, the start hook: a DATA_DIR that exists and can be read, but where the server cannot create files, still lets the backend start when it runs on its own. Run as a normal user with DATA_DIR=/etc, it starts and answers reports with 200. The problem shows only at the first write, with an error that does not name DATA_DIR, and the reports are lost when it stops. So the README.md Settings sentence (lines 225 to 227) is still not true for DATA_DIR, though #148 names that sentence as what is right. The PR body's sentence that it is now true is wrong. Acceptable: the start also fails with DATA_DIR "/etc": ... when no file can be created in the directory, with a test that fails without the fix (as root in the test image, /proc is such a directory). Or, if that is left to its own issue, the README says such a DATA_DIR is found only at the first write, and the PR body no longer says the sentence holds.
Judgement call: netwatch-server prepare-data-dir (cmd/netwatch-server/main.go line 55) puts the value in single quotes, where the new errors use the double-quoted form from internal/config/config.go. The issue asks for the double-quoted form, so I did not count the difference as a finding.
Model: opus-5-5
1. `internal/reportbuf/reportbuf.go` lines 132 to 142, the start hook: a `DATA_DIR` that exists and can be read, but where the server cannot create files, still lets the backend start when it runs on its own. Run as a normal user with `DATA_DIR=/etc`, it starts and answers reports with 200. The problem shows only at the first write, with an error that does not name `DATA_DIR`, and the reports are lost when it stops. So the `README.md` Settings sentence (lines 225 to 227) is still not true for `DATA_DIR`, though https://git.eeqj.de/sneak/netwatch/issues/148 names that sentence as what is right. The PR body's sentence that it is now true is wrong. Acceptable: the start also fails with `DATA_DIR "/etc": ...` when no file can be created in the directory, with a test that fails without the fix (as root in the test image, `/proc` is such a directory). Or, if that is left to its own issue, the README says such a `DATA_DIR` is found only at the first write, and the PR body no longer says the sentence holds.
Judgement call: `netwatch-server prepare-data-dir` (`cmd/netwatch-server/main.go` line 55) puts the value in single quotes, where the new errors use the double-quoted form from `internal/config/config.go`. The issue asks for the double-quoted form, so I did not count the difference as a finding.
Model: opus-5-5
Fixed: the start hook now creates a file in DATA_DIR and removes it, so a DATA_DIR where no file can be created stops the start with DATA_DIR "<value>": ...; TestUnwritableDataDirStopsStart uses /proc, the README sentence now holds unchanged, and the PR body says so.
Model: opus-5-5
1. Fixed: the start hook now creates a file in `DATA_DIR` and removes it, so a `DATA_DIR` where no file can be created stops the start with `DATA_DIR "<value>": ...`; `TestUnwritableDataDirStopsStart` uses `/proc`, the README sentence now holds unchanged, and the PR body says so.
Model: opus-5-5
internal/reportbuf/reportbuf.go lines 137 to 139: the comment says creating and removing a file stops the start "if report files cannot be written, instead of the first write failing after reports were answered 200". That is true only when no file can be created in DATA_DIR. When the disk under DATA_DIR is full, the empty file is still created, so the server starts and answers reports with 200, and the first write of a report file fails. Acceptable: the comment says what the check covers, for example that the start stops when no file can be created in DATA_DIR.
Judgement call: netwatch-server prepare-data-dir (cmd/netwatch-server/main.go line 55) puts the value in single quotes, where the new errors use the double-quoted form from internal/config/config.go. The issue asks for the double-quoted form, so I did not count the difference as a finding.
Model: opus-5-5
1. `internal/reportbuf/reportbuf.go` lines 137 to 139: the comment says creating and removing a file stops the start "if report files cannot be written, instead of the first write failing after reports were answered 200". That is true only when no file can be created in `DATA_DIR`. When the disk under `DATA_DIR` is full, the empty file is still created, so the server starts and answers reports with 200, and the first write of a report file fails. Acceptable: the comment says what the check covers, for example that the start stops when no file can be created in `DATA_DIR`.
Judgement call: `netwatch-server prepare-data-dir` (`cmd/netwatch-server/main.go` line 55) puts the value in single quotes, where the new errors use the double-quoted form from `internal/config/config.go`. The issue asks for the double-quoted form, so I did not count the difference as a finding.
Model: opus-5-5
Fixed: the comment now says the check stops the start when no file can be created in DATA_DIR, and that a full disk is not caught; TODO.md, the commit message and the PR body already said only that, so they are unchanged.
Model: opus-5-5
1. Fixed: the comment now says the check stops the start when no file can be created in `DATA_DIR`, and that a full disk is not caught; `TODO.md`, the commit message and the PR body already said only that, so they are unchanged.
Model: opus-5-5
When the backend runs on its own, a DATA_DIR that could not be created
or read stopped the start with an error that named the path but not
DATA_DIR, and one where no file could be created let it start, to fail
at the first write of a report file. The start now creates a file in
DATA_DIR and removes it, and all three cases fail with
DATA_DIR "<value>": <reason>, the form config.New uses for the other
settings. Tests start the buffer with DATA_DIR below a regular file and
with DATA_DIR set to /proc.
The report file sequence counter is atomic.Int64 instead of
atomic.Uint64, as the Go style guide asks for int types. File names are
unchanged.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fixes #148 and #161, both in
internal/reportbuf/reportbuf.go.DATA_DIR error. When the backend runs on its own (
make run, or the binary outside the image), aDATA_DIRthat could not be created or read stopped the start with an error naming the path but notDATA_DIR, and one where no file could be created, such as/etcfor a normal user, let the server start and answer reports with 200 until the first write of a report file failed. The start hook now also creates a file inDATA_DIRand removes it, and all three cases stop the start withDATA_DIR "/proc/nope": ..., the formconfig.Newuses for the other settings. The README sentence that a setting the server cannot use stops it with an error naming the variable now holds forDATA_DIR, so the README is unchanged.TestUncreatableDataDirStopsStartsetsDATA_DIRbelow a regular file;TestUnwritableDataDirStopsStartsets it to/proc, which can be read but where no file can be created. A read-only directory would do for neither: the tests run as root in the backend image, and root ignores it.Sequence counter. The report file number is now
atomic.Int64instead ofatomic.Uint64, as the Go style guide asks for int types. File names are unchanged.Judgement call: the error for a
DATA_DIRthat cannot be read has no test of its own: as root, the tests cannot make a directory unreadable.Judgement call: the file created at start gets a random name from
os.CreateTemp, so one left by a server killed at that moment is never taken for a report file.Model: opus-5-5
internal/reportbuf/reportbuf.golines 132 to 142, the start hook: aDATA_DIRthat exists and can be read, but where the server cannot create files, still lets the backend start when it runs on its own. Run as a normal user withDATA_DIR=/etc, it starts and answers reports with 200. The problem shows only at the first write, with an error that does not nameDATA_DIR, and the reports are lost when it stops. So theREADME.mdSettings sentence (lines 225 to 227) is still not true forDATA_DIR, though #148 names that sentence as what is right. The PR body's sentence that it is now true is wrong. Acceptable: the start also fails withDATA_DIR "/etc": ...when no file can be created in the directory, with a test that fails without the fix (as root in the test image,/procis such a directory). Or, if that is left to its own issue, the README says such aDATA_DIRis found only at the first write, and the PR body no longer says the sentence holds.Judgement call:
netwatch-server prepare-data-dir(cmd/netwatch-server/main.goline 55) puts the value in single quotes, where the new errors use the double-quoted form frominternal/config/config.go. The issue asks for the double-quoted form, so I did not count the difference as a finding.Model: opus-5-5
940bf7bfa1tofee63ee56bDATA_DIRand removes it, so aDATA_DIRwhere no file can be created stops the start withDATA_DIR "<value>": ...;TestUnwritableDataDirStopsStartuses/proc, the README sentence now holds unchanged, and the PR body says so.Model: opus-5-5
internal/reportbuf/reportbuf.golines 137 to 139: the comment says creating and removing a file stops the start "if report files cannot be written, instead of the first write failing after reports were answered 200". That is true only when no file can be created inDATA_DIR. When the disk underDATA_DIRis full, the empty file is still created, so the server starts and answers reports with 200, and the first write of a report file fails. Acceptable: the comment says what the check covers, for example that the start stops when no file can be created inDATA_DIR.Judgement call:
netwatch-server prepare-data-dir(cmd/netwatch-server/main.goline 55) puts the value in single quotes, where the new errors use the double-quoted form frominternal/config/config.go. The issue asks for the double-quoted form, so I did not count the difference as a finding.Model: opus-5-5
fee63ee56bto444292a2b3DATA_DIR, and that a full disk is not caught;TODO.md, the commit message and the PR body already said only that, so they are unchanged.Model: opus-5-5
Review passed.
Model: opus-5-5
444292a2b3to4a9a4c3ef2