Skip to content

Report why a server call failed everywhere, not just at task completion - #163

Merged
mastacontrola merged 1 commit into
masterfrom
curl-reporting-sweep
Aug 26, 2026
Merged

Report why a server call failed everywhere, not just at task completion#163
mastacontrola merged 1 commit into
masterfrom
curl-reporting-sweep

Conversation

@mastacontrola

Copy link
Copy Markdown
Member

Follow-on to #162, which fixed the blank * Error returned: at task completion. Every other script that talks to the FOG server still read res=$(curl -Lks --data ...), which collapses a connect failure, an HTTP error, an empty 2xx and a real answer into one empty string — so the same silence #162 fixed at completion was still there at check-in, registration, inventory, capone and the multicast capability probe.

What changed

postToServer is generalized to callServer <url> [data] — GET when no data is given, POST when there is, because it is the same exchange either way. It returns:

rc meaning
0 a body came back
1 the call failed (transport, or HTTP >= 400)
2 answered 2xx with an empty body

Three outcomes rather than two, because a few endpoints answer empty on purpose and a caller has to be able to tell that from a dead server — which is exactly what fog.man.reg's location and OU prompts need.

23 call sites across 12 scripts converted.

Bugs found on the way

  • fog.inventory printed Done after giving up. All eleven attempts could fail and the operator was told it worked.
  • fog.capone reported Count not find (sic) and blamed the image for what may have been a transport failure.
  • restoreLVMPartition's capability probe told the operator their server was too old to multicast LVM when the probe had never reached it — a claim about the server's version drawn from a dead network. Same shape as fogproject#1266.
  • fog.man.reg's locationcheck/oucheck skipped their prompts silently on a failed GET, so a host registered into no location with nothing on screen to say so.
  • fog.checkin and fog.man.reg looped without reporting anything at all.

Regression fixed from #162

res=$(curl ...) strips trailing newlines; the helper did not. A server whose reply ended in a newline yielded ##\n, every == "##" comparison failed, and a capture that had succeeded retried eleven times and then gave up. Case 5b pins it — and had to be written twice: the first cut read the body through head -1, which cannot see a trailing newline, and stayed green with the fix removed.

Left on raw curl deliberately

Each with its reason in a comment at the call site: fog.statusreporter (a 3s ping would paint over imaging output), fog.av (fire-and-forget), reportToServer (its contract is silence — pinned by tests/checks/error-report.sh), the secureboot-funcs.sh and bin/fog -o downloads, and S40network's connectivity probe.

Tests

tests/checks/server-post-reporting.sh → 15 assertions, adding the GET/POST split, the three return codes, and two whole-overlay sweeps: no call site may wrap callServer in $( ) (the subshell discards every variable it set — the bug this file exists to prevent), and raw curl may read a reply only in the exceptions listed above.

tests/checks/lvm.sh → case 30 for an unreachable capability probe, and its curl stub now emits the -w status line it always implied.

Every new assertion was mutation-verified red before being kept:

mutation goes red
always send --data 9. GET path
empty body returns 1 not 2 3, 10
wrap a call site in $( ) 11a
revert a site to raw curl 11b
revert the caps gate to $( ) lvm 30 (5 assertions)

Full suite: 15 check scripts pass, golden output byte-identical.

fos#162 gave fog.imgcomplete and fog.nonimgcomplete a helper that tells a
transport failure, an HTTP error, an empty 2xx and a real answer apart. Every
other script that talks to the server still read `res=$(curl -Lks --data ...)`,
which collapses all four into one empty string -- so the same blank failure
fos#162 fixed at completion was still there at check-in, registration,
inventory, capone and the multicast capability probe.

postToServer is generalized to callServer <url> [data]: GET when no data is
given, POST when there is, since it is the same exchange either way. It returns
0 with a body, 1 when the call failed, and 2 when the server answered 2xx with
nothing -- three outcomes rather than two, because a few endpoints answer empty
on purpose and a caller must be able to tell that from a dead server. That is
what fog.man.reg's location and OU prompts need.

23 call sites across 12 scripts are converted. Genuine bugs found on the way:

  fog.inventory printed "Done" after giving up on all eleven attempts.
  fog.capone reported "Count not find" and blamed the image for what could be a
    transport failure.
  restoreLVMPartition's multicast capability probe told the operator their
    server was too old to multicast LVM when the probe had never reached it --
    a claim about the server's VERSION drawn from a dead network.
  fog.man.reg's locationcheck/oucheck skipped their prompts silently when the
    GET failed, so a host registered into no location with no sign anything
    had gone wrong.
  fog.checkin and fog.man.reg looped without reporting anything at all.

Also fixes a regression shipped in fos#162: `res=$(curl ...)` strips trailing
newlines and the helper did not, so a server whose reply ended in a newline
yielded "##\n", every `== "##"` comparison failed, and a capture that had
SUCCEEDED retried eleven times and gave up. Test 5b pins it -- and had to be
written twice, because the first cut read the body through `head -1`, which
cannot see a trailing newline and stayed green with the fix removed.

Left on raw curl deliberately, each with its reason at the call site:
fog.statusreporter (a 3s ping would paint over imaging output),
fog.av (fire-and-forget), reportToServer (its contract is silence, pinned by
tests/checks/error-report.sh), the secureboot-funcs.sh and bin/fog `-o`
downloads, and S40network's connectivity probe.

tests/checks/server-post-reporting.sh grows to 15 assertions: the GET/POST
split, the three return codes, and two whole-file sweeps -- no call site
anywhere in the overlay may wrap callServer in $( ), and raw curl may read a
reply only in the exceptions named above. tests/checks/lvm.sh gains case 30 for
the capability probe, and its curl stub now emits the -w status line it always
implied. Every new assertion was mutation-verified red before being kept.

Co-Authored-By: Claude <noreply@anthropic.com>
@mastacontrola
mastacontrola merged commit 0f99656 into master Aug 26, 2026
1 check passed
@mastacontrola
mastacontrola deleted the curl-reporting-sweep branch August 26, 2026 17:36
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