From: norbert.bizet Date: Fri, 9 Sep 2022 12:56:53 +0000 (-0400) Subject: cloud: Fix #9419 Avoid abort when truncate() fails X-Git-Tag: Beta-15.0.0~515 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f32b0da9d8429070310113400bb756ef1fe40c88;p=thirdparty%2Fbacula.git cloud: Fix #9419 Avoid abort when truncate() fails --- diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index 7c6dfbee2..188dff4d6 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -534,6 +534,9 @@ bail_out: * * Returns: true if OK * false if unable to write it + * N.B. 2022: Function is called in a loop and should avoid FATAL errors as much as possible. + * In order to fix MT9419 (corner case with cloud device), I moved the !truncate(dcr) error handling + * from FATAL to ERROR so the truncated volumes can be effectively set in Error state. */ bool DEVICE::rewrite_volume_label(DCR *dcr, bool recycle) { @@ -572,7 +575,7 @@ bool DEVICE::rewrite_volume_label(DCR *dcr, bool recycle) if (recycle) { Dmsg1(150, "Doing recycle. Vol=%s\n", dcr->VolumeName); if (!truncate(dcr)) { - Jmsg3(jcr, M_FATAL, 0, _("Truncate error on %s device %s: ERR=%s\n"), + Jmsg3(jcr, M_ERROR, 0, _("Truncate error on %s device %s: ERR=%s\n"), print_type(), print_name(), print_errmsg()); Leave(100); return false; diff --git a/regress/tests/cloud-MT9419-wrong-device-volumes-in-error b/regress/tests/cloud-MT9419-wrong-device-volumes-in-error new file mode 100755 index 000000000..0c32bb4c9 --- /dev/null +++ b/regress/tests/cloud-MT9419-wrong-device-volumes-in-error @@ -0,0 +1,103 @@ +#!/bin/sh +# +# Copyright (C) 2000-2021 Kern Sibbald +# Copyright (C) 2021-2022 Bacula Systems SA +# License: BSD 2-Clause; see file LICENSE-FOSS +# +# Cloud transfer test. Exercice the retry-waiting mecanism introduced to support S3 GLACIER restoration +# Will work with all drivers but is mostly design to be run with file_driver. +# +TestName="cloud-MT9419-test" +JobName=NightlySave +. scripts/functions + +require_cloud + +#config is required for cloud cleanup +scripts/copy-test-confs +scripts/cleanup + +FORCE_FILE_SET=${FORCE_FILE_SET:-"${cwd}/build"} +echo "$FORCE_FILE_SET" >${cwd}/tmp/file-list + +start_test +$bperl -e 'add_attribute("$conf/bacula-dir.conf", "LabelFormat", "Vol", "Pool")' +$bperl -e 'add_attribute("$conf/bacula-dir.conf", "MaximumVolumeBytes", "40000000", "Pool")' +$bperl -e 'add_attribute("$conf/bacula-dir.conf", "VolumeRetention", "1s", "Pool")' +$bperl -e 'add_attribute("$conf/bacula-sd.conf", "MaximumUploadBandwidth", "4MB/s", "Cloud")' +$bperl -e 'add_attribute("$conf/bacula-sd.conf", "MaximumDownloadBandwidth", "4MB/s", "Cloud")' +$bperl -e 'add_attribute("$conf/bacula-sd.conf", "MaximumDownloadBandwidth", "4MB/s", "Cloud")' + +AccessKey=$($bperl -e "get_attribute('$conf/bacula-sd.conf', 'Cloud', '$CLOUD_NAME', 'AccessKey')") +$bperl -e 'add_attribute("$conf/bacula-sd.conf", "AccessKey", '"${CLOUD_NAME}_WRONG"',, "Cloud")' + + +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log1.out +run job=$JobName level=Full yes +wait +messages +@$out ${cwd}/tmp/log1_list.out +list media +END_OF_DATA + +echo "Running job 1" +run_bacula +ls -l tmp/Vol* + +# exactly the same but log2 +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log2.out +run job=$JobName level=Full yes +wait +messages +@$out ${cwd}/tmp/log2_list.out +list media +END_OF_DATA + +echo "Running job 2" +run_bconsole +ls -l tmp/Vol* + + +sleep 2 +unset FORCE_CLOUD +stop_bacula + +grep 'Marking Volume "Vol0001" in Error in Catalog.' $tmp/log2.out > /dev/null +if [ $? -ne 0 ]; then + print_debug "ERROR: Vol0001 not set in error" + estat=1 +fi + +grep 'Marking Volume "Vol0002" in Error in Catalog.' $tmp/log2.out > /dev/null +if [ $? -ne 0 ]; then + print_debug "ERROR: Vol0002 not set in error" + estat=2 +fi + +grep 'Marking Volume "Vol0003" in Error in Catalog.' $tmp/log2.out > /dev/null +if [ $? -ne 0 ]; then + print_debug "ERROR: Vol0003 not set in error" + estat=3 +fi + +grep 'Vol0001 | Error' $tmp/log2_list.out > /dev/null +if [ $? -ne 0 ]; then + print_debug "ERROR: Vol0001 not listed in error" + estat=4 +fi + +grep 'Vol0002 | Error' $tmp/log2_list.out > /dev/null +if [ $? -ne 0 ]; then + print_debug "ERROR: Vol0002 not listed in error" + estat=5 +fi + +grep 'Vol0003 | Error' $tmp/log2_list.out > /dev/null +if [ $? -ne 0 ]; then + print_debug "ERROR: Vol0003 not listed in error" + estat=6 +fi + +end_test