Skip to content

fix(performance): pin the headroom rejection message numerically - #1049

Merged
Starosdev merged 3 commits into
developfrom
fix/perf-headroom-test-tmpfs
Oct 29, 2026
Merged

Starosdev merged 3 commits into
developfrom
fix/perf-headroom-test-tmpfs

Conversation

@Starosdev

Copy link
Copy Markdown
Owner

Summary

Pins the spaceRejection message numerically, so the required figure has to be the test file plus the headroom rather than the test file alone.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Related Issues

Follow-up to #1040, which merged at 54fdbf7e while this change was still under review at b107b38c. Related to #1038.

Reason

A review of #1040 found that TestSpaceRejection asserted only Contains "insufficient space", Contains "headroom", and Contains "1024 bytes available". That leaves one mutation alive: change the second argument at collector/pkg/performance/mount_linux.go:69 from neededBytes back to requiredBytes, or the third from uint64(spaceHeadroomBytes) to anything else, and every assertion still passes.

The consequence is the defect the test exists to prevent. An operator reading 1152921504606846976 bytes required when the real requirement is that plus 64 MiB concludes the free space is the whole budget, which is exactly why the message names the headroom separately.

Changes Made

  • collector/pkg/performance/mount_linux_test.go: assert the required figure as requested+headroom and the headroom as plus %d bytes headroom, both computed rather than matched as loose substrings.

No change to mount_linux.go; spaceRejection and its message are untouched.

Testing

  • I have tested this locally
  • I have added/updated tests that prove my fix/feature works
  • All existing tests pass
gofmt -l collector/pkg/performance/                              # clean
GOOS=linux GOARCH=amd64 go vet ./collector/pkg/performance/      # clean
GOOS=linux GOARCH=amd64 go test -c ./collector/pkg/performance/  # compiles

mount_linux_test.go is Linux-only by filename and this host is macOS with no container runtime, so the tests could not be executed locally. CI is the execution check. TestSpaceRejection touches no filesystem, so it runs rather than skipping.

Checklist

  • My code follows the project's code style
  • I have performed a self-review of my code
  • I have commented my code where necessary (particularly complex areas)
  • I have updated the documentation if needed
  • My changes generate no new warnings
  • No console.log, debug statements, or commented-out code

Additional Notes

Review: not required (test-only change; no runtime code, no security or access boundary, trivially revertible).

Known and deliberately out of scope: requiredBytes + spaceHeadroomBytes is uint64 arithmetic with no overflow guard, so a performance.temp_file_size at or near MaxUint64 wraps and spaceRejection returns no rejection for a file the mount point cannot hold. That predates #1040 and the extraction preserved it exactly; it deserves its own change rather than being folded into a test fix.

isMountPointSuitable rejects an unsuitable mount entry at mount_linux.go:37,
before it reaches the free-space branch at mount_linux.go:50. The headroom test
called it with t.TempDir() and asserted the reason contains "insufficient
space", so on a CI runner whose temporary directory is backed by tmpfs the
tmpfs rejection returned first and the assertion failed:

    "filesystem type is tmpfs (device not mounted as a real filesystem)"
    does not contain "insufficient space"

The outcome depended on which runner the job landed on rather than on the code
under test, which made Test Backend fail intermittently on unrelated pull
requests.

Probe the directory at a trivial required size first and skip when it is not a
benchmark target, matching requireBenchmarkableDir in resolve_target_test.go.
The headroom assertion still runs, and still fails, on a runner with a real
filesystem.

Test-only change. The collector's tmpfs rejection is deliberate and unchanged.

Fixes #1038
The headroom test called isMountPointSuitable with t.TempDir() and asserted the
rejection contains "insufficient space". The mount entry checks reject a tmpfs
at mount_linux.go:37, before the space check at mount_linux.go:50, and CI
runners put the temporary directory on tmpfs, so the assertion failed on the
runners that do and passed on the ones that do not.

Skipping on an unsuitable directory stops the failure but leaves nothing
covering the rule: ubuntu-latest has /tmp on tmpfs, so the assertion would not
execute in CI at all, and "insufficient space" and "headroom" appear nowhere
else under collector/.

Extract the rule into spaceRejection(availableBytes, requiredBytes), which
isMountPointSuitable now calls. The behavior is unchanged, including the message
text, and the rule is testable without a filesystem of any particular type, so
TestSpaceRejection runs on every runner. It pins the boundary at exactly enough
and one byte short, and asserts the required figure numerically: the message has
to name the test file plus the headroom, not the test file alone, or it implies
the free space is the whole budget.

The integration test stays as a check that isMountPointSuitable still consults
the rule, and skips only when the directory is rejected for a reason other than
space. An "insufficient space" rejection means the space check ran, so it is no
longer a reason to skip: on a nearly-full real filesystem the probe at one byte
fails against the 64 MiB headroom, and the earlier version skipped there even
though the assertion would have held.

Fixes #1038
…test-tmpfs

# Conflicts:
#	collector/pkg/performance/mount_linux_test.go
@Starosdev
Starosdev merged commit 25af928 into develop Oct 29, 2026
19 of 20 checks passed
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.

1 participant