Skip to content

Commit

Permalink
Merge pull request #1296
Browse files Browse the repository at this point in the history
backup.cc: fail backup when `Write Bootstrap` to pipe fails
  • Loading branch information
pstorz committed Oct 31, 2022
2 parents 5a5e015 + 6219d60 commit 73c9573
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
- stored: systemtests: docs: checkpoints improvements [PR #1277]
- winbareos.nsi: fix working directory in configure.sed [PR #1288]
- core: BareosDb::FindLastJobStartTimeForJobAndClient: take into account Running job [PR #1265] [BUG #1466]
- backup.cc: fail backup when `Write Bootstrap` to pipe fails [PR #1296]

### Changed
- contrib: rename Python modules to satisfy PEP8 [PR #768]
Expand Down
10 changes: 9 additions & 1 deletion core/src/dird/backup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,15 @@ void UpdateBootstrapFile(JobControlRecord* jcr)
}
if (VolParams) { free(VolParams); }
if (got_pipe) {
CloseBpipe(bpipe);
int status = CloseBpipe(bpipe);
if (status) {
BErrNo err;
Jmsg(jcr, M_ERROR, 0,
_("Error running program when updating bootstrap file: "
"%s: ERR=%s\n"),
fname, err.bstrerror(status));
jcr->setJobStatus(JS_ErrorTerminated);
}
} else {
fclose(fd);
}
Expand Down
4 changes: 0 additions & 4 deletions core/src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,6 @@ bareos_add_test(

bareos_add_test(thread_list LINK_LIBRARIES bareos GTest::gtest_main)

set_tests_properties(
gtest:thread_list.thread_list_startup_and_shutdown PROPERTIES LABELS broken
)

bareos_add_test(
thread_specific_data LINK_LIBRARIES bareos Threads::Threads GTest::gtest_main
)
Expand Down
11 changes: 5 additions & 6 deletions core/src/tests/thread_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,15 @@ static void* ShutdownCallback(void* data)
return nullptr;
}

static constexpr int maximum_allowed_thread_count = 10;
static constexpr int try_to_start_thread_count = 11;
static constexpr int maximum_thread_count = 10;

TEST(thread_list, thread_list_startup_and_shutdown)
{
std::unique_ptr<ThreadList> t(std::make_unique<ThreadList>());

t->Init(ThreadHandler, ShutdownCallback);

for (int i = 0; i < try_to_start_thread_count; i++) {
for (int i = 0; i < maximum_thread_count; i++) {
auto wc(std::make_unique<WaitCondition>());
if (t->CreateAndAddNewThread(nullptr, wc.get())) {
list_of_wait_conditions.push_back(std::move(wc));
Expand All @@ -110,7 +109,7 @@ TEST(thread_list, thread_list_startup_and_shutdown)
EXPECT_EQ(c.get()->GetStatus(), WaitCondition::Status::kSuccess);
}

EXPECT_EQ(thread_counter, maximum_allowed_thread_count);
EXPECT_EQ(thread_counter, maximum_thread_count);
}

static void* ThreadHandlerSleepRandomTime(ConfigurationParser*, void* data)
Expand All @@ -131,13 +130,13 @@ TEST(thread_list, thread_random_shutdown)
t->Init(ThreadHandlerSleepRandomTime, nullptr);

thread_counter = 0;
for (int i = 0; i < maximum_allowed_thread_count; i++) {
for (int i = 0; i < maximum_thread_count; i++) {
t->CreateAndAddNewThread(nullptr, nullptr);
}

std::this_thread::sleep_for(std::chrono::milliseconds(100));
t->ShutdownAndWaitForThreadsToFinish();

EXPECT_EQ(t->Size(), 0);
EXPECT_EQ(thread_counter, maximum_allowed_thread_count);
EXPECT_EQ(thread_counter, maximum_thread_count);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@ Job {
# This deletes the copy of the catalog
RunAfterJob = "@scriptdir@/delete_catalog_backup MyCatalog"

# This sends the bootstrap via mail for disaster recovery.
# Should be sent to another system, please change recipient accordingly
Write Bootstrap = "|@bindir@/bsmtp -h @smtp_host@ -f \"\(Bareos\) \" -s \"Bootstrap for Job %j\" @job_email@" # (#01)
Priority = 11 # run after main backup
}

0 comments on commit 73c9573

Please sign in to comment.