submit_report.sh, kdump.etc: Add setting to disable log submission

Users may want to not submit logs to Valve servers, either for debug
purposes or just due to their preference. This patch adds a setting
for that, exposed in /etc/default/kdump . Information about this
tuning was added to README as well.

Finally, this commit also improves journal output when we bail-out
without submitting the logs to Valve servers, showing a friendly
message pointing to the locally saved file.

Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
This commit is contained in:
Guilherme G. Piccoli
2022-02-11 16:01:28 -03:00
parent 304c45ed84
commit 1cde924b40
4 changed files with 53 additions and 18 deletions

View File

@ -25,13 +25,13 @@ source=('20-kdump-steamos.conf'
sha256sums=('dbedff54addfb5dce51614c73df04c90fca9f27d0d3a690243259ccbbfcca07c' sha256sums=('dbedff54addfb5dce51614c73df04c90fca9f27d0d3a690243259ccbbfcca07c'
'2514f79a496f76af847e262eadd55a5c2f8d95375cc513efa8cadd4cd98fe1d2' '2514f79a496f76af847e262eadd55a5c2f8d95375cc513efa8cadd4cd98fe1d2'
'd33778b5ba356f96ae2b78998deaeb7059260b8e2aa4253be3f7da4e9877f94c' '4267a2b52ba3016a541d8d6149fc5d4974dd92fb8844439eaa81bd9cde6aa735'
'7956c6cf1ce5c5e9aaf573ceee8c6ac2a0cad7e0cfa8f5b21adaa20f9f3db929' '7956c6cf1ce5c5e9aaf573ceee8c6ac2a0cad7e0cfa8f5b21adaa20f9f3db929'
'06b38bd9f09da5fb22a765b6f1945fc349cc5f9d13cd32c9218b9b60b40a9010' '06b38bd9f09da5fb22a765b6f1945fc349cc5f9d13cd32c9218b9b60b40a9010'
'12a9124b907f208471ba7aaac0f3261cbbd34a168cce3260fa9e7793994beebd' '12a9124b907f208471ba7aaac0f3261cbbd34a168cce3260fa9e7793994beebd'
'26bc2b64af0d468f050c0e0dd9e2053176d56886edad9146bc495797bf2c5810' '26bc2b64af0d468f050c0e0dd9e2053176d56886edad9146bc495797bf2c5810'
'ada82c11a2ceef871dd2b7b6c265390903753c49b13f08f00514bccd58037230' '84723f6448e8b914d110078d71d4c3e114ac5637be53a1a91423728f6bb611d7'
'b1a4a0f77cae137d3f5155a0fcc4b9d1e1b7ffd0089adb06b6bb21e71c751e27' '37620d55624a26d87b2f3018d3e3f2f5ba909fbfcb9da5a28ead318ba0450a36'
'cbb207ecc0f6bacefbeed41f0d4910daac6500ac2345366e1f95f09a7653c65a') 'cbb207ecc0f6bacefbeed41f0d4910daac6500ac2345366e1f95f09a7653c65a')
package() { package() {

View File

@ -57,8 +57,9 @@
# #
# 6. Error and succeeding messages are sent to systemd journal, so running # 6. Error and succeeding messages are sent to systemd journal, so running
# 'journalctl | grep kdump' would hopefully bring some information. Also, # 'journalctl | grep kdump' would hopefully bring some information. Also,
# the ZIP file collected is automatically submitted to Valve servers; see # the ZIP file collected is automatically submitted to Valve servers (unless
# below under DETAILS/LOG SUBMISSION for API details, decisions made, etc. # the feature is disabled by the user); see below under DETAILS/LOG SUBMISSION
# for API details, decisions made, how to disable the feature, etc.
# #
# #
# ############################## DETAILS ################################## # ############################## DETAILS ##################################
@ -127,14 +128,15 @@
# The logs collected and compressed in the ZIP file are kept in the system, # The logs collected and compressed in the ZIP file are kept in the system,
# but they provide valuable data to Valve in order to determine issue in the # but they provide valuable data to Valve in order to determine issue in the
# field, and hopefully fix them, so users are happy. Hence, the kdump-steamos # field, and hopefully fix them, so users are happy. Hence, the kdump-steamos
# is capable now to submit logs to Valve servers, through an API. Below such # is capable to submit logs to Valve servers, through an API. If users wish
# API is described, but first worth to mention some assumptions / decisions # to disable this feature, just set LOG_SUBMISSION=0 in /etc/default/kdump.
# made in the log submission mechanism: # Below such API is described, but first worth to mention some assumptions
# and decisions made in the log submission mechanism:
# #
# * First of all, we attempt to verify network connectivity by pinging the # * First of all, we attempt to verify network connectivity by pinging the
# URL "steampowered.com" - quick pings (2 packets, 0.5s between each one) # URL "steampowered.com" - quick pings (2 packets, 0.5s between each one)
# are attempted, but if after 99 of such pings network is considered not # are attempted, but if after 99 of such pings network is considered not
# not reliable, the log submission is aborted, but the ZIP file is kept # reliable, the log submission is aborted, but the ZIP file is kept
# locally of course. # locally of course.
# #
# * The 'curl' tool is used to submit the requests to Valve servers; for # * The 'curl' tool is used to submit the requests to Valve servers; for

View File

@ -38,6 +38,11 @@ GRUB_AUTOSET=1
# in size. # in size.
USE_PSTORE_RAM=1 USE_PSTORE_RAM=1
# By default, collected logs are submitted automatically to Valve servers.
# Setting LOG_SUBMISSION to '0' will disable this behavior; but notice that
# even with the log submission disabled, the logs are saved locally.
LOG_SUBMISSION=1
# Below some log submission settings, based on Steam config files and Valve # Below some log submission settings, based on Steam config files and Valve
# URLs. These settings *should not* be changed, or else the log sending # URLs. These settings *should not* be changed, or else the log sending
# mechanism will be impaired. # mechanism will be impaired.

View File

@ -11,6 +11,17 @@
# if kdump logs are present. # if kdump logs are present.
# #
# Function to bail-out in case logs can't/shouldn't be sent to Valve servers.
# Arg1: folder / Arg2: full filename
save_locally_and_bail() {
mkdir -p "$1"
mv "$2" "$1"
LOG_FNAME="$(basename "$2")"
logger "kdump-steamos: logs not submitted, only saved locally ($1/${LOG_FNAME})"
exit 0
}
# We do some validation to be sure KDUMP_MNT pointed path is valid... # We do some validation to be sure KDUMP_MNT pointed path is valid...
# That and having a valid /etc/default/kdump are essential conditions. # That and having a valid /etc/default/kdump are essential conditions.
if [ ! -f "/etc/default/kdump" ]; then if [ ! -f "/etc/default/kdump" ]; then
@ -174,10 +185,20 @@ if [ ${LOGS_FOUND} -ne 0 ]; then
############################## ##############################
NOT_SENT_FLD="${KDUMP_MAIN_FOLDER}/not_sent_logs"
SENT_FLD="${KDUMP_MAIN_FOLDER}/sent_logs"
# The POST request requires a valid Steam ID. # The POST request requires a valid Steam ID.
if [ "${STEAM_ID}" -eq 0 ]; then if [ "${STEAM_ID}" -eq 0 ]; then
logger "kdump-steamos: invalid Steam ID, cannot submit logs" logger "kdump-steamos: invalid Steam ID, cannot submit logs"
exit 0 LOG_SUBMISSION=0 # force to enter next conditional
fi
# If users don't want to submit the logs (or Steam ID is invalid),
# just save them locally and bail out.
if [ "${LOG_SUBMISSION}" -eq 0 ]; then
rm -rf "${KDUMP_LOGS_FOLDER}"
save_locally_and_bail "${NOT_SENT_FLD}" "${LOG_FNAME}"
fi fi
# Construct the POST request fields... # Construct the POST request fields...
@ -213,7 +234,7 @@ if [ ${LOGS_FOUND} -ne 0 ]; then
# Bail out in case we have network issues # Bail out in case we have network issues
if [ ${LOOP_CNT} -ge ${MAX_LOOP} ]; then if [ ${LOOP_CNT} -ge ${MAX_LOOP} ]; then
logger "kdump-steamos: network issue - cannot send logs" logger "kdump-steamos: network issue - cannot send logs"
exit 0 save_locally_and_bail "${NOT_SENT_FLD}" "${LOG_FNAME}"
fi fi
CURL_ERR="${KDUMP_MAIN_FOLDER}/.curl_err" CURL_ERR="${KDUMP_MAIN_FOLDER}/.curl_err"
@ -224,7 +245,8 @@ if [ ${LOGS_FOUND} -ne 0 ]; then
if ! curl -X POST -d "${POST_REQ}" "${START_URL}" 1>"${RESPONSE_FILE}" 2>"${CURL_ERR}"; then if ! curl -X POST -d "${POST_REQ}" "${START_URL}" 1>"${RESPONSE_FILE}" 2>"${CURL_ERR}"; then
logger "kdump-steamos: curl issues - failed in the log submission POST (err=$?)" logger "kdump-steamos: curl issues - failed in the log submission POST (err=$?)"
#rm -f "${RESPONSE_FILE}" # keep this for now, as debug information #rm -f "${RESPONSE_FILE}" # keep this for now, as debug information
exit 0
save_locally_and_bail "${NOT_SENT_FLD}" "${LOG_FNAME}"
fi fi
RESPONSE_PUT_URL="$(jq -r '.response.url' "${RESPONSE_FILE}")" RESPONSE_PUT_URL="$(jq -r '.response.url' "${RESPONSE_FILE}")"
@ -238,7 +260,8 @@ if [ ${LOGS_FOUND} -ne 0 ]; then
if [ "${PUT_HEADERS_LEN}" -le 0 ] || [ "${PUT_HEADERS_LEN}" -gt 20 ]; then if [ "${PUT_HEADERS_LEN}" -le 0 ] || [ "${PUT_HEADERS_LEN}" -gt 20 ]; then
logger "kdump-steamos: unsupported number of response headers (${PUT_HEADERS_LEN}), aborting..." logger "kdump-steamos: unsupported number of response headers (${PUT_HEADERS_LEN}), aborting..."
#rm -f "${RESPONSE_FILE}" # keep this for now, as debug information #rm -f "${RESPONSE_FILE}" # keep this for now, as debug information
exit 0
save_locally_and_bail "${NOT_SENT_FLD}" "${LOG_FNAME}"
fi fi
LOOP_CNT=0 LOOP_CNT=0
@ -254,23 +277,28 @@ if [ ${LOGS_FOUND} -ne 0 ]; then
if ! curl -X PUT --data-binary "@${LOG_FNAME}" -H "@${CURL_PUT_HEADERS}" "${RESPONSE_PUT_URL}" 1>/dev/null 2>"${CURL_ERR}"; then if ! curl -X PUT --data-binary "@${LOG_FNAME}" -H "@${CURL_PUT_HEADERS}" "${RESPONSE_PUT_URL}" 1>/dev/null 2>"${CURL_ERR}"; then
logger "kdump-steamos: curl issues - failed in the log submission PUT (err=$?)" logger "kdump-steamos: curl issues - failed in the log submission PUT (err=$?)"
#rm -f "${CURL_PUT_HEADERS}" # keep this for now, as debug information #rm -f "${CURL_PUT_HEADERS}" # keep this for now, as debug information
exit 0
save_locally_and_bail "${NOT_SENT_FLD}" "${LOG_FNAME}"
fi fi
rm -f "${CURL_PUT_HEADERS}"
if ! curl -X POST -d "gid=${RESPONSE_GID}" "${FINISH_URL}" 1>/dev/null 2>"${CURL_ERR}"; then if ! curl -X POST -d "gid=${RESPONSE_GID}" "${FINISH_URL}" 1>/dev/null 2>"${CURL_ERR}"; then
logger "kdump-steamos: curl issues - failed in the log finish POST (err=$?)" logger "kdump-steamos: curl issues - failed in the log finish POST (err=$?)"
exit 0 #rm -f "${CURL_PUT_HEADERS}" # keep this for now, as debug information
save_locally_and_bail "${NOT_SENT_FLD}" "${LOG_FNAME}"
fi fi
# If we reached this point, the zipped log should have been submitted # If we reached this point, the zipped log should have been submitted
# succesfully; save a local copy as well. # succesfully; save a local copy as well.
# TODO: implement a clean-up routine to just keep up to N logs... # TODO: implement a clean-up routine to just keep up to N logs...
rm -f "${CURL_PUT_HEADERS}"
rm -f "${CURL_ERR}" rm -f "${CURL_ERR}"
SENT_FLD="${KDUMP_MAIN_FOLDER}/sent_logs/"
mkdir -p "${SENT_FLD}" mkdir -p "${SENT_FLD}"
logger "kdump-steamos: successfully submitted crash logs to Valve"
mv "${LOG_FNAME}" "${SENT_FLD}" mv "${LOG_FNAME}" "${SENT_FLD}"
logger "kdump-steamos: successfully submitted crash log to Valve" LOG_FNAME="$(basename "${LOG_FNAME}")"
logger "kdump-steamos: logs also saved locally (${SENT_FLD}/${LOG_FNAME})"
fi fi