Skip to content

Commit fee6cff

Browse files
committed
fix(subscription): log send failures to the journal
1 parent fc53470 commit fee6cff

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

core/imageroot/var/lib/nethserver/cluster/bin/send-cluster-backup

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ elif [[ -f "${encrypted_file}" ]]; then
5959
fi
6060
curl \
6161
--silent \
62+
--show-error \
6263
--location-trusted \
6364
--fail-with-body \
6465
--max-time 900 \

core/imageroot/var/lib/nethserver/cluster/bin/send-heartbeat

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,14 @@ function send_heartbeat_nsent ()
3838
return 0
3939
fi
4040

41-
curl -m 30 --retry 3 -L -s -X POST \
41+
# Surface failures (DNS, TLS, timeouts, HTTP errors) in the journal
42+
# instead of swallowing them; the || keeps set -e and the loop alive.
43+
local err
44+
err=$(curl -m 30 --retry 3 -L -sSf -X POST \
4245
--user "${system_id:?}:${auth_token:?}" \
43-
"${collect_url}/heartbeat" >/dev/null || :
46+
-o /dev/null -w 'HTTP %{http_code}' \
47+
"${collect_url}/heartbeat" 2>&1) || \
48+
echo "<4>[WARNING] heartbeat send failed: ${err}" 1>&2
4449
}
4550

4651
function send_heartbeat_nscom ()

core/imageroot/var/lib/nethserver/cluster/bin/send-inventory

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,17 @@ function send_inventory_nsent ()
3636
return 0
3737
fi
3838

39-
print-phonehome | \
40-
curl -m 180 --retry 3 -L -s -X POST \
39+
# Surface failures (DNS, TLS, timeouts, HTTP errors) in the journal
40+
# instead of swallowing them; the || keeps set -e satisfied.
41+
local err
42+
err=$(print-phonehome | \
43+
curl -m 180 --retry 3 -L -sSf -X POST \
4144
--user "${system_id:?}:${auth_token:?}" \
4245
-H "Content-Type: application/json" \
4346
--data-binary @- \
44-
"${collect_url}/inventory" >/dev/null || :
47+
-o /dev/null -w 'HTTP %{http_code}' \
48+
"${collect_url}/inventory" 2>&1) || \
49+
echo "<4>[WARNING] inventory send failed: ${err}" 1>&2
4550
}
4651

4752
function send_inventory_nscom ()

0 commit comments

Comments
 (0)