Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revised heartbeat check #5864

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 27 additions & 21 deletions samples/vboxwrapper/vboxwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ int main(int argc, char** argv) {
last_checkpoint_elapsed_time = elapsed_time;
last_heartbeat_elapsed_time = elapsed_time;
last_checkpoint_cpu_time = starting_cpu_time;
initial_heartbeat_check = true;


// Choose a random interleave value for checkpoint intervals
Expand Down Expand Up @@ -1050,43 +1051,48 @@ int main(int argc, char** argv) {
}
if (pVM->heartbeat_filename.size()) {

if (elapsed_time >= (last_heartbeat_elapsed_time + pVM->minimum_heartbeat_interval))
{
if (elapsed_time >= (last_heartbeat_elapsed_time + pVM->minimum_heartbeat_interval)) {

int return_code = BOINC_SUCCESS;
bool should_exit = false;
struct stat heartbeat_stat;

if (!shared_file_exists(pVM->heartbeat_filename)) {
vboxlog_msg("VM Heartbeat file specified, but missing.");
return_code = ERR_FILE_MISSING;
should_exit = true;
}

if (shared_stat(pVM->heartbeat_filename, &heartbeat_stat)) {
// Error
vboxlog_msg("VM Heartbeat file specified, but missing file system status. (errno = '%d')", errno);
should_exit = true;
}
} else {

if (initial_heartbeat_check) {
// Force the next check to be successful
last_heartbeat_mod_time = heartbeat_stat.st_mtime - 1;
}
if (shared_stat(pVM->heartbeat_filename, &heartbeat_stat)) {
// Error
vboxlog_msg("VM Heartbeat file specified, but missing file system status. (errno = '%d')", errno);
return_code = ERR_STAT;
should_exit = true;
} else {

if (heartbeat_stat.st_mtime > last_heartbeat_mod_time) {
// Heartbeat successful
last_heartbeat_mod_time = heartbeat_stat.st_mtime;
last_heartbeat_elapsed_time = elapsed_time;
} else {
vboxlog_msg("VM Heartbeat file specified, but missing heartbeat.");
should_exit = true;
if (initial_heartbeat_check) {
// Force the next check to be successful
last_heartbeat_mod_time = heartbeat_stat.st_mtime - 1;
}

if (heartbeat_stat.st_mtime > last_heartbeat_mod_time) {
// Heartbeat successful
last_heartbeat_mod_time = heartbeat_stat.st_mtime;
last_heartbeat_elapsed_time = elapsed_time;
} else {
vboxlog_msg("VM Heartbeat file specified, but missing heartbeat.");
return_code = ERR_TIMEOUT;
should_exit = true;
}
}
}

if (should_exit) {
pVM->reset_vm_process_priority();
pVM->capture_screenshot();
pVM->cleanup();
pVM->dump_hypervisor_logs(true);
boinc_finish(EXIT_ABORTED_BY_CLIENT);
boinc_finish(return_code);
}

initial_heartbeat_check = false;
Expand Down
Loading